Merge lp:~mterry/duplicity/946988 into lp:duplicity/0.6

Proposed by Michael Terry
Status: Merged
Merged at revision: 896
Proposed branch: lp:~mterry/duplicity/946988
Merge into: lp:duplicity/0.6
Diff against target: 69 lines (+26/-7)
2 files modified
bin/duplicity (+2/-4)
testing/tests/restarttest.py (+24/-3)
To merge this branch: bzr merge lp:~mterry/duplicity/946988
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+134214@code.launchpad.net

Description of the change

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.

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
1=== modified file 'bin/duplicity'
2--- bin/duplicity 2012-09-29 19:45:14 +0000
3+++ bin/duplicity 2012-11-13 21:56:22 +0000
4@@ -1321,10 +1321,8 @@
5
6 os.umask(077)
7
8- # full/inc only needs a passphrase for symmetric keys
9- if not action in ["full", "inc"] or not globals.gpg_profile.recipients:
10- # get the passphrase if we need to based on action/options
11- globals.gpg_profile.passphrase = get_passphrase(1, action)
12+ # get the passphrase if we need to based on action/options
13+ globals.gpg_profile.passphrase = get_passphrase(1, action)
14
15 if action == "restore":
16 restore(col_stats)
17
18=== modified file 'testing/tests/restarttest.py'
19--- testing/tests/restarttest.py 2012-10-02 22:18:43 +0000
20+++ testing/tests/restarttest.py 2012-11-13 21:56:22 +0000
21@@ -70,17 +70,21 @@
22 Run duplicity binary with given arguments and options
23 """
24 options.append("--archive-dir testfiles/cache")
25- cmd_list = ["duplicity"]
26+ # We run under setsid and take input from /dev/null (below) because
27+ # this way we force a failure if duplicity tries to read from the
28+ # console (like for gpg password or such).
29+ cmd_list = ["setsid", "duplicity"]
30 cmd_list.extend(options + ["--allow-source-mismatch"])
31 if current_time:
32 cmd_list.append("--current-time %s" % (current_time,))
33 if other_args:
34 cmd_list.extend(other_args)
35 cmd_list.extend(arglist)
36+ cmd_list.extend(["<", "/dev/null"])
37 cmdline = " ".join(cmd_list)
38 #print "Running '%s'." % cmdline
39- if not os.environ.has_key('PASSPHRASE'):
40- os.environ['PASSPHRASE'] = 'foobar'
41+ helper.set_environ('PASSPHRASE', helper.sign_passphrase)
42+ self.addCleanup(lambda: helper.set_environ("PASSPHRASE", None))
43 # print "CMD: %s" % cmdline
44 return_val = os.system(cmdline)
45 if return_val:
46@@ -232,6 +236,23 @@
47 self.backup("full", "testfiles/largefiles", options = ["--vol 1"])
48 self.verify("testfiles/largefiles")
49
50+ def test_restart_sign_and_encrypt(self):
51+ """
52+ Test restarting a backup using same key for sign and encrypt
53+ https://bugs.launchpad.net/duplicity/+bug/946988
54+ """
55+ self.make_largefiles()
56+ enc_opts = ["--sign-key " + helper.sign_key, "--encrypt-key " + helper.sign_key]
57+ # Force a failure partway through
58+ try:
59+ self.backup("full", "testfiles/largefiles", options = ["--vols 1", "--fail 2"] + enc_opts)
60+ self.fail()
61+ except CmdError, e:
62+ self.assertEqual(30, e.exit_status)
63+ # Now finish that backup
64+ self.backup("full", "testfiles/largefiles", options = enc_opts)
65+ self.verify("testfiles/largefiles")
66+
67 def test_last_file_missing_in_middle(self):
68 """
69 Test restart when the last file being backed up is missing on restart.

Subscribers

People subscribed via source and target branches

to all changes: