Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am facing a strange problem in which i am having a suid script working on linux, but the same suid script not working on solaris.DOes soalris support suid?? I have the following lines im my script

#!/usr/bin/perl $ENV{PATH}="/bin:/usr/ucb"; my $uid = $<; my $euid = $>; print "\n$uid $euid\n"; mkdir "/home/private/database/mydir", 0777; print "\n$uid $euid\n";
This script is kept in an area /home/private with its suid bit set.Hence the script will run having the permission to of the user "private" and will be able to write in that area...

Now , when i run the script from linux, i get the real user id and effective user id different ie
something like
2204 2224

and i am able to create the directory mydir, as it is to be created by the permissions of effective user id.(The permission of the user who owns the script, not the one who runs it)

But if i run the same on solaris, i get an error saying mkdir "permission denied" and the real uid and the effective user id are the same and that of the user who has run the script, not of the owner of the script!!!

I am not able to understand this behavior on solaris... If any of you has faced such a prob , pls let me know your comments..

Thanks in advance

Edited by Chady -- code tags and minor formatting.

Replies are listed 'Best First'.
Re: suid on solaris??
by rdm (Hermit) on Jun 24, 2004 at 08:36 UTC

    Okay....This is working off a fairly old memory of Solaris - it's been a few years since I've used it.

    Solaris has a policy of 'no scripts shall change uid'. This means that anything that fires off an external interpreter (via the #! magic) will not honour the suid bit.

    OTOH, you should also check your Perl install, and see if it is SUID-enabled, as the policy may have changed.

    Lastly, if you must have an SUID script, and the policy is still in place, or you have a non-SUID Perl, there is 'sudo', which you can use as a wrapper.

    Hope this helps...

    -Reality might not get out of Beta today. (O.Timas, "Bot")
Re: suid on solaris??
by tbone1 (Monsignor) on Jun 24, 2004 at 12:54 UTC
    I just tried this on our Sun box, running Solaris 5.9, and saw what you did. It must be a Solaris thing.

    --
    tbone1, YAPS (Yet Another Perl Schlub)
    And remember, if he succeeds, so what.
    - Chick McGee

Re: suid on solaris??
by pelagic (Priest) on Jun 24, 2004 at 08:35 UTC