Commit b4f576d0 authored by simonft's avatar simonft
Browse files

Don't attempt to sign a user's own key

Instead, warn.

Fixes #30
parent faa3126e
......@@ -858,6 +858,25 @@ class OpenPGPkey():
if i == 4: s += ' '
return s
def __eq__(self, other):
"""
Two keys are equal if their fingerprint matches. If either don't
have a fingerprint, we can't say for sure that they're equal
"""
if isinstance(other, self.__class__):
return (self.fpr and
self.fpr and other.fpr
and self.fpr == other.fpr)
else:
return NotImplemented
def __neq__(self, other):
if isinstance(other, self.__class__):
return not self.__eq__(other)
else:
return NotImplemented
class OpenPGPuid():
def __init__(self, uid, trust, creation = 0, expire = None, uidhash = ''):
self.uid = uid
......
......@@ -559,7 +559,15 @@ ordering.
assert(keys is not None) # nosec
self.log(_('found %d keys matching your request') % len(keys))
secret_keys = self.keyring.get_keys(self.options.user, True, False)
for key in keys:
# Make sure the user isn't signing their own key
for secret_key in secret_keys.values():
if keys[key] == secret_key:
self.warn(_('Refusing to sign own key'))
return False
alluids = self.yes_no(_("""\
Signing the following key
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment