From bfa431576ccd54eb6d137a5743699a1700eea6b8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 21 Nov 2008 05:48:13 +0000 Subject: fix/document issues noted by arma in todo. git-svn-id: file:///home/or/svnrepo/updater/trunk@17350 55e972cd-5a19-0410-ae62-a4d7a52db4cd --- lib/thandy/SignerCLI.py | 5 ++++- lib/thandy/formats.py | 3 +++ lib/thandy/keys.py | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/thandy/SignerCLI.py b/lib/thandy/SignerCLI.py index 55adb41..476e7d5 100644 --- a/lib/thandy/SignerCLI.py +++ b/lib/thandy/SignerCLI.py @@ -305,7 +305,10 @@ def main(): if cmd in [ "keygen", "listkeys", "addrole", "delrole", "chpass", "dumpkey", "makepackage", "makebundle", "signkeylist", "makekeylist", "signkeylist", "makemirrorlist", ]: - globals()[cmd](args) + try: + globals()[cmd](args) + except thandy.BadPassword: + print >>sys.stderr, "Password incorrect." else: usage() diff --git a/lib/thandy/formats.py b/lib/thandy/formats.py index 8a27a65..cf9ff1f 100644 --- a/lib/thandy/formats.py +++ b/lib/thandy/formats.py @@ -790,6 +790,9 @@ def makeKeylistObj(keylist_fname, includePrivate=False): klist = [] for k in keys: k = thandy.keys.RSAKey.fromJSon(k) + if includePrivate and not k.isPrivateKey(): + raise thandy.FormatException("Private key information not found.") + klist.append({'key': k.format(private=includePrivate), 'roles' : k.getRoles() }) result = { '_type' : "Keylist", diff --git a/lib/thandy/keys.py b/lib/thandy/keys.py index 5442b26..a243fa7 100644 --- a/lib/thandy/keys.py +++ b/lib/thandy/keys.py @@ -47,7 +47,8 @@ class PublicKey: paths. """ assert role in thandy.formats.ALL_ROLES - self._roles.append((role, path)) + if (role, path) not in self._roles: + self._roles.append((role, path)) def clearRoles(self): """Remove all roles from this key.""" del self._roles[:] -- cgit v1.2.3