HI, All,

I am banging my head against the wall on an issue that I think would
be pretty simple; I'm trying to determine whether or not the current
running script has the SetGUID file mode set on it and it is proving
much more challenging than I had originally anticipated.  I am using
OSX version 10.6 and perl version v5.10.0.

Basically my function looks like this:

use Fcntl;
sub isCurrentFileSetGID() {
        my $currentFile = $0;
        my $mode = (stat($currentFile))[2];
        print "Mode: " . $mode . "\n";
        my $MyMask = Fcntl::S_ISGID;
        print "MyMask: " . Fcntl::S_ISGID . "\n";
        my $isItSet =  $mode & Fcntl::S_ISGID;
        print "iSItSet = " . $isItSet . "\n";
        return $isItSet;
}

For some reason, the S_ISGID constant is being interpreted as 1024,
however I am uncertain why.  It appears as "0002000" in
/usr/include/sys/fcntl.h:

#define S_ISGID         0002000         /* [XSI] set group id on execution */

When I execute the script, I am getting 1024 as the output for both
the mask and the operation between the mask and the file mode.  Am I
missing something here?  I would expect this to return 1.  Can
somebody help me shed some light on this?  The output of my execution
against a perl script with the setgid bit set is found below.

wireless-s1-so-150-57-199:Perl dsullivan2$ ls -l
total 8
-rwx--x--x  1 dsullivan2  staff  731 Oct 29 05:55 pw7.pl
wireless-s1-so-150-57-199:Perl dsullivan2$ chmod 2711 pw7.pl
wireless-s1-so-150-57-199:Perl dsullivan2$ ls -l
total 8
-rwx--s--x  1 dsullivan2  staff  731 Oct 29 05:55 pw7.pl
wireless-s1-so-150-57-199:Perl dsullivan2$ ./pw7.pl
Mode: 34249
MyMask: 1024
iSItSet = 1024
wireless-s1-so-150-57-199:Perl dsullivan2$

Thank-you,

Dan Sullivan
312-607-3702

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to