# HG changeset patch # User Heiko Schlittermann # Date 1293551336 -3600 # Node ID 22a94a179106f9947fbdef84875a87e26f13b82c # Parent 92120bd108c9c7a49102b5d70cfda00c86685344# Parent cfc3c458bef28537e76a7b27da282a5be3ef9d20 merged diff -r cfc3c458bef2 -r 22a94a179106 check_exec.pl --- a/check_exec.pl Tue Dec 28 16:47:32 2010 +0100 +++ b/check_exec.pl Tue Dec 28 16:48:56 2010 +0100 @@ -36,7 +36,7 @@ my $VERSION = "0.3"; sub download($$); -sub verify($); +sub verify($$); sub cleanup($); sub execute($); sub version($$); @@ -60,8 +60,9 @@ $opt->{url} // pod2usage(-verbose => 1, -exitval => $ERRORS{CRITICAL}); - my $file = download($opt->{url}, $opt->{path}); - my $run_file = verify($file); + my $tmp = File::Temp->new(); + my $file = download($opt->{url}, $opt->{path}); + my $run_file = verify($file => $tmp); warn "<< $run_file >>\n"; die `cat $run_file`; @@ -101,37 +102,37 @@ mkpath($path, { mode => 0700, error => \my $err }); for my $diag (@$err) { my ($directory, $message) = %$diag; - print "EXEC CRITICAL: Can't create directory $directory: $message\n"; + print + "EXEC CRITICAL: Can't create directory $directory: $message\n"; } - exit $ERRORS{CRITICAL} if defined $err; + exit $ERRORS{CRITICAL} if defined $err; } $file = "$path/$file"; my $rc = getstore($url, $file); if (is_error($rc)) { - unlink $file; + unlink $file; if ($rc == 404) { print "EXEC OK: $url ", status_message($rc), "\n"; exit $ERRORS{OK}; - } + } - print "EXEC CRITICAL: $url ", status_message($rc), "\n"; - exit $ERRORS{CRITICAL}; + print "EXEC CRITICAL: $url ", status_message($rc), "\n"; + exit $ERRORS{CRITICAL}; } return $file; } -sub verify($) { - my $file = shift; +sub verify($$) { + my ($file, $tmp) = @_; my $dir = dirname($file); - my $tmp = File::Temp->new(); my $home_dir = (getpwuid($>))[7]; - - my $dc = "$opt->{binary} --output @{[$tmp->filename]} --homedir $home_dir/.gnupg --batch --yes"; + my $dc = + "$opt->{binary} --output $tmp --homedir $home_dir/.gnupg --batch --yes"; my @r = qx($dc $file 2>&1); if ($?) { print "EXEC CRITICAL: @r";