Package: rsh-redone-server
Version: 81-2
Severity: normal
Tags: patch

rsh -n localhost 'sleep 100 < /dev/null > /dev/null 2>&1 &'

should return immediately, not after 100s.

With rshd from rshd-redone-server, it doesn't. This is because
rshd forgets to close the fd that has been used to setup the
second connection for stderr after it has been dup'ed to 2.

$ rsh -n localhost 'sleep 100 < /dev/null > /dev/null 2>&1 &' &
[2] 18405
$ lsof -c sleep
COMMAND   PID     USER   FD   TYPE DEVICE    SIZE     NODE NAME
sleep   18407 chazelas  cwd    DIR    8,3   36864 16613378 /home/chazelas
sleep   18407 chazelas  rtd    DIR    8,3    4096        2 /
sleep   18407 chazelas  txt    REG    8,3   23504  7848172 /bin/sleep
sleep   18407 chazelas  mem    REG    8,3 4071824 15286302 
/usr/lib/locale/locale-archive
sleep   18407 chazelas  mem    REG    8,3 1360292 11194941 
/lib/i686/cmov/libc-2.7.so
sleep   18407 chazelas  mem    REG    8,3  109152 24053305 /lib/ld-2.7.so
sleep   18407 chazelas    0r   CHR    1,3               91 /dev/null
sleep   18407 chazelas    1w   CHR    1,3               91 /dev/null
sleep   18407 chazelas    2w   CHR    1,3               91 /dev/null
sleep   18407 chazelas    3u  IPv4 114413              TCP 
localhost:1021->localhost:1022 (ESTABLISHED)

patch:

--- rshd.c~     2008-05-06 20:49:46.000000000 +0100
+++ rshd.c      2008-05-06 20:38:06.000000000 +0100
@@ -224,6 +224,8 @@ int main(int argc, char **argv) {
                        syslog(LOG_ERR, "dup2() failed: %m");
                        return 1;
                }
+               if(esock != 2)
+                       close(esock);
        }
 
        /* Read usernames and terminal info */

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-rc8 (PREEMPT)
Locale: LANG=en_GB.ISO-8859-15, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages rsh-redone-server depends on:
ii  libc6                         2.7-10     GNU C Library: Shared libraries
ii  libpam0g                      0.99.7.1-6 Pluggable Authentication Modules l
ii  xinetd [inet-superserver]     1:2.3.14-7 replacement for inetd with many en

rsh-redone-server recommends no packages.

-- no debconf information
--- rshd.c~	2008-05-06 20:49:46.000000000 +0100
+++ rshd.c	2008-05-06 20:38:06.000000000 +0100
@@ -224,6 +224,8 @@ int main(int argc, char **argv) {
 			syslog(LOG_ERR, "dup2() failed: %m");
 			return 1;
 		}
+		if(esock != 2)
+			close(esock);
 	}
 
 	/* Read usernames and terminal info */

Reply via email to