*BSD News Article 82694


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.mel.connect.com.au!news.mel.aone.net.au!news-out.internetmci.com!news.internetMCI.com!newsfeed.internetmci.com!howland.erols.net!news.mathworks.com!uunet!in3.uu.net!news.eden.com!interval.net!arlut.utexas.edu!usenet
From: Ian Fink <fink@arlut.utexas.edu>
Newsgroups: comp.unix.admin,comp.unix.questions,comp.unix.bsd.bsdi.misc
Subject: Re: Setuid Problem
Date: Mon, 11 Nov 1996 15:45:37 -0600
Organization: Applied Research Laboratories - The University of Texas at Austin
Lines: 48
Message-ID: <32879E81.777B@arlut.utexas.edu>
References: <567ko8$6dd@sleipnir.iaccess.com.au>
NNTP-Posting-Host: seadevil.arlut.utexas.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (X11; I; HP-UX A.09.05 9000/730)
To: Phillip Krokidis <phil@iaccess.com.au>
Xref: euryale.cc.adfa.oz.au comp.unix.admin:50170 comp.unix.questions:91062 comp.unix.bsd.bsdi.misc:5251

Phillip Krokidis wrote:
> 
> Hello,
> 
> Im having problems getting setuid to work on a bsdi 1.1 system
> I have set the owner of a file as root and the "s" bit as
> follows:
> 
> -rwsrwxr-x  1 root  wheel    1815 Nov  3 22:59 file.pl
> 
> If I try to run the program by sending email to an alias
> in the sendmail /etc/aliases file ie. alias: "|/path_to_file/file.pl"
> the program will not run as root but as daemon with effective and real id
> of "1".
> 
> Can anyone suggest a way to get this working?
> 
> Thanks,
> Phil
> phil@iaccess.com.au


If your Perl script is trying to write to a file, then in general
kernel won't let you unless you recompile your kernel to allow setuid
scripts.

I have been able to get around this (sometimes) by writing a C wrapper.
The wrapper has the uid set (no uid set on the script), and then
it forks and exec's the script.  

In the exec, I generally do an: 

execlp("/usr/bin/perl", "/usr/bin/perl", "/path/to/file.pl", NULL);

before that, create a pipe to the child process, and redirect the
stdin and stdout to it...

And make sure that the $ENV{"PATH"} has paths to any outside program
it needs to run in file.pl.

But to solve (maybe create more) problems better, try downloading
the Perl Compiler Kit by Malcom Beatle.

This will allow you to creat a stand-alone executable of your Perl
script which you can set uid bits without hassle ;)

Ian Fink
fink@arlut.utexas.edu