how to set SUID bit ???

Here is what I am doing:

as root creating the file test.pl:

#!/usr/bin/perl
printf("My uid is $> (%s)\n", (getpwuid($>))[0]);

then,

#chmod a+x ./test.pl
#chmod u+s ./test.pl
#./test.pl
My uid is 0 (root)
#ls -l
-rwsr-xr-x 1 root wheel 67 Mar 9 16:11 test.pl

after that, as administrator:
#./test.pl
My uid is 501 (administrator)

Why the SUID bit is not working ???



PB G4 Mac OS X (10.4.8)

Posted on Mar 12, 2007 5:31 AM

Reply
2 replies

Mar 12, 2007 8:12 AM in response to Antonio Ivanovo

If I remember correctly, setuid is usually disabled in Perl. You may need to recompile Perl in order to support that. I have not run setuid Perl scripts on OS X, but I can't imagine Apple compiled in setuid support when it's generally disabled in the Perl distribution.

Even if it is enabled, after you chmod u+s the file permissions of your script, you need to actually invoke the effective user change inside your script. It's just like a C program in this regard. The setuid bit grants the program the ability to actually have the setuid() library call function as intended.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how to set SUID bit ???

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.