Perl can be configured to ignore SUID scripts; this is the default and most likely the way you are configured. You must print the real and effective UID and GID in the script.
You can verify this specifically with Perl's modestly hidden single-line interface:
$ perl -MConfig -e 'foreach $key (keys %Config) { print "$key = $Config{$key}\n"; }' | > grep -i -e 'se*t*[ug]id' d_dosuid = d_setresgid = define d_setresuid = define d_suidsafe = $
Or, a little less obscure, now I have found the correct name:
$ perl -MConfig -e 'print "d_suidsafe = $Config{d_suidsafe}\n"' d_suidsafe = $
This shows that this Perl (built by me on 5.12.1) does not consider SUID scripts safe.
Real and effective values ββfor user and group identifiers can be obtained using: RUID $<
, EUID $>
, RGID $(
and EGID $)
or (more reasonably) using English:
#!/usr/bin/env perl use English '-no_match_vars'; print "EUID = $EUID; RUID = $UID; EGID = $EGID; RGID = $RGID\n";
source share