1 |
commit: dbd6861ec6e35b1ce8862303ca16021e86276a7d |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jul 17 01:52:30 2013 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Wed Jul 17 01:52:30 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=dbd6861e |
7 |
|
8 |
Change to make keys install to individual directories. |
9 |
|
10 |
Git has no options to set the git keydir or keyring. |
11 |
Must set GNUPGHOME env variable to the desired keydir before |
12 |
calling git log --show-signature to verify commits. |
13 |
|
14 |
--- |
15 |
gkeyldap/search.py | 6 +++--- |
16 |
gkeys/actions.py | 14 ++++++------- |
17 |
gkeys/cli.py | 10 ++++----- |
18 |
gkeys/config.py | 4 ++-- |
19 |
gkeys/lib.py | 60 +++++++++++++++++++++++++++++++----------------------- |
20 |
5 files changed, 51 insertions(+), 43 deletions(-) |
21 |
|
22 |
diff --git a/gkeyldap/search.py b/gkeyldap/search.py |
23 |
index f7d2045..92471df 100644 |
24 |
--- a/gkeyldap/search.py |
25 |
+++ b/gkeyldap/search.py |
26 |
@@ -21,9 +21,9 @@ gkey2ldap_map = { |
27 |
'name': 'cn', |
28 |
'keyid': 'gpgkey', |
29 |
'longkeyid': 'gpgkey', |
30 |
- # map the uid to keyring, since we want |
31 |
- # dev keyrings to be separate from each other |
32 |
- 'keyring': 'uid', |
33 |
+ # map the uid to keydir, since we want |
34 |
+ # dev keydir to be separate from each other |
35 |
+ 'keydir': 'uid', |
36 |
'fingerprint': 'gpgfingerprint' |
37 |
} |
38 |
# Sanity check they are in sync |
39 |
|
40 |
diff --git a/gkeys/actions.py b/gkeys/actions.py |
41 |
index 9873362..7efcd44 100644 |
42 |
--- a/gkeys/actions.py |
43 |
+++ b/gkeys/actions.py |
44 |
@@ -190,25 +190,25 @@ class Actions(object): |
45 |
#failed = [] |
46 |
print(" GPG output:") |
47 |
for key in keyresults: |
48 |
- if not key.keyring and not args.nick == '*': |
49 |
- self.logger.debug("ACTIONS: listkey; NO keyring... Ignoring") |
50 |
+ if not key.keydir and not args.nick == '*': |
51 |
+ self.logger.debug("ACTIONS: listkey; NO keydir... Ignoring") |
52 |
return {"Failed: No keyid's found for %s" % key.name : ''} |
53 |
- self.logger.debug("ACTIONS: listkey; listing keyring:" |
54 |
- + str(key.keyring)) |
55 |
- results[key.name] = self.gpg.list_keys(key.keyring) |
56 |
+ self.logger.debug("ACTIONS: listkey; listing keydir:" |
57 |
+ + str(key.keydir)) |
58 |
+ results[key.name] = self.gpg.list_keys(key.keydir) |
59 |
if self.config.options['print_results']: |
60 |
print(results[key.name].output) |
61 |
self.logger.debug("data output:\n" + |
62 |
str(results[key.name].output)) |
63 |
#for result in results[key.name].status.data: |
64 |
- #print("key desired:", key.name, ", keyring listed:", |
65 |
+ #print("key desired:", key.name, ", keydir listed:", |
66 |
#result) |
67 |
#self.logger.debug("data record: " + str(result)) |
68 |
else: |
69 |
return results |
70 |
return {'done': True} |
71 |
else: |
72 |
- return {"No keyrings to list": False} |
73 |
+ return {"No keydirs to list": False} |
74 |
|
75 |
|
76 |
def addkey(self, args): |
77 |
|
78 |
diff --git a/gkeys/cli.py b/gkeys/cli.py |
79 |
index d34ed4d..46344f9 100644 |
80 |
--- a/gkeys/cli.py |
81 |
+++ b/gkeys/cli.py |
82 |
@@ -67,12 +67,12 @@ class Main(object): |
83 |
be hazardous to your system!''') |
84 |
# actions |
85 |
parser.add_argument('action', choices=actions, nargs='?', |
86 |
- default='listseeds', help='Add to seed file or keyring') |
87 |
+ default='listseeds', help='List the seeds in the file') |
88 |
# options |
89 |
parser.add_argument('-c', '--config', dest='config', default=None, |
90 |
help='The path to an alternate config file') |
91 |
parser.add_argument('-d', '--dest', dest='destination', default=None, |
92 |
- help='The destination seed file or keyring for move, copy operations') |
93 |
+ help='The destination seed file or keydir for move, copy operations') |
94 |
parser.add_argument('-f', '--fingerprint', dest='fingerprint', default=None, |
95 |
help='The fingerprint of the the key') |
96 |
parser.add_argument('-N', '--name', dest='name', default=None, |
97 |
@@ -83,9 +83,9 @@ class Main(object): |
98 |
help='The keyid of the the key') |
99 |
parser.add_argument('-l', '--longkeyid', dest='longkeyid', default=None, |
100 |
help='The longkeyid of the the key') |
101 |
- parser.add_argument('-r', '--keyring', |
102 |
- choices=['release', 'dev', 'overlays'], dest='keyring', default=None, |
103 |
- help='The keyring to use or update') |
104 |
+ parser.add_argument('-r', '--keydir', |
105 |
+ choices=['release', 'dev', 'overlays'], dest='keydir', default=None, |
106 |
+ help='The keydir to use or update') |
107 |
parser.add_argument('-s', '--seeds', |
108 |
choices=['release', 'dev'], dest='seeds', default=None, |
109 |
help='The seeds file to use or update') |
110 |
|
111 |
diff --git a/gkeys/config.py b/gkeys/config.py |
112 |
index 043f84f..96b4aee 100644 |
113 |
--- a/gkeys/config.py |
114 |
+++ b/gkeys/config.py |
115 |
@@ -97,11 +97,11 @@ class GKeysConfig(GPGConfig): |
116 |
|
117 |
|
118 |
class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid', |
119 |
- 'keyring', 'fingerprint'])): |
120 |
+ 'keydir', 'fingerprint'])): |
121 |
'''Class to hold the relavent info about a key''' |
122 |
|
123 |
field_types = {'nick': str, 'name': str, 'keyid': list, |
124 |
- 'longkeyid': list, 'keyring': str, 'fingerprint': list} |
125 |
+ 'longkeyid': list, 'keydir': str, 'fingerprint': list} |
126 |
field_separator = "|" |
127 |
list_separator = ":" |
128 |
__slots__ = () |
129 |
|
130 |
diff --git a/gkeys/lib.py b/gkeys/lib.py |
131 |
index 0420f7c..a97b7e7 100644 |
132 |
--- a/gkeys/lib.py |
133 |
+++ b/gkeys/lib.py |
134 |
@@ -30,12 +30,13 @@ class GkeysGPG(GPG): |
135 |
'''class init function |
136 |
|
137 |
@param config: GKeysConfig config instance to use |
138 |
- @param keyring: string, the path to the keydir to be used |
139 |
+ @param keydir: string, the path to the keydir to be used |
140 |
for all operations. |
141 |
''' |
142 |
GPG.__init__(self, config) |
143 |
self.config = config |
144 |
- self.keydir = keydir |
145 |
+ self.basedir = keydir |
146 |
+ self.keydir = None |
147 |
self.task = None |
148 |
self.task_value = None |
149 |
|
150 |
@@ -60,13 +61,20 @@ class GkeysGPG(GPG): |
151 |
self.task_value = None |
152 |
|
153 |
|
154 |
+ def set_keydir(self, keydir): |
155 |
+ logger.debug("basedir: %s, keydir: %s" % (self.basedir, keydir)) |
156 |
+ self.task = task |
157 |
+ self.keydir = pjoin(self.basedir, keydir) |
158 |
+ return |
159 |
+ |
160 |
+ |
161 |
def add_key(self, gkey): |
162 |
- '''Add the specified key to the specified keyring |
163 |
+ '''Add the specified key to the specified keydir |
164 |
|
165 |
@param gkey: GKEY namedtuple with |
166 |
- (name, keyid/longkeyid, keyring, fingerprint,) |
167 |
+ (name, keyid/longkeyid, keydir, fingerprint,) |
168 |
''' |
169 |
- self.set_keypath(gkey.keyring, self.config['tasks']['recv-keys']) |
170 |
+ self.set_keydir(gkey.keydir) |
171 |
|
172 |
# prefer the longkeyid if available |
173 |
#logger.debug("LIB: add_key; keyids %s, %s" |
174 |
@@ -105,60 +113,60 @@ class GkeysGPG(GPG): |
175 |
return results |
176 |
|
177 |
|
178 |
- def del_key(self, gkey, keyring): |
179 |
- '''Delete the specified key to the specified keyring |
180 |
+ def del_key(self, gkey, keydir): |
181 |
+ '''Delete the specified key in the specified keydir |
182 |
|
183 |
@param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint) |
184 |
''' |
185 |
return [] |
186 |
|
187 |
|
188 |
- def del_keyring(self, keyring): |
189 |
- '''Delete the specified key to the specified keyring |
190 |
+ def del_keydir(self, keydir): |
191 |
+ '''Delete the specified keydir |
192 |
''' |
193 |
return [] |
194 |
|
195 |
|
196 |
- def update_key(self, gkey, keyring): |
197 |
- '''Update the specified key in the specified keyring |
198 |
+ def update_key(self, gkey, keydir): |
199 |
+ '''Update the specified key in the specified keydir |
200 |
|
201 |
@param key: tuple of (name, keyid, fingerprint) |
202 |
- @param keyring: the keyring to add the key to |
203 |
+ @param keydir: the keydir to add the key to |
204 |
''' |
205 |
return [] |
206 |
|
207 |
|
208 |
- def list_keys(self, keyring): |
209 |
- '''List all keys in the specified keyring or |
210 |
- all key in all keyrings if keyring=None |
211 |
+ def list_keys(self, keydir): |
212 |
+ '''List all keys in the specified keydir or |
213 |
+ all keys in all keydir if keydir=None |
214 |
|
215 |
- @param keyring: the keyring to add the key to |
216 |
+ @param keydir: the keydir to list the keys for |
217 |
''' |
218 |
- if not keyring: |
219 |
- logger.debug("LIB: list_keys(), invalid keyring parameter: %s" |
220 |
- % str(keyring)) |
221 |
+ if not keydir: |
222 |
+ logger.debug("LIB: list_keys(), invalid keydir parameter: %s" |
223 |
+ % str(keydir)) |
224 |
return [] |
225 |
if '--with-colons' in self.config['tasks']['list-keys']: |
226 |
self.config['tasks']['list-keys'].remove('--with-colons') |
227 |
|
228 |
- self.set_keypath(keyring, self.config['tasks']['list-keys']) |
229 |
+ self.set_keydir(keydir) |
230 |
logger.debug("** Calling runGPG with Running 'gpg %s --list-keys %s'" |
231 |
- % (' '.join(self.config['tasks']['list-keys']), keyring) |
232 |
+ % (' '.join(self.config['tasks']['list-keys']), keydir) |
233 |
) |
234 |
- result = self.runGPG(task='list-keys', inputfile=keyring) |
235 |
+ result = self.runGPG(task='list-keys') |
236 |
logger.info('GPG return code: ' + str(result.returncode)) |
237 |
- self.reset_task() |
238 |
+ #self.reset_task() |
239 |
return result |
240 |
|
241 |
|
242 |
- def list_keyrings(self): |
243 |
- '''List all available keyrings |
244 |
+ def list_keydirs(self): |
245 |
+ '''List all available keydirs |
246 |
''' |
247 |
return [] |
248 |
|
249 |
|
250 |
def verify_key(self, gkey): |
251 |
- '''verify the specified key from the specified keyring |
252 |
+ '''verify the specified key from the specified keydir |
253 |
|
254 |
@param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint) |
255 |
''' |