Skip to content

Commit

Permalink
[munin-run] cleanup and fix perlcritic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Aug 27, 2018
1 parent 147e83b commit b700f18
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions script/munin-run
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use Munin::Node::Service;

use English qw(-no_match_vars);

my $services;
my $servicedir;
my $conffile = "$Munin::Common::Defaults::MUNIN_CONFDIR/munin-node.conf";
my $DEBUG = 0;
Expand All @@ -52,18 +51,18 @@ sub main {
# @ARGV, the latter takes precedence.
$paranoia = $config->{paranoia};

my $config = Munin::Node::Config->instance();
$config->parse_config_from_file($conffile);

$services = Munin::Node::Service->new(
my $services = Munin::Node::Service->new(
servicedir => $servicedir,
defuser => $config->{defuser},
defgroup => $config->{defgroup},
pidebug => $PIDEBUG,
);

$config->reinitialize( {
%$config, paranoia => $paranoia,
%{$config}, ## no critic qw(ValuesAndExpressions::ProhibitCommaSeparatedStatements)
paranoia => $paranoia,
} );

unless ( $services->is_a_runnable_service($plugin) ) {
Expand Down Expand Up @@ -108,21 +107,25 @@ sub parse_args {
print_usage_and_exit() unless $ARGV[0];

# Detaint the plugin name
($plugin) = ( $ARGV[0] =~ m/^([-\w.:]+)$/ ) or die "# ERROR: Invalid plugin name '$ARGV[0].\n";
($plugin) = ( $ARGV[0] =~ m/^([-\w.:]+)$/x )
or die "# ERROR: Invalid plugin name '$ARGV[0]'.\n";
if ( $ARGV[1] ) {
($arg) = ( $ARGV[1] =~ m/^(\w+)$/ )
($arg) = ( $ARGV[1] =~ m/^(\w+)$/x )
or die "# ERROR: Invalid characters in argument '$ARGV[1]'.\n";
die "# ERROR: Invalid plugin argument '$ARGV[1]'.\n"
unless grep( /^$ARGV[1]$/x, qw(autoconf config suggest) );
}

# Detaint service directory. FIXME: do more strict detainting?
# Detaint service directory.
if ($servicedir) {
$servicedir =~ /(.*)/;
$servicedir = $1;
die "# ERROR: Invalid servicedir supplied.\n" unless -d $servicedir;
$servicedir =~ /(.*)/x;
$servicedir = $1; ## no critic qw(RegularExpressions::ProhibitCaptureWithoutTest)
}

# Update the config
$config->reinitialize( {
%$config,
%{$config}, ## no critic qw(ValuesAndExpressions::ProhibitCommaSeparatedStatements)

sconfdir => $sconfdir,
conffile => $conffile,
Expand Down

0 comments on commit b700f18

Please sign in to comment.