Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeyldap/
Date: Sun, 10 Nov 2013 01:01:19
Message-Id: 1384031859.55af15b6c3e64ba2f7d9a81b04d2cef6b4c9b513.dol-sen@gentoo
1 commit: 55af15b6c3e64ba2f7d9a81b04d2cef6b4c9b513
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Nov 9 19:27:28 2013 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Sat Nov 9 21:17:39 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=55af15b6
7
8 Don't add a dev's seed if there were errors
9
10 ---
11 gkeyldap/actions.py | 34 ++++++++++++++++++++++++++--------
12 1 file changed, 26 insertions(+), 8 deletions(-)
13
14 diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
15 index ee5efd9..7ffa094 100644
16 --- a/gkeyldap/actions.py
17 +++ b/gkeyldap/actions.py
18 @@ -125,9 +125,11 @@ class Actions(object):
19 continue
20 #self.logger.debug("create_seedfile, dev = "
21 # "%s, %s" % (str(dev), str(devs[dev])))
22 - new_gkey = GKEY._make(self.build_gkeylist(devs[dev]))
23 - self.seeds.add(new_gkey)
24 - count += 1
25 + keyinfo = self.build_gkeylist(devs[dev])
26 + if keyinfo:
27 + new_gkey = GKEY._make(keyinfo)
28 + self.seeds.add(new_gkey)
29 + count += 1
30 self.output("Total number of seeds created:", count)
31 self.output("Seeds created...saving file: %s" % filename)
32 return self.seeds.save()
33 @@ -174,6 +176,8 @@ class Actions(object):
34 keyinfo = []
35 keyid_found = False
36 keyid_missing = False
37 + # assume it's good until found an error is found
38 + is_good = True
39 #self.logger.debug("MAIN: build_gkeylist; info = %s" % str(info))
40 for x in GKEY._fields:
41 field = gkey2ldap_map[x]
42 @@ -198,6 +202,7 @@ class Actions(object):
43 self.logger.error('ERROR in ldap info for: %s, %s'
44 %(info['uid'][0],info['cn'][0]))
45 self.logger.error(' %s = "undefined"' %(field))
46 + is_good = False
47 keyinfo.append(value)
48 except KeyError:
49 self.logger.error('ERROR in ldap info for: %s, %s'
50 @@ -207,6 +212,7 @@ class Actions(object):
51 if x in ['keyid', 'longkeyid']:
52 keyid_missing = True
53 keyinfo.append(None)
54 + is_good = False
55 if not keyid_found and not keyid_missing:
56 try:
57 gpgkey = info[gkey2ldap_map['longkeyid']]
58 @@ -216,14 +222,21 @@ class Actions(object):
59 %(info['uid'][0],info['cn'][0]))
60 self.logger.error(' A valid keyid or longkeyid was not found '
61 "%s : gpgkey = %s" %(info['cn'][0], gpgkey))
62 + is_good = False
63 else:
64 if keyinfo[5]: # fingerprints exist check
65 - self._check_fingerprint_integrity(info, keyinfo)
66 - self._check_id_fingerprint_match(info, keyinfo)
67 - return keyinfo
68 + is_ok = self._check_fingerprint_integrity(info, keyinfo)
69 + is_match = self._check_id_fingerprint_match(info, keyinfo)
70 + if not is_ok or not is_match:
71 + is_good = False
72 + if is_good:
73 + return keyinfo
74 + return None
75
76
77 def _check_id_fingerprint_match(self, info, keyinfo):
78 + # assume it's good until found an error is found
79 + is_good = True
80 for x in [2, 3]:
81 # skip blank id field
82 if not keyinfo[x]:
83 @@ -236,10 +249,13 @@ class Actions(object):
84 self.logger.error(' ' + str(keyinfo))
85 self.logger.error(' GPGKey id %s not found in the '
86 % y.lstrip('0x') + 'listed fingerprint(s)')
87 - return
88 + is_good = False
89 + return is_good
90
91
92 def _check_fingerprint_integrity(self, info, keyinfo):
93 + # assume it's good until found an error is found
94 + is_good = True
95 for x in keyinfo[5]:
96 # check fingerprint integrity
97 if len(x) != 40:
98 @@ -247,10 +263,12 @@ class Actions(object):
99 %(info['uid'][0],info['cn'][0]))
100 self.logger.error(' GPGKey incorrect fingerprint ' +
101 'length (%s) for fingerprint: %s' %(len(x), x))
102 + is_good = False
103 continue
104 if not self.fingerprint_re.match(x):
105 self.logger.error('ERROR in ldap info for: %s, %s'
106 %(info['uid'][0],info['cn'][0]))
107 self.logger.error(' GPGKey: Non hexadecimal digits in ' +
108 'fingerprint for fingerprint: ' + x)
109 - return
110 + is_good = False
111 + return is_good