From: Peter Palfrader Date: Sat, 5 Dec 2009 01:02:28 +0000 (+0100) Subject: Try to handle the case where we cannot exec gnupg X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0305cd36f9fc9412c8a1505f0889279eb2c65e7;p=pwstore Try to handle the case where we cannot exec gnupg --- diff --git a/pws b/pws index c7d740c..4a3b0ad 100755 --- 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