summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Zangerl <az@snafu.priv.at>2012-09-04 10:27:32 +0000
committerAlexander Zangerl <az@snafu.priv.at>2012-09-04 10:27:32 +0000
commit903df9544dabd9ffeb4423448e790bc47a53f03b (patch)
treed8d03d76d664594461fb041069ce55d99a95cf8b
parent6c8307eadfa2f20564041048aa5e3e5bb2eb9d0d (diff)
downloadkuvert-903df9544dabd9ffeb4423448e790bc47a53f03b.tar.gz
kuvert-903df9544dabd9ffeb4423448e790bc47a53f03b.tar.bz2
kuvert-903df9544dabd9ffeb4423448e790bc47a53f03b.tar.xz
kuvert-903df9544dabd9ffeb4423448e790bc47a53f03b.zip
added 600s timeout for gpg invocations
-rwxr-xr-xkuvert24
1 files changed, 19 insertions, 5 deletions
diff --git a/kuvert b/kuvert
index 4b8d376..9e69d5c 100755
--- a/kuvert
+++ b/kuvert
@@ -19,7 +19,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-# $Id: kuvert,v 2.25 2010/09/16 05:17:22 az Exp az $
+# $Id: kuvert,v 2.26 2012/02/21 02:19:28 az Exp az $
#--
use strict;
@@ -51,6 +51,8 @@ my($username,$home)=(getpwuid($<))[0,7];
# where is the configuration file
my $rcfile="$home/.kuvert";
+my $timeout=600; # seconds to wait for gpg
+
# configuration directives
my (%config,$debug,%email2key);
@@ -1275,10 +1277,22 @@ sub sign_encrypt
bailout("exec gpg failed: $!\n");
}
}
- # outermost parent: read gpg status info
- my @output=<F>;
- close(F);
- if ($?)
+ # outermost parent: read gpg status info
+ my @output;
+ eval {
+ local $SIG{ALRM}=sub { die "alarm\n"; };
+ alarm $timeout;
+ @output=<F>;
+ alarm 0;
+ close(F);
+ };
+ if ($@)
+ {
+ logit("gpg timeout!");
+ kill("TERM",$pid);
+ return 1;
+ }
+ elsif ($?)
{
# no complaints if gpg just dislikes the passphrase
return 1