1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-12 21:57:27 +03:00

userdbctl: flush stdout before running the chain command

Otherwise it's quite difficult to capture the entire output:

$ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA//dxI2xLg4MgxIKKZv1nqwTEIlE/fdakii2Fb75pG+ foo@bar.tld
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMlaqG2rTMje5CQnfjXJKmoSpEVJ2gWtx4jBvsQbmee2XbU/Qdq5+SRisssR9zVuxgg5NA5fv08MgjwJQMm+csc= hello@world.tld
hello
$ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello | tee
hello

(cherry picked from commit 5b09499cacd3c1c95ab240d041e28cc954a5975d)
(cherry picked from commit 0e7745249b1c576f89fb97ee76c3bf4c83d8f299)
This commit is contained in:
Frantisek Sumsal 2023-03-24 17:17:31 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent ebcd284358
commit 73afda3f6d

View File

@ -1037,6 +1037,7 @@ static int ssh_authorized_keys(int argc, char *argv[], void *userdata) {
log_debug("Chain invoking: %s", s);
}
fflush(stdout);
execv(chain_invocation[0], chain_invocation);
if (errno == ENOENT) /* Let's handle ENOENT gracefully */
log_warning_errno(errno, "Chain executable '%s' does not exist, ignoring chain invocation.", chain_invocation[0]);