setuid program

P

pasear

I find I can't run setuid perl script
when I do this on a Unix-like platform:

1.Create a file "setuid.pl":
#!/usr/bin/perl -T
2.chmod a+x setuid.pl
3.chmod u+s setuid.pl

then i try

shell> ./setuid.pl
Permission denied.

hmm...it always come out with this,
and it's not because i don't have execute permission.
The message was sent by perl,
can anyone tell me how should I write a setuid program in perl?
Without a external wrap on it.
Thank you very much.
 
D

Dale Atkin

The message was sent by perl,
can anyone tell me how should I write a setuid program in perl?

Is it maybe that the perl interpreter is not running as root? What are the
exact permissions on the perl script? I would imagine (but haven't verified)
that if the current user has permission to execute the script, that it will
load as that user, and not as root. Perhaps if the permissions are 700 on
the perl script it might force the execution as root.

Just a thought

Dale
 
P

pasear

Dale Atkin said:
Is it maybe that the perl interpreter is not running as root? What are the
exact permissions on the perl script? I would imagine (but haven't verified)
that if the current user has permission to execute the script, that it will
load as that user, and not as root. Perhaps if the permissions are 700 on
the perl script it might force the execution as root.
Just a thought
Dale
-rwsr-xr-x 1 wchunhao cp 19 Oct 8 00:04 setuid.pl*
I want the program to be run by other people,
and he can be setuid to my uid.
I don't think the owner have to be root since I don't want it to setuid
to root, just setuid to my uid.

How to make it? thank u.
 
K

Kris Wempa

pasear said:
I find I can't run setuid perl script
when I do this on a Unix-like platform:

1.Create a file "setuid.pl":
#!/usr/bin/perl -T
2.chmod a+x setuid.pl
3.chmod u+s setuid.pl

then i try

shell> ./setuid.pl
Permission denied.

hmm...it always come out with this,
and it's not because i don't have execute permission.
The message was sent by perl,
can anyone tell me how should I write a setuid program in perl?
Without a external wrap on it.
Thank you very much.

Setuid scripts are very dangerous. I didn't think the operating system even
honored the setuid bit for scripts. Am I mistaken ? Perl gave me loads of
headaches even when I tried to convert the perl script to a binary file
using perl2exe. Even after 'untainting' all of the variables, there were
still many problems. I ended up having to re-write the program in C, which
also happens to be the safest way to run a program as setuid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top