in reply to $0 in suid enabled script
in thread Insecure dependency in system under -T, with list form invocation

there is caller and __FILE__
C:\>more temp.pl #!/usr/bin/perl -- use strict; use warnings; my ($package, $filename, $line) = eval { caller }; print "\$0 $0\n"; print "filename $filename\n"; print "__FILE__ ", __FILE__,"\n"; __END__ C:\>perl temp.pl $0 temp.pl filename temp.pl __FILE__ temp.pl C:\>

Replies are listed 'Best First'.
Re^2: $0 in suid enabled script (not SUID)
by tye (Sage) on Sep 15, 2008 at 15:18 UTC

    Since $0 isn't anything like "/dev/fd/4" above, you haven't demonstrated that your assumptions apply in the situation described. I'd be quite surprised if they did. You show 3 different ways of getting exactly the same string. When $0 returns "/dev/fd/4", the other two most likely return that exact same string as well.

    - tye        

      You're most likely correct, but its for him to try, I don't have fedora.
        Fedora? Solaris.

        Exactly as predicted, your script works as intended as I run it myself, but shows the same problem as the one I complained about, once I suid it, and run it as an other user:

        $ id uid=54482(emagiro) gid=17465(ath) $ /tmp/showfile $0 /tmp/showfile filename /tmp/showfile __FILE__ /tmp/showfile $ chmod u+s /tmp/showfile $ ll /tmp/showfile -rwsr-xr-x 1 emagiro ath 208 Sep 15 16:37 /tmp/showfile ~> id uid=33629(eeivob05) gid=17465(ath) ~> /tmp/showfile $0 /dev/fd/4 filename /dev/fd/4 __FILE__ /dev/fd/4