1833722 Members
2619 Online
110063 Solutions
New Discussion

Perl setuid scripts?

 
SOLVED
Go to solution
Robert Comber
Advisor

Perl setuid scripts?

Hi,

How can I make my Perl script run as root when run as a regular user? Nothing I try seems to work even when the script has the setuid bit set and is owned by root.

I am running Perl 5.6.1 on HP-UX 11.0.

Thanks,
Bob
2 REPLIES 2
Mark Grant
Honored Contributor
Solution

Re: Perl setuid scripts?

perl recognizes when it is running as a setuid and takes defensive measures to stop you doing insecure things in it.

Generally this means it dosn't work. The easiest way around it is with a 'C' wrapper.

Have a look at this link for an example. If you've never done any 'C' before compile with something like theo following. Save your code as perlwrapper.c

cc -s -o perlwrapper perlwrapper.c

http://lists.q-linux.com/pipermail/ph-perl/2001-March/000059.html

Never preceed any demonstration with anything more predictive than "watch this"
A. Clay Stephenson
Acclaimed Contributor

Re: Perl setuid scripts?

As noted, this is intentional in the design of Perl. Personally, ANY scripts that run as setuid root scare me to death. If you do make a C wrapper, make absolutely certain that the permissions on both the wrapper and the script itself are as tight as you can make them. If not, all an intruder has to do is replace your script with his and he in home free.
If it ain't broke, I can fix that.