X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Famcryptsimple.pl;fp=common-src%2Famcryptsimple.pl;h=dd8760f91d0e0461dbce95e305c0224706201f03;hb=949b8910a5e23c4285d0b1aedacfc82a14dc97a5;hp=e8d492280dcb037ca5477cc15a237d7661b32575;hpb=c6f0a88c567f8536c498f554285aed1f8150da18;p=debian%2Famanda diff --git a/common-src/amcryptsimple.pl b/common-src/amcryptsimple.pl index e8d4922..dd8760f 100755 --- a/common-src/amcryptsimple.pl +++ b/common-src/amcryptsimple.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 @@ -62,9 +62,22 @@ sub do_gpg_agent() { 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() { 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"; + my $gpg = which_gpg(); + 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); @@ -79,7 +92,8 @@ sub encrypt() { sub decrypt() { my $gpg_agent_cmd = do_gpg_agent(); - system "$gpg_agent_cmd gpg --batch --quiet --no-mdc-warning --decrypt --passphrase-fd 3 3<$AM_PASS"; + my $gpg = which_gpg(); + 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);