Merge lp:~mfisch/sync.links/gpg-error-check into lp:sync.links

Proposed by Matt Fischer
Status: Merged
Merged at revision: 2
Proposed branch: lp:~mfisch/sync.links/gpg-error-check
Merge into: lp:sync.links
Diff against target: 17 lines (+6/-1)
1 file modified
put.py (+6/-1)
To merge this branch: bzr merge lp:~mfisch/sync.links/gpg-error-check
Reviewer Review Type Date Requested Status
Alex Chiang Approve
Review via email: mp+89374@code.launchpad.net

Description of the change

Adds some error checking to the gpg call. This will catch issues when you enter a bad password.

To post a comment you must log in.
Revision history for this message
Alex Chiang (achiang) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'put.py'
2--- put.py 2012-01-17 05:47:23 +0000
3+++ put.py 2012-01-20 03:05:24 +0000
4@@ -51,7 +51,12 @@
5 abspath = os.path.abspath(tmp)
6 os.system("cp '%s' '%s'" % ('/'.join([dotdir_abspath, secure_tgz_gpg]), tmp))
7 os.chdir(tmp)
8- os.system("gpg %s" % secure_tgz_gpg)
9+ status = os.system("gpg %s" % secure_tgz_gpg)
10+ retval = ((status >> 8) & 0xFF)
11+ if retval != 0 or not os.path.exists(secure_tgz):
12+ print "Failed to decrypt secure dotfiles, probably a bad password"
13+ sys.exit(1)
14+
15 os.system("tar xf %s" % secure_tgz)
16 os.unlink(secure_tgz)
17 os.unlink(secure_tgz_gpg)

Subscribers

People subscribed via source and target branches

to all changes: