]> err.no Git - pwstore/commitdiff
Try to handle the case where we cannot exec gnupg
authorPeter Palfrader <peter@palfrader.org>
Sat, 5 Dec 2009 01:02:28 +0000 (02:02 +0100)
committerPeter Palfrader <peter@palfrader.org>
Sat, 5 Dec 2009 01:02:28 +0000 (02:02 +0100)
pws

diff --git a/pws b/pws
index c7d740c40f5b95597253eb7d97dd75344ead873e..4a3b0ad0901c0e5e705e6e2348ae779fc919a649 100755 (executable)
--- a/pws
+++ b/pws
@@ -90,7 +90,12 @@ class GnuPG
       STDIN.reopen(inR)
       STDOUT.reopen(outW)
       STDERR.reopen(errW)
-      exec(GNUPG, "--status-fd=#{statW.fileno}",  *args)
+      begin
+        exec(GNUPG, "--status-fd=#{statW.fileno}",  *args)
+      rescue Exception => e
+        outW.puts("[PWSEXECERROR]: #{e}")
+        exit(1)
+      end
       raise ("Calling gnupg failed")
     end
     inR.close
@@ -102,6 +107,10 @@ class GnuPG
     throw "Unexpected pid: #{pid} vs #{wpid}" unless pid == wpid
     throw "Process has not exited!?" unless status.exited?
     throw "gpg call did not exit sucessfully" if (require_success and status.exitstatus != 0)
+    if m=/^\[PWSEXECERROR\]: (.*)/.match(outtxt) then
+      STDERR.puts "Could not run GnuPG: #{m[1]}"
+      exit(1)
+    end
     return outtxt, stderrtxt, statustxt, status.exitstatus
   end