rshd depends on risky assumption

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Aug 23 17:18:43 AEST 1989


The 4.3BSD rshd (normally in its child branch) unconditionally closes an FD
named "f" in the source code without checking whether f = 0, 1, or 2.  If
inetd always starts the slave process with all three FDs open, this will work,
but it seems an unsafe assumption.  (Only FD 0 is documented as being set up
by inetd.)  There's no particular reason FD "f" shouldn't have been closed
back where the dup2(f,*)s occur, being careful not to close(f) unless f > 2.

By the way, to anyone who studies the rsh/rshd implementation, it should be
apparent that it would be really useful to have a way to ask the kernel to
"pump" data from one socket into another, instead of having to spawn a child
process to do the pumping.  With the kernel doing it, there would be far fewer
context switches.

Yours for improved plumbing...



More information about the Comp.bugs.4bsd.ucb-fixes mailing list