Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[munin-run] cleanup #1061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 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 @@ -53,18 +52,17 @@ 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,
%{$config}, ## no critic qw(ValuesAndExpressions::ProhibitCommaSeparatedStatements)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wild guessing: is this expression supposed to merge the config hash together with the additional hash value and supply this new hash as an argument to the reinitialize method?
Maybe there is a better way to achieve this without overriding the policy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be better, but I did not yet find a way, input welcome.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a temporary var is always possible, and usually even preferred

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgzones: would you try to work around this (by using a separate variable?) one in order to save the warning override?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see a way to use a temporary variable :-(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steveschnepp: I think, it is time to prove your a temporary var is always possible claim :)

paranoia => $paranoia,
});

Expand Down Expand Up @@ -109,21 +107,24 @@ 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