← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~mterry/duplicity/946988 into lp:duplicity

 

Michael Terry has proposed merging lp:~mterry/duplicity/946988 into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)
Related bugs:
  Bug #946988 in Duplicity: "GnuPG passphrase error after failed backup session"
  https://bugs.launchpad.net/duplicity/+bug/946988

For more details, see:
https://code.launchpad.net/~mterry/duplicity/946988/+merge/134214

This fixes bug 946988 by not duplicating the checks for when we should ask for the password (those same checks are done more correctly inside get_passphrase).  And add a test to reproduce the bug.
-- 
https://code.launchpad.net/~mterry/duplicity/946988/+merge/134214
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/946988 into lp:duplicity.
=== modified file 'bin/duplicity'
--- bin/duplicity	2012-09-29 19:45:14 +0000
+++ bin/duplicity	2012-11-13 21:56:22 +0000
@@ -1321,10 +1321,8 @@
 
     os.umask(077)
 
-    # full/inc only needs a passphrase for symmetric keys
-    if not action in ["full", "inc"] or not globals.gpg_profile.recipients:
-        # get the passphrase if we need to based on action/options
-        globals.gpg_profile.passphrase = get_passphrase(1, action)
+    # get the passphrase if we need to based on action/options
+    globals.gpg_profile.passphrase = get_passphrase(1, action)
 
     if action == "restore":
         restore(col_stats)

=== modified file 'testing/tests/restarttest.py'
--- testing/tests/restarttest.py	2012-10-02 22:18:43 +0000
+++ testing/tests/restarttest.py	2012-11-13 21:56:22 +0000
@@ -70,17 +70,21 @@
         Run duplicity binary with given arguments and options
         """
         options.append("--archive-dir testfiles/cache")
-        cmd_list = ["duplicity"]
+        # We run under setsid and take input from /dev/null (below) because
+        # this way we force a failure if duplicity tries to read from the
+        # console (like for gpg password or such).
+        cmd_list = ["setsid", "duplicity"]
         cmd_list.extend(options + ["--allow-source-mismatch"])
         if current_time:
             cmd_list.append("--current-time %s" % (current_time,))
         if other_args:
             cmd_list.extend(other_args)
         cmd_list.extend(arglist)
+        cmd_list.extend(["<", "/dev/null"])
         cmdline = " ".join(cmd_list)
         #print "Running '%s'." % cmdline
-        if not os.environ.has_key('PASSPHRASE'):
-            os.environ['PASSPHRASE'] = 'foobar'
+        helper.set_environ('PASSPHRASE', helper.sign_passphrase)
+        self.addCleanup(lambda: helper.set_environ("PASSPHRASE", None))
 #        print "CMD: %s" % cmdline
         return_val = os.system(cmdline)
         if return_val:
@@ -232,6 +236,23 @@
         self.backup("full", "testfiles/largefiles", options = ["--vol 1"])
         self.verify("testfiles/largefiles")
 
+    def test_restart_sign_and_encrypt(self):
+        """
+        Test restarting a backup using same key for sign and encrypt
+        https://bugs.launchpad.net/duplicity/+bug/946988
+        """
+        self.make_largefiles()
+        enc_opts = ["--sign-key " + helper.sign_key, "--encrypt-key " + helper.sign_key]
+        # Force a failure partway through
+        try:
+            self.backup("full", "testfiles/largefiles", options = ["--vols 1", "--fail 2"] + enc_opts)
+            self.fail()
+        except CmdError, e:
+            self.assertEqual(30, e.exit_status)
+        # Now finish that backup
+        self.backup("full", "testfiles/largefiles", options = enc_opts)
+        self.verify("testfiles/largefiles")
+
     def test_last_file_missing_in_middle(self):
         """
         Test restart when the last file being backed up is missing on restart.


Follow ups