sshd's -e doesn't work as expected

Jim Knoble jmknoble at pobox.com
Thu Dec 27 10:41:45 EST 2007


I think the intent was for '-e' to be used with '-D':

__________[from sshd(8)]__________

-D      When this option is specified, sshd will not detach and
        does not become a daemon.  This allows easy monitoring of sshd.

__________[end sshd(8)]__________

Perhaps sshd should complain if '-e' appears without '-D'?

--jim

Circa 2007-12-26 15:15 dixit Julio M. Merino Vidal:

: Hello,
: 
: I'm running a sshd server using the -e flag so that I can capture its
: whole output and later send it to the user.  I'm also setting LogLevel
: to DEBUG1 in the configuration file and I don't want to disturb syslogd.
: But the problem is that it doesn't work as expected (or as I expect,
: which I think should be the correct behavior).  The log file ends up
: being empty because the call to daemon(0, 0) done by the server
: effectively closes the stderr stream and all prints to it do not work.
: 
: I've fixed this issue with the attached patch.  Hope that it is OK and
: can be committed.  If not, please tell me why.
: 
: Thank you,
: 
: Index: sshd.c
: ===================================================================
: RCS file: /cvsroot/src/crypto/dist/ssh/sshd.c,v
: retrieving revision 1.42
: diff -u -p -r1.42 sshd.c
: --- sshd.c	18 Dec 2007 02:35:33 -0000	1.42
: +++ sshd.c	26 Dec 2007 20:12:22 -0000
: @@ -1485,8 +1485,16 @@ main(int ac, char **av)
:  	if (!(debug_flag || inetd_flag || no_daemon_flag)) {
:  		int fd;
:  
: -		if (daemon(0, 0) < 0)
: +		if (daemon(0, 1) < 0)
:  			fatal("daemon() failed: %.200s", strerror(errno));
: +		close(STDIN_FILENO);
: +		open(_PATH_DEVNULL, O_RDONLY);
: +		close(STDOUT_FILENO);
: +		open(_PATH_DEVNULL, O_WRONLY);
: +		if (!log_stderr) {
: +			close(STDERR_FILENO);
: +			open(_PATH_DEVNULL, O_WRONLY);
: +		}
:  
:  		/* Disconnect from the controlling tty. */
:  		fd = open(_PATH_TTY, O_RDWR | O_NOCTTY);
: 
: -- 
: Julio M. Merino Vidal <jmmv at NetBSD.org>
: _______________________________________________
: openssh-unix-dev mailing list
: openssh-unix-dev at mindrot.org
: https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
: 

-- 
jim knoble  |  jmknoble at pobox.com  |  http://www.pobox.com/~jmknoble/
(GnuPG key ID: 6F39C2CC  >>>>>>  http://www.pobox.com/~jmknoble/keys/ )
(GnuPG fingerprint: 5024:D578:7CF4:5660:7269::F6F3:B919:9307:6F39:C2CC)
+----------------------------------------------------------------------+
|[L]iberty, as we all know, cannot flourish in a country that is perma-|
| nently on a war footing, or even a near-war footing.  --Aldous Huxley|
+----------------------------------------------------------------------+


More information about the openssh-unix-dev mailing list