[K42-discussion] rlogin eof patch
Patrick Bozeman
PEBozeman at lbl.gov
Thu Feb 16 13:12:54 EST 2006
If a new K42 user accidentally tries to rlogin to K42 via ssh rather
than rlogin, they can hang the K42 rlogin daemon.
It is fairly common for linux distributions to symlink rlogin to ssh.
If a new user tries to run 'rlogin -p <k42-rlogin-port>' on such a
distribution, the login will fail. If they then kill the ssh process,
the K42 rlogin daemon gets stuck in an infinite loop spewing, "DEBUG:
ReadStr: read() returned 0: Success." to the console because it isn't
properly handling the EOF condition on the socket. (Note, this happened
to me and it took me awhile to figure out why my login was failing.)
This patch adds EOF checking to the ReadStr function in the pty/Login
implementation. I also added EINTR handling, but I'm not sure if it is
necessary in K42 applications or not.
Since the native recv is being called in two places, I added a new
function, ReadByte, following the semantics and err_printf usage of the
existing ReadStr, e.g. it returns a uval, with 1 indicating success.
ReadStr was changed to use ReadByte as was the initial handshake read in
HandShake.
Note that this process is pretty inefficient since its only reading one
byte at a time from the socket, but that's how the ReadStr function
worked prior to the patch too. Since this is only done during the
handshake code, it doesn't seem worth changing.
I also added an err_printf if EOF is detected on the socket during the
rlogin handshake, which would most likely occur at the start when a user
hits ctrl-c from a stuck ssh connection on the rlogin port. Hopefully,
this is enough to help them figure out what is wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: k42-rlogin-eof.patch
Type: text/x-patch
Size: 2506 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/k42-discussion/attachments/20060215/04bb5184/attachment.bin
More information about the K42-discussion
mailing list