2012-05-30 Ramon Novoa <rnovoa@artica.es>
* pandora_agent: Merged from 4.0 branch. Check for valid regular expressions before adding module conditions. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6373 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
77771b13ec
commit
6cfbb4205a
|
@ -1,3 +1,8 @@
|
||||||
|
2012-05-30 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* pandora_agent: Merged from 4.0 branch. Check for valid regular
|
||||||
|
expressions before adding module conditions.
|
||||||
|
|
||||||
2012-04-25 Miguel de Dios <miguel.dedios@artica.es>
|
2012-04-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* DEBIAN/postinst, DEBIAN/make_deb_package.sh: disabled the checking
|
* DEBIAN/postinst, DEBIAN/make_deb_package.sh: disabled the checking
|
||||||
|
|
|
@ -231,6 +231,22 @@ sub error ($) {
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Check a regular expression. Returns 1 if its valid, 0 otherwise.
|
||||||
|
################################################################################
|
||||||
|
sub valid_regexp ($) {
|
||||||
|
my $regexp = shift;
|
||||||
|
|
||||||
|
eval {
|
||||||
|
'' =~ /$regexp/;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Something went wrong
|
||||||
|
return 0 if ($@);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Recursively delete files and directories.
|
# Recursively delete files and directories.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -375,7 +391,11 @@ sub parse_conf_modules($) {
|
||||||
push (@{$module->{'precondition'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2, 'command' => $3});
|
push (@{$module->{'precondition'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2, 'command' => $3});
|
||||||
# Regular expression
|
# Regular expression
|
||||||
} elsif ($action =~ /^\s*=~\s+(\S*)\s+(.*)$/) {
|
} elsif ($action =~ /^\s*=~\s+(\S*)\s+(.*)$/) {
|
||||||
push (@{$module->{'precondition'}}, {'operator' => '=~', 'value_1' => $1, 'command' => $2});
|
if (valid_regexp ($1)) {
|
||||||
|
push (@{$module->{'precondition'}}, {'operator' => '=~', 'value_1' => $1, 'command' => $2});
|
||||||
|
} else {
|
||||||
|
log_message ('setup', "Invalid regular expression in module precondition: $line");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elsif ($line =~ /^\s*module_exec\s+(.+)$/) {
|
} elsif ($line =~ /^\s*module_exec\s+(.+)$/) {
|
||||||
$module->{'func'} = \&module_exec;
|
$module->{'func'} = \&module_exec;
|
||||||
|
@ -429,7 +449,11 @@ sub parse_conf_modules($) {
|
||||||
push (@{$module->{'conditions'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2, 'command' => $3});
|
push (@{$module->{'conditions'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2, 'command' => $3});
|
||||||
# Regular expression
|
# Regular expression
|
||||||
} elsif ($action =~ /^\s*=~\s+(\S*)\s+(.*)$/) {
|
} elsif ($action =~ /^\s*=~\s+(\S*)\s+(.*)$/) {
|
||||||
push (@{$module->{'conditions'}}, {'operator' => '=~', 'value_1' => $1, 'command' => $2});
|
if (valid_regexp ($1)) {
|
||||||
|
push (@{$module->{'conditions'}}, {'operator' => '=~', 'value_1' => $1, 'command' => $2});
|
||||||
|
} else {
|
||||||
|
log_message ('setup', "Invalid regular expression in module condition: $line");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elsif ($line =~ /^\s*module_intensive_condition\s+(.*)$/) {
|
} elsif ($line =~ /^\s*module_intensive_condition\s+(.*)$/) {
|
||||||
my $action = $1;
|
my $action = $1;
|
||||||
|
@ -444,7 +468,11 @@ sub parse_conf_modules($) {
|
||||||
push (@{$module->{'intensive_conditions'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2});
|
push (@{$module->{'intensive_conditions'}}, {'operator' => '()', 'value_1' => $1, 'value_2' => $2});
|
||||||
# Regular expression
|
# Regular expression
|
||||||
} elsif ($action =~ /^\s*=~\s+(\S*)\s*$/) {
|
} elsif ($action =~ /^\s*=~\s+(\S*)\s*$/) {
|
||||||
push (@{$module->{'intensive_conditions'}}, {'operator' => '=~', 'value_1' => $1});
|
if (valid_regexp ($1)) {
|
||||||
|
push (@{$module->{'intensive_conditions'}}, {'operator' => '=~', 'value_1' => $1});
|
||||||
|
} else {
|
||||||
|
log_message ('setup', "Invalid regular expression in intensive condition: $line");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elsif ($line =~ /^\s*module_crontab\s+(((\*|(\d+(-\d+){0,1}))\s*){5}).*$/) {
|
} elsif ($line =~ /^\s*module_crontab\s+(((\*|(\d+(-\d+){0,1}))\s*){5}).*$/) {
|
||||||
$module->{'cron'} = $1;
|
$module->{'cron'} = $1;
|
||||||
|
|
Loading…
Reference in New Issue