Commit a2f411f8 authored by Yadd's avatar Yadd
Browse files

New "require" parameter (fixes: #1309)

parent d0583bb7
......@@ -10,6 +10,8 @@ has customFunctions => ( is => 'rw', isa => 'Maybe[Str]' );
has useSafeJail => ( is => 'rw', isa => 'Maybe[Int]' );
has require => ( is => 'rw', isa => 'Maybe[Int]' );
has jail => ( is => 'rw' );
has error => ( is => 'rw' );
......@@ -20,7 +22,7 @@ our $VERSION = '2.0.0';
# Build and return the security jail used to compile rules and headers.
# @return Safe object
sub build_jail {
my ( $self, $api ) = @_;
my ( $self, $api, $require ) = @_;
return $self->jail
if ( $self->jail
......@@ -30,6 +32,20 @@ sub build_jail {
$self->useSafeJail(1) unless defined $self->useSafeJail;
if($require) {
foreach my $f (split /[, ]+/, $require) {
if($f =~ /^[\w\:]+$/) {
eval "require $f";
}
else {
eval "require '$f'";
}
if($@) {
die "Unable to load required files: $@";
}
}
}
my @t =
$self->customFunctions ? split( /\s+/, $self->customFunctions ) : ();
foreach (@t) {
......
......@@ -167,11 +167,11 @@ sub jailInit {
$class->tsv->{jail} = Lemonldap::NG::Handler::Main::Jail->new(
{
'useSafeJail' => $conf->{useSafeJail},
'customFunctions' => $conf->{customFunctions}
useSafeJail => $conf->{useSafeJail},
customFunctions => $conf->{customFunctions},
}
);
$class->tsv->{jail}->build_jail($class);
$class->tsv->{jail}->build_jail( $class, $conf->{require} );
}
## @imethod protected void defaultValuesInit(hashRef args)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment