Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: perl -T script.pl and #!/usr/bin/perl -T conflict

by rlk (Pilgrim)
on Jan 24, 2001 at 23:54 UTC ( [id://54100]=note: print w/replies, xml ) Need Help??


in reply to perl -T script.pl and #!/usr/bin/perl -T conflict

Here's the simple solution.
#!/usr/bin perl -w print "Script started\n"; eval { exec("perl -wT $0") #Only works if taint mode off }; print "Now we're in taint mode!\n";
Unfortunately, if your script is suid, this has a gaping security hole, as you've just executed an arbitrary program as root. (Was it /usr/bin/perl as you were expecting, or was it /home/l33t_hax0r/bin/perl? With an insecure $ENV{PATH}, you'll never know.)

Here's a version that fixes that particular hole

#!/usr/bin perl -w print "Script started\n"; eval { $ENV{PATH}, exec("/path/to/perl -wT $0") #Only works if ta +int mode off }; print "Now we're in taint mode!\n";
Eliminating the "useless use of a hash element in void context" message is left as an exercise for the reader. (Hint: look at the is_tainted function example in perlsec)

--
Ryan Koppenhaver, Aspiring Perl Hacker
"I ask for so little. Just fear me, love me, do as I say and I will be your slave."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://54100]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found