check_exec.pl
changeset 11 92120bd108c9
parent 9 69c1005df8ce
child 14 a74319812ee1
--- a/check_exec.pl	Tue Dec 28 16:38:55 2010 +0100
+++ b/check_exec.pl	Tue Dec 28 16:48:21 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";