Perl and setuid

John Evans evansj at kilnar.com
Tue Jun 5 18:08:31 CDT 2001


On Tue, 5 Jun 2001, Keary Suska wrote:

> Is the web server running a cgi wrapper program? Perhaps that is running
> interference. Another possibility is that the kernel isn't allowing setuid
> from nobody, but that's a long shot. I have heard that some systems are
> picky about the uid of nobody as regards setuid, notably Solaris, which
> won't allow setuid if from a uid of -2.
>
> That's all I can think of. Can you test the cgi from the command line to see
> if it will setuid from an account other than nobody?

To answer your questions:

No wrapper program. I am not using the CGIWrap or SUExec options that come
with Apache.

Apache runs as nobody, but not sure if Linux 2.2.16 stops nobody from
running suid programs.

I can run the program from the command-line as other users and the suid
portion is not working... I have the following code in the script:

open(LOG, ">>/tmp/cvsweb.log");
printf LOG ("R: %d\t%d\n", $<, $();  ## Prints real uid/gid
printf LOG ("E: %d\t%d\n", $>, $));  ## Prints effective uid/gid
printf LOG ("-" x 40 . "\n");
close(LOG);

The logfile is showing the real and effective IDs to be the same, so I'm
not sure what's going on??

ls -l shows:
-rwsr-sr-x    1 spear    coders      79471 Jun  5 18:56 index.cgi

The rws and r-s shows the sticky bits are on...


I've searched through my Perl docs and have found nothing special that you
have to do to allow for Perl scripts to allow suid to run as the proper
user. Maybe I'm missing something.

I've even written a simple script:
#!/usr/bin/perl -w

open(LOG, ">>/tmp/test.log");
printf LOG ("R: %d\t%d\n", $<, $();
printf LOG ("E: %d\t%d\n", $>, $));
printf LOG ("-" x 40 . "\n");
close(JOHN);

### end perl

and it does not run suid even with chmod 4755.


I really do appreciate the time and thoughts that you guys have given
forth. Hopefully something will come to one of us in the near future.


-- 
John Evans
http://evansj.kilnar.com/





More information about the Pikes-peak-pm mailing list