When ssh-agent is run in foreground mode with -d and stdout is not a
terminal, the output including the path to the listening socket and
PID may not be written before the main loop begins. Since no further
output is written to stdout, this output may never be written.

$ ssh-agent -d < /dev/null 2> /dev/null | cat
^C
$

This behavior is important when wrapping ssh-agent in another daemon.

Thank you,


Dustin Lundquist


Index: usr.bin/ssh/ssh-agent.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/ssh-agent.c,v
retrieving revision 1.204
diff -u -r1.204 ssh-agent.c
--- usr.bin/ssh/ssh-agent.c 8 Jul 2015 20:24:02 -0000 1.204
+++ usr.bin/ssh/ssh-agent.c 1 Dec 2015 22:05:17 -0000
@@ -1301,6 +1301,7 @@
  printf(format, SSH_AUTHSOCKET_ENV_NAME, socket_name,
     SSH_AUTHSOCKET_ENV_NAME);
  printf("echo Agent pid %ld;\n", (long)parent_pid);
+ fflush(stdout);
  goto skip;
  }
  pid = fork();

Reply via email to