On Nov 26, 2005, at 4:58 AM, John W. Krahn wrote:


You could use perl's built-in getgrnam function to do that:

$ perl -le' $shouldbegid = getgrnam "uucp"; print $shouldbegid'
14


Cool, that's much better.  Thanks.



I think you may misunderstand how the & operator works. You are telling it to turn off bits in $perms->mode that are not turned on in both $perms- >mode and
$shouldbemode.  For example:

$ perl -e' $x = 0777; $y = 0660; printf "%#o\n", $x & $y'
0660
$ perl -e' $x = 0; $y = 0660; printf "%#o\n", $x & $y'
0


OK, I think I understand better now, thanks. So, since I'm looking for a specific mode, I just need to do this:

my $shouldbemode = 0100660;     # -rw-rw---- perms
my $perms = stat($conffile)
        || die "can't find $conffile: $!\n";

unless ($perms->mode == $shouldbemode)) {
                print "Aborting! Incorrect config file perms!\n";
                exit 1
}

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to