]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
userdbctl: flush stdout before running the chain command
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 24 Mar 2023 16:17:31 +0000 (17:17 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 24 Mar 2023 16:17:31 +0000 (17:17 +0100)
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

src/userdb/userdbctl.c

index 86b8d383df06e5b380bb3d9793ed3069d917d41f..eab0c3af1515987c6b1ef053fca7260f52613969 100644 (file)
@@ -1038,6 +1038,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]);