Commit 80f17a91 authored by Yadd's avatar Yadd
Browse files

Compile macros and groups (#595)

parent 41d487ee
......@@ -181,7 +181,26 @@ sub reloadConf {
}
}
# TODO: compile macros in _macros, groups in _groups
# Compile macros in _macros, groups in _groups
foreach my $type (qw(macros groups)) {
$self->{"_$type"} = {};
if ( $self->conf->{$type} ) {
for my $name ( sort keys %{ $self->conf->{$type} } ) {
my $sub = HANDLER->tsv->{jail}->jail_reval(
"sub{return(" . $self->conf->{$type}->{$name} . ")}" );
if ($sub) {
$self->{"_$type"}->{$name} = $sub;
}
else {
$self->lmLog(
"$type $name returns an error: "
. HANDLER->tsv->{jail}->error,
'error'
);
}
}
}
}
# Load plugins
foreach my $plugin ( $self->enabledPlugins ) {
......
......@@ -152,7 +152,7 @@ sub setSessionInfo {
$req->{sessionInfo}->{_url} = $req->datas->{urldc};
# Share sessionInfo with underlying handler (needed for safe jail)
HANDLER->datas($req->{sessionInfo});
HANDLER->datas( $req->{sessionInfo} );
# Call UserDB setSessionInfo
return $self->_userDB->setSessionInfo($req);
......@@ -163,7 +163,7 @@ sub setSessionInfo {
sub setMacros {
my ( $self, $req ) = @_;
foreach ( sort keys %{ $self->_macros } ) {
$req->{sessionInfo}->{$_} = $self->_macros->{$_}->($req);
$req->{sessionInfo}->{$_} = $self->_macros->{$_}->();
}
PE_OK;
}
......@@ -202,7 +202,7 @@ sub setPersistentSessionInfo {
sub setLocalGroups {
my ( $self, $req ) = @_;
foreach ( sort keys %{ $self->_groups } ) {
if ( $self->_groups->{$_}->($req) ) {
if ( $self->_groups->{$_}->() ) {
$req->{sessionInfo}->{groups} .=
$self->conf->{multiValuesSeparator} . $_;
$req->{sessionInfo}->{hGroups}->{$_}->{name} = $_;
......
Markdown is supported
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