Subject: Re: using rsh: "stty: TIOCGETD: Operation not supported"
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-help
Date: 04/20/2001 19:47:54
>> But I still don't understand why it connected and executed the command
>> (when rlogind isn't running).
>>
>> My other email (I sent today) shows the examples.
>
>'rsh host' will in fact call rlogin, and so connect to rlogind of host
>'rsh host ls' will to a rsh to host, and so connect to rshd of the remote
>host
>the magic is that rsh will exec rlogin if it has no command
addendum:
if you attempt to do 'rsh localhost command', then rmcd() in libc will
see that you are (a) trying to connect to localhost specifically, (b)
see that you are trying to do it as yourself and not someone else, and
(c) execute a command instead of logging in.
what rcmd() does in this particular case is establish a socketpair()
over which to run the command instead of connecting via tcp and then
call fork().
what this means is that 'rsh localhost echo foo' will *always* work,
regardless of the state of your network configuration (be it up, down,
or broken), inetd configuration (or even if inetd is running), or
personal opinions on the use of r-commands.
example:
% tty
/dev/ttyp2
% rsh localhost 'whoami ; ps tp2'
andrew
PID TT STAT TIME COMMAND
280 p2 Ss 0:02.93 -csh (tcsh)
17522 p2 S+ 0:00.00 rsh localhost whoami ; ps tp2
17524 p2 S+ 0:00.03 tcsh -c whoami ; ps tp2
17525 p2 S+ 0:00.03 rsh localhost whoami ; ps tp2
17527 p2 R+ 0:00.00 ps tp2
% rsh localhost 'fstat -p $$'
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
andrew tcsh 17530 wd /usr 843201 drwxr-xr-x 512 r
andrew tcsh 17530 16* unix stream c0903f80 <-> c07c5f00
andrew tcsh 17530 17* unix stream c0903f80 <-> c07c5f00
andrew tcsh 17530 18* unix stream c08c4b40 <-> c08c4d40
andrew tcsh 17530 19* unix stream c0903f80 <-> c07c5f00
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."