Mercurial > hg
comparison hgext/gpg.py @ 36034:f3d8f61c425d
gpg: print unknown key IDs in their entirety
Shortening the key is nice in theory but it results in ambiguity which can
be exploited. Therefore, when encountering an unknown key ID we should
print the whole ID returned by gpg. This may or may not be the whole key,
however it will match the user preference set in gpg configuration.
Furthermore, the key ID shortening had a couple of issues:
(1) it truncated the key ID (dropping the last digit and outputting only 15
hex digits) making it very hard to find the correct key on a key server
(2) since only 15 digits were fed into shortkey(), it always emitted the
ui.debug() warning
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 11 Feb 2018 18:32:37 -0500 |
parents | de1f045781e0 |
children | c6061cadb400 |
comparison
equal
deleted
inserted
replaced
36033:dae84ccebc57 | 36034:f3d8f61c425d |
---|---|
151 | 151 |
152 validkeys = [] | 152 validkeys = [] |
153 # warn for expired key and/or sigs | 153 # warn for expired key and/or sigs |
154 for key in keys: | 154 for key in keys: |
155 if key[0] == "ERRSIG": | 155 if key[0] == "ERRSIG": |
156 ui.write(_("%s Unknown key ID \"%s\"\n") | 156 ui.write(_("%s Unknown key ID \"%s\"\n") % (prefix, key[1])) |
157 % (prefix, shortkey(ui, key[1][:15]))) | |
158 continue | 157 continue |
159 if key[0] == "BADSIG": | 158 if key[0] == "BADSIG": |
160 ui.write(_("%s Bad signature from \"%s\"\n") % (prefix, key[2])) | 159 ui.write(_("%s Bad signature from \"%s\"\n") % (prefix, key[2])) |
161 continue | 160 continue |
162 if key[0] == "EXPSIG": | 161 if key[0] == "EXPSIG": |
318 repo.commit(message, opts['user'], opts['date'], match=msigs, | 317 repo.commit(message, opts['user'], opts['date'], match=msigs, |
319 editor=editor) | 318 editor=editor) |
320 except ValueError as inst: | 319 except ValueError as inst: |
321 raise error.Abort(str(inst)) | 320 raise error.Abort(str(inst)) |
322 | 321 |
323 def shortkey(ui, key): | |
324 if len(key) != 16: | |
325 ui.debug("key ID \"%s\" format error\n" % key) | |
326 return key | |
327 | |
328 return key[-8:] | |
329 | |
330 def node2txt(repo, node, ver): | 322 def node2txt(repo, node, ver): |
331 """map a manifest into some text""" | 323 """map a manifest into some text""" |
332 if ver == "0": | 324 if ver == "0": |
333 return "%s\n" % hgnode.hex(node) | 325 return "%s\n" % hgnode.hex(node) |
334 else: | 326 else: |