X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Famcryptsimple.pl;h=e8d492280dcb037ca5477cc15a237d7661b32575;hb=3c4bb2012986d596b3ee0e65fac4b2c5b7b01540;hp=05e50e55ebf17e48d2678bb71dd016386ff3cf3e;hpb=94a044f90357edefa6f4ae9f0b1d5885b0e34aee;p=debian%2Famanda diff --git a/common-src/amcryptsimple.pl b/common-src/amcryptsimple.pl index 05e50e5..e8d4922 100755 --- a/common-src/amcryptsimple.pl +++ b/common-src/amcryptsimple.pl @@ -1,6 +1,6 @@ #!@PERL@ -w # -# Copyright (c) 2006 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2007,2008 Zmanda, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as published @@ -15,8 +15,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120 -# Sunnyvale, CA 94085, USA, or: http://www.zmanda.com +# Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 +# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com # @@ -53,13 +53,43 @@ $ENV{'PATH'} = '/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:/opt/csw/bin'; $ENV{'GNUPGHOME'} = "$AMANDA_HOME/.gnupg"; +sub do_gpg_agent() { + my $path=`which gpg-agent 2>/dev/null`; + chomp $path; + if (-x $path) { + return "gpg-agent --daemon --"; + } + return "" +} sub encrypt() { - system "gpg --batch --no-secmem-warning --disable-mdc --symmetric --cipher-algo AES256 --passphrase-fd 3 3<$AM_PASS"; + my $gpg_agent_cmd = do_gpg_agent(); + system "$gpg_agent_cmd gpg --batch --no-secmem-warning --disable-mdc --symmetric --cipher-algo AES256 --passphrase-fd 3 3<$AM_PASS"; + if ($? == -1) { + print STDERR "failed to execute gpg: $!\n"; + exit (1); + } elsif ($? & 127) { + printf STDERR "gpg died with signal %d\n", ($? & 127); + exit ($?); + } elsif ($? >> 8) { + printf STDERR "gpg exited with value %d\n", ($? >> 8); + exit ($? >> 8); + } } sub decrypt() { - system "gpg --batch --quiet --no-mdc-warning --decrypt --passphrase-fd 3 3<$AM_PASS"; + my $gpg_agent_cmd = do_gpg_agent(); + system "$gpg_agent_cmd gpg --batch --quiet --no-mdc-warning --decrypt --passphrase-fd 3 3<$AM_PASS"; + if ($? == -1) { + print STDERR "failed to execute gpg: $!\n"; + exit (1); + } elsif ($? & 127) { + printf STDERR "gpg died with signal %d\n", ($? & 127); + exit ($?); + } elsif ($? >> 8) { + printf STDERR "gpg exited with value %d\n", ($? >> 8); + exit ($? >> 8); + } } sub int_catcher {