X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Famgpgcrypt.pl;fp=common-src%2Famgpgcrypt.pl;h=50db13a22b9d92bfbc59fd27a4fe6c91a3631f50;hb=949b8910a5e23c4285d0b1aedacfc82a14dc97a5;hp=2a0c2ebf1223f0c4e92999a5f10d0f4916c23635;hpb=c6f0a88c567f8536c498f554285aed1f8150da18;p=debian%2Famanda diff --git a/common-src/amgpgcrypt.pl b/common-src/amgpgcrypt.pl index 2a0c2eb..50db13a 100755 --- a/common-src/amgpgcrypt.pl +++ b/common-src/amgpgcrypt.pl @@ -1,6 +1,6 @@ #!@PERL@ -w # -# Copyright (c) 2007,2008 Zmanda, Inc. All Rights Reserved. +# Copyright (c) 2007-2012 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 @@ -46,13 +46,37 @@ $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 which_gpg() { + my $path=`which gpg2 2>/dev/null`; + if (!$path) { + $path=`which gpg 2>/dev/null`; + } + if (!$path) { + die("no gpg or gpg2"); + } + chomp $path; + return $path; +} + sub encrypt() { -# system "gpg --armor --encrypt --recipient $AMANDA"; - system "gpg --batch --disable-mdc --encrypt --cipher-algo AES256 --recipient $AMANDA"; + my $gpg_agent_cmd = do_gpg_agent(); + my $gpg = which_gpg(); + system "$gpg_agent_cmd $gpg --batch --disable-mdc --encrypt --cipher-algo AES256 --recipient $AMANDA"; } sub decrypt() { - system "gpg --batch --quiet --no-mdc-warning --secret-keyring $AM_PRIV --decrypt --passphrase-fd 3 3<$AM_PASS"; + my $gpg_agent_cmd = do_gpg_agent(); + my $gpg = which_gpg(); + system "$gpg_agent_cmd $gpg --batch --quiet --no-mdc-warning --secret-keyring $AM_PRIV --decrypt --passphrase-fd 3 3<$AM_PASS"; } sub my_sig_catcher {