Merge lp:~mwilck/duplicity/duplicity into lp:~duplicity-team/duplicity/0.8-series

Proposed by Martin Wilck
Status: Merged
Merged at revision: 1150
Proposed branch: lp:~mwilck/duplicity/duplicity
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 58 lines (+27/-3)
2 files modified
bin/duplicity.1 (+9/-3)
duplicity/gpg.py (+18/-0)
To merge this branch: bzr merge lp:~mwilck/duplicity/duplicity
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+306331@code.launchpad.net

Description of the change

GPG: enable truly non-interactive operation with gpg2

This patch fixes the IMO unexpected behavior that, when using GnuPG2, a pass phrase dialog always pops up for saving backups. This is particularly annoying when trying to do unattended / fully automatic backups.

The patch changes the behavior of the "--use-agent" option when GnuPG 2 is in use. The man page is updated accordingly.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/duplicity.1'
--- bin/duplicity.1 2016-08-22 10:58:28 +0000
+++ bin/duplicity.1 2016-09-21 13:03:22 +0000
@@ -917,9 +917,15 @@
917if needed.917if needed.
918.br918.br
919.B Note:919.B Note:
920GnuPG 2 and newer ignore this option and will always use a running920Contrary to previous versions of duplicity, this option will also be honored
921.B gpg-agent921by GnuPG 2 and newer versions. If GnuPG 2 is in use, duplicity passes the option
922if no passphrase was delivered.922.I --pinentry-mode=cancel
923to the the gpg process unless
924.I --use-agent
925is specified on the duplicity command line. This has the effect that GnuPG 2
926uses the agent only if
927.I --use-agent
928is given, just like GnuPG 1.
923929
924.TP930.TP
925.BI "--verbosity " level ", -v" level931.BI "--verbosity " level ", -v" level
926932
=== modified file 'duplicity/gpg.py'
--- duplicity/gpg.py 2015-11-05 15:36:58 +0000
+++ duplicity/gpg.py 2016-09-21 13:03:22 +0000
@@ -87,6 +87,20 @@
87 else:87 else:
88 self.hidden_recipients = []88 self.hidden_recipients = []
8989
90 self.gpg_major = self.get_gpg_major(globals.gpg_binary)
91
92 _version_re = re.compile(r'^gpg.*\(GnuPG\) (?P<maj>[0-9])\.[0-9]+\.[0-9]+$')
93
94 def get_gpg_major(self, binary):
95 gpg = gpginterface.GnuPG()
96 if binary is not None:
97 gpg.call = binary
98 res = gpg.run(["--version"], create_fhs=["stdout"])
99 line = res.handles["stdout"].readline().rstrip()
100 mtc = self._version_re.search(line)
101 if mtc is not None:
102 return int(mtc.group("maj"), 10)
103 raise GPGError("failed to determine gpg version of %s from %s" % (binary, line))
90104
91class GPGFile:105class GPGFile:
92 """106 """
@@ -121,6 +135,10 @@
121 gnupg.options.extra_args.append('--no-secmem-warning')135 gnupg.options.extra_args.append('--no-secmem-warning')
122 if globals.use_agent:136 if globals.use_agent:
123 gnupg.options.extra_args.append('--use-agent')137 gnupg.options.extra_args.append('--use-agent')
138 elif profile.gpg_major == 2:
139 # This forces gpg2 to ignore the agent.
140 # Necessary to enforce truly non-interactive operation.
141 gnupg.options.extra_args.append('--pinentry-mode=cancel')
124 if globals.gpg_options:142 if globals.gpg_options:
125 for opt in globals.gpg_options.split():143 for opt in globals.gpg_options.split():
126 gnupg.options.extra_args.append(opt)144 gnupg.options.extra_args.append(opt)

Subscribers

People subscribed via source and target branches