Problem: setuid script calling program that forks (I think :) 
Author Message
 Problem: setuid script calling program that forks (I think :)

I want to write a setuid script that calls 'dip' to make a SLIP
connection, does a couple of other things (like running 'netdate'),
and exits.  The problem *seems* to be that, when 'dip' forks to do
it's network configuration stuff, the uid doesn't get carried along.
I tried setting $< to $>, but that didn't help.  In fact, here's the
whole script:

#!/usr/bin/perl

$< = $>;
$( = $);
exec "/sbin/dip /usr/local/etc/wu.dip";
# Set clock
exec "/usr/sbin/netdate ns";

Can anyone see where my mistake is?  I can run it as root, of course
(it's my machine :), but I'm getting tired of su'ing everytime I lose
the connection.

BTW, I'm running perl 4.0.1.8, patch level 36, under Linux (Slackware
1.2, kernel 1.0.8).

Thanks.
--
John A. Breen                   |



Thu, 13 Feb 1997 11:45:02 GMT  
 Problem: setuid script calling program that forks (I think :)

Quote:

>Subject: Problem: setuid script calling program that forks (I think :)
>Date: 27 Aug 1994 22:45:02 -0500
>I want to write a setuid script that calls 'dip' to make a SLIP
>connection, does a couple of other things (like running 'netdate'),
>and exits.  The problem *seems* to be that, when 'dip' forks to do
>it's network configuration stuff, the uid doesn't get carried along.
>I tried setting $< to $>, but that didn't help.  In fact, here's the
>whole script:
>#!/usr/bin/perl
>$< = $>;
>$( = $);
>exec "/sbin/dip /usr/local/etc/wu.dip";
># Set clock
>exec "/usr/sbin/netdate ns";

Hmmm .. where is the fork?
If your problem is that dip works but netdate doesn't, just remember
that netdate is never executed! Try fork()ing first before
you exec dip, and wait() for dip to complete before you exec netdate.

Guntram



Sun, 16 Feb 1997 21:27:56 GMT  
 Problem: setuid script calling program that forks (I think :)

Quote:


>>#!/usr/bin/perl

>>$< = $>;
>>$( = $);
>>exec "/sbin/dip /usr/local/etc/wu.dip";
>># Set clock
>>exec "/usr/sbin/netdate ns";

>Hmmm .. where is the fork?

The fork is in dip itself.  Near as I can tell, dip dials the modem,
makes the connection, then forks to do the actual interface config and
route setup.  At least these are the parts that I get errors on when I
run it under a non-root account (and yes, I'm pretty sure I have the
protection of the script set correctly; dip won't normally run at all
unless you're root).

Quote:
>If your problem is that dip works but netdate doesn't, just remember
>that netdate is never executed!

Yes, sorry about that :-).  I had been using system(), but changed to
exec() to see if it made any difference.  I forgot to change it back
before I posted.  But no, the problem isn't that netdate doesn't run.
It's a privilege violation inside dip itself.  I've been assuming that
it's because the process that dip forks is no longer running as root.
--
John A. Breen         | I teleported home one night with Ron & Sid & Meg.

                      |                            - Douglas Adams


Tue, 18 Feb 1997 22:04:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. SOLUTION to: Problem executing program from a Perl script called by HTTP Server

2. Problem executing program from a Perl script called by HTTP Server

3. Setuid scripts don't work when I call perl5.003 perl5

4. Q: cannot rsh in setuid script called from CGI

5. setuid wrapper program for perl4 script...

6. compiler-a3: problem with setuid perl program

7. perl script for calling a java program,running the script through cgi of the web server

8. calling other scripts/programs from cgi scripts.

9. call external script - fork

10. Forking Problem w/ Netscape Server dealing w/ Cgi-scripts and Perl Scripts

11. Problem with setuid scripts.

12. setuid script problem under 4.036

 

 
Powered by phpBB® Forum Software