Networking Forums

Networking Forums > Computer Networking > Linux Networking > program calls rcmd() twice, _second_ call works for root but notnormal users

Reply
Thread Tools Display Modes

program calls rcmd() twice, _second_ call works for root but notnormal users

 
 
David Mathog
Guest
Posts: n/a

 
      06-15-2005, 06:50 PM
I have a hacked up version of rsh based on inetutils-1.4.2 which accepts
a list of hosts and runs the same command on each of them
(sequentially). In other words, it does this in a loop:

rem = rcmd (&host, sp->s_port, pw->pw_name, user, args, &rfd2);

where the host part changes but the other parts don't. This is so
that I can do:

rsh host1,host2,host3 whatever
or
rsh -f list_of_hosts whatever

instead of

rsh host1 whatever
rsh host2 whatever
rsh host3 whatever

Now the odd part: this modified rsh works just fine for root but for any
other user the rcmd call works once (for the first host) and
then gives a

rcmd: socket: Permission denied

when it attempts a second rcmd call. This is true even if host in
the second rcmd is the same as it was in the first rcmd.
Yes, the modified rsh is suid root, otherwise it wouldn't
even do the first rcmd call.

I tried adding

shutstat=shutdown(rem, SHUT_RDWR);

so that the socket would be closed the second time around but it
made no difference.

Additionally, the exact same behavior is observed when rsh runs
on Mandrake 10.0 or Solaris 8. It seems to be intrinsic somehow
in rcmd.

Can somebody please explain what is going on here???

Thanks,

David Mathog
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
David Mathog
Guest
Posts: n/a

 
      06-17-2005, 05:26 PM
David Mathog wrote:

> Now the odd part: this modified rsh works just fine for root but for any
> other user the rcmd call works once (for the first host) and
> then gives a
>
> rcmd: socket: Permission denied
>
> when it attempts a second rcmd call.


I figured it out. Carried over from the original inetutils/rsh.c
code were two lines

seteuid (uid);
setuid (uid);

just before the signal stuff was set up but after the rcmd() call.
All of this was within the loop over target hosts. Removing these
two lines fixed the problem so that any user could run multiple
rcmd(). It's not clear to me what the purpose of these lines was
in the first place since rsh runs perfectly well without it in the
limited tests I performed.

On the other hand,

rsh -l someotheruser targetnode 'ls'

apparently doesn't work with either my modified code or with
the original code. It just hangs on the sending machine. My
code is based on inetutils 1.4.2


Thanks,

David Mathog
(E-Mail Removed)
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free program to list all wireless users and what they are currently doing on my Windows PC? gsaogwash@yahoo.com Wireless Internet 6 12-02-2008 10:06 AM
Moved DHCP server to DC, now only works for domain users robert.waters Windows Networking 6 08-13-2008 02:13 PM
RCMD and NETSVC TOOLS Rubens Luque Sanches Jr. Windows Networking 0 03-21-2005 08:35 PM
Remote call fail/Local Works Paul B. Linux Networking 2 12-22-2003 01:01 PM
DNS only works as root with Verizon DSL/Netgear router dave Linux Networking 5 11-07-2003 06:41 PM



1 2 3 4 5 6 7 8 9 10 11