- if (defined $param{safe}) {
- $safe = $param{safe};
- if (not defined $hole) {
- $hole = Safe::Hole->new();
- }
- }
- else {
- print STDERR "Created new safe\n" if $DEBUG;
- $safe = Safe->new() or die "Unable to create safe compartment";
- $safe->deny_only();
- my @modules = ('Text::Template' => undef,
- # This doesn't work yet; have to figure it out
- #'Debbugs::Config' => [qw(:globals :config)],
- );
- while (my ($module,$param) = splice (@modules,0,2)) {
- print STDERR "Eval $module\n" if $DEBUG;
- my $code = '';
- if (not defined $param) {
- $code = "use $module;";
- }
- else {
- $code = "use $module ".(join(',',map {"q($_)"} @{$param})).';';
- }
- $safe->reval($code);
- print STDERR "Error while attempting to eval '$code': $@" if $@;
- }
- $safe->permit_only(':base_core',':base_io',':base_mem',':base_loop',
- qw(padsv padav padhv padany),
- qw(rv2gv refgen srefgen ref),
- );
- $safe->share('$language','%tt_templates','$safe','$variables','%filled_templates');
- $safe->share('*STDERR');
- $safe->share('&_fill_in_template');
- $safe->share('%config');
- $safe->share('&include');
- my $root = $safe->root();
- # load variables into the safe
- for my $key (keys %{$param{variables}||{}}) {
- print STDERR "Loading $key\n" if $DEBUG;
- if (ref($param{variables}{$key})) {
- no strict 'refs';
- print STDERR $safe->root().'::'.$key,qq(\n) if $DEBUG;
- *{"${root}::$key"} = $param{variables}{$key};
- }
- else {
- no strict 'refs';
- ${"${root}::$key"} = $param{variables}{$key};
- }
- }
- for my $key (keys %{$param{hole_var}||{}}) {
- $hole->wrap($param{hole_var}{$key},$safe,$key);
- }
- }
- #$safe->deny_only();
- # perldoc Opcode; for details
+# if (defined $param{safe}) {
+# $safe = $param{safe};
+# }
+# else {
+# print STDERR "Created new safe\n" if $DEBUG;
+# $safe = Safe->new() or die "Unable to create safe compartment";
+# $safe->permit_only(':base_core',':base_loop',':base_mem',
+# qw(padsv padav padhv padany),
+# qw(rv2gv refgen srefgen ref),
+# qw(caller require entereval),
+# qw(gmtime time sprintf prtf),
+# qw(sort),
+# );
+# $safe->share('*STDERR');
+# $safe->share('%config');
+# $hole->wrap(\&Debbugs::Text::include,$safe,'&include');
+# my $root = $safe->root();
+# # load variables into the safe
+# for my $key (keys %{$param{variables}||{}}) {
+# print STDERR "Loading $key\n" if $DEBUG;
+# if (ref($param{variables}{$key})) {
+# no strict 'refs';
+# print STDERR $safe->root().'::'.$key,qq(\n) if $DEBUG;
+# *{"${root}::$key"} = $param{variables}{$key};
+# }
+# else {
+# no strict 'refs';
+# ${"${root}::$key"} = $param{variables}{$key};
+# }
+# }
+# for my $key (keys %{exists $param{hole_var}?$param{hole_var}:{}}) {
+# print STDERR "Wraping $key as $param{hole_var}{$key}\n" if $DEBUG;
+# $hole->wrap($param{hole_var}{$key},$safe,$key);
+# }
+# }