in reply to Safe usage
No, it is not possible. Safe.pm does not allow for XS modules to be loaded, only pure Perl modules can be loaded. The only way of making XS modules like Data::Dumper work, is by pre-loading them and sharing the symbol table. use them inside of the compartment's package to import the symbols to the right place.
This doesn't work well if the module has more namespaces.use Safe; my $safe = Safe->new('Safe::Compartment'); $safe->permit(Opcode::full_opset); for my $module (qw/Data::Dumper/) { (my $file = "$module.pm") =~ s!::!/!g; $safe->share('*' . $module . '::'); package Safe::Compartment; require $file; $module->import(); } $safe->reval(qq{ use Data::Dumper; # Already done, so not needed. print Dumper([ 1..10 ]), "\n"; }); warn $@ if $@;
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
|---|