#!@PERL@ -w
#
-# Copyright (c) 2006 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
# 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
#
# Amanda has problem with gpg mdc(modification detection code) in the binary mode.
$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 {