]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pakfire/patches/0015-Add-option-to-export-secret-keys.patch
0934ab1b581b7f7156014a3762d5fda37b83c25f
[people/ms/ipfire-3.x.git] / pakfire / patches / 0015-Add-option-to-export-secret-keys.patch
1 From a78770d3e74e29522a0a29f04ba2757fc8f8704d Mon Sep 17 00:00:00 2001
2 From: Michael Tremer <michael.tremer@ipfire.org>
3 Date: Sat, 30 Jun 2012 12:20:41 +0200
4 Subject: [PATCH 15/16] Add option to export secret keys.
5
6 ---
7 python/pakfire/api.py | 4 ++--
8 python/pakfire/cli.py | 5 ++++-
9 python/pakfire/keyring.py | 4 ++--
10 3 files changed, 8 insertions(+), 5 deletions(-)
11
12 diff --git a/python/pakfire/api.py b/python/pakfire/api.py
13 index 5203c5f..372e4d5 100644
14 --- a/python/pakfire/api.py
15 +++ b/python/pakfire/api.py
16 @@ -145,10 +145,10 @@ def key_import(keyfile, **pakfire_args):
17
18 return pakfire.keyring.import_key(keyfile)
19
20 -def key_export(keyid, keyfile, **pakfire_args):
21 +def key_export(keyid, keyfile, secret=False, **pakfire_args):
22 pakfire = Pakfire(**pakfire_args)
23
24 - return pakfire.keyring.export_key(keyid, keyfile)
25 + return pakfire.keyring.export_key(keyid, keyfile, secret=secret)
26
27 def key_delete(keyid, **pakfire_args):
28 pakfire = Pakfire(**pakfire_args)
29 diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py
30 index 05a8c6e..a808975 100644
31 --- a/python/pakfire/cli.py
32 +++ b/python/pakfire/cli.py
33 @@ -1220,6 +1220,8 @@ class CliKey(Cli):
34 help=_("The ID of the key to export."))
35 sub_export.add_argument("filename", nargs=1,
36 help=_("Write the key to this file."))
37 + sub_export.add_argument("--secret", action="store_true",
38 + help=_("Export the secret key, too."))
39 sub_export.add_argument("action", action="store_const", const="export")
40
41 def parse_command_delete(self):
42 @@ -1275,8 +1277,9 @@ class CliKey(Cli):
43 def handle_export(self):
44 keyid = self.args.keyid[0]
45 filename = self.args.filename[0]
46 + secret = self.args.secret
47
48 - pakfire.key_export(keyid, filename, **self.pakfire_args)
49 + pakfire.key_export(keyid, filename, secret=secret, **self.pakfire_args)
50
51 def handle_delete(self):
52 keyid = self.args.keyid[0]
53 diff --git a/python/pakfire/keyring.py b/python/pakfire/keyring.py
54 index 8fe052e..d1f4626 100644
55 --- a/python/pakfire/keyring.py
56 +++ b/python/pakfire/keyring.py
57 @@ -168,9 +168,9 @@ class Keyring(object):
58
59 log.info(_("Successfully imported %s.") % keyfile)
60
61 - def export_key(self, keyid, keyfile):
62 + def export_key(self, keyid, keyfile, secret=False):
63 keydata = io.BytesIO()
64 - self.ctx.export(keyid, keydata)
65 + self.ctx.export(keyid, keydata, secret)
66
67 f = open(keyfile, "wb")
68 f.write(keydata.getvalue())
69 --
70 1.7.10.4
71