da w00t has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Opcode; use Text::Template; use Safe; my @names = Opcode::opset_to_ops(Opcode::full_opset); foreach my $name (@names) { my (@feh); my ($cmptmt); undef $cmptmt; print "trying name $name..\t\t"; $cmptmt = new Safe; push @feh,$name; $cmptmt->permit_only(@feh); $Journal::true = 10; my $template_text = '{$true}'; my $template = new Text::Template (TYPE => 'STRING', SOURCE => $template_text, SAFE => $cmptmt); my $return_text = $template->fill_in(PACKAGE => Journal); if ($return_text eq "10") { print "return text is ok... "; $cmptmt1 = new Safe; $cmptmt1->permit_only(@feh); my $template_text1 = '{open(PASSWD,"/etc/passwd");read(PASSWD,$_,1 +,0);print}'; $template1 = new Text::Template (TYPE => 'STRING', SOURCE => $template_text1, SAFE => $cmptmt1); if ($return_text1 = $template1->fill_in(PACKAGE => Journal) == 1) { print "Um, ok?\n"; } else { print "Bad!!\n"; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: use Safe;
by ColtsFoot (Chaplain) on May 07, 2001 at 14:02 UTC | |
(tye)Re: use Safe;
by tye (Sage) on May 07, 2001 at 20:38 UTC | |
Re: use Safe;
by da w00t (Sexton) on May 08, 2001 at 03:17 UTC |