habit_forming has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks! Please see fit to answer my question.

Why does the -T disable the rdo function from Safe.pm?
Here is an example:

#!/usr/bin/perl -T use warnings; use strict; use Safe; my $s = new Safe 'SAFE'; $s->permit(qw( print )); $s->share_from('main',['*STDOUT']); $s->rdo('do.pl'); if($@){ print "Error: $@"; } else { print "No Error.\n"; }
Does not work where as:
#!/usr/bin/perl #Notice NO -T use warnings; use strict; use Safe; my $s = new Safe 'SAFE'; $s->permit(qw( print )); $s->share_from('main',['*STDOUT']); $s->rdo('do.pl'); if($@){ print "Error: $@"; } else { print "No Error.\n"; }
Works like a champ!
Note that do.pl contains this:
#!/usr/bin/perl print STDOUT "This is the client script.\n";


I have not been able to find an example of someone else having this problem. There is no mention of this in any documentation I have seen. I little help please.

Cheers!
--habit

Replies are listed 'Best First'.
Re: -T and Safe.pm
by Joost (Canon) on Feb 16, 2005 at 19:48 UTC
Re: -T and Safe.pm
by jbrugger (Parson) on Feb 16, 2005 at 19:08 UTC
    <hunchmode> Perhaps its your version of safe, linuxsecurity.com
    safe.pm 2.0.7 and earlier, when used in Perl 5.8.0 and earlier, may allow attackers to break out of safe compartments in (1) Safe::reval or (2) Safe::rdo using a redefined @_ variable, which is not reset between successive calls.
    Perhaps perl -T doesn't like that? </hunchmode>