X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Famcryptsimple.pl;h=e8d492280dcb037ca5477cc15a237d7661b32575;hb=refs%2Ftags%2Fupstream%2F3.3.1;hp=cf5306bf2b3698fc7784246c7005892bc9d049ae;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/common-src/amcryptsimple.pl b/common-src/amcryptsimple.pl index cf5306b..e8d4922 100755 --- a/common-src/amcryptsimple.pl +++ b/common-src/amcryptsimple.pl @@ -53,9 +53,18 @@ $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); @@ -69,7 +78,8 @@ sub encrypt() { } 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);