mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-06-14 18:57:29 +02:00
Solved the subkey selection issue.
Changes one line and adds six to do this: * change keyid = verified.keyid to be keyid0; * added an if/else check to see if it's the subkey or master key; and * then set keyid according the result of that check; * then continues as normal.
This commit is contained in:
parent
720b299e82
commit
432b8f8fb5
@ -524,56 +524,28 @@ class User(callbacks.Plugin):
|
|||||||
'Authentication aborted.'), Raise=True)
|
'Authentication aborted.'), Raise=True)
|
||||||
verified = gpg.keyring.verify(data)
|
verified = gpg.keyring.verify(data)
|
||||||
if verified and verified.valid:
|
if verified and verified.valid:
|
||||||
keyid = verified.key_id
|
keyid0 = verified.key_id
|
||||||
fprint = verified.pubkey_fingerprint
|
fprint = verified.pubkey_fingerprint
|
||||||
kprint = fprint[-16:]
|
kprint = fprint[-16:]
|
||||||
prefix, expiry = self._tokens.pop(token)
|
prefix, expiry = self._tokens.pop(token)
|
||||||
found = False
|
found = False
|
||||||
pkeys = gpg.list_keys(False)
|
if keyid0 == kprint:
|
||||||
pnum = len(pkeys)
|
keyid = keyid0
|
||||||
for x in range(pnum):
|
else:
|
||||||
if keyid or kprint in pkeys[x]["keyid"] and keyid in user.gpgkeys and if keyid is kprint:
|
keyid = kprint
|
||||||
|
for (id, user) in ircdb.users.items():
|
||||||
|
if keyid in [x[-len(keyid):] for x in user.gpgkeys]:
|
||||||
user.addAuth(msg.prefix)
|
user.addAuth(msg.prefix)
|
||||||
|
try:
|
||||||
|
user.addAuth(msg.prefix)
|
||||||
|
except ValueError:
|
||||||
|
irc.error(_('Your secure flag is true and your '
|
||||||
|
'hostmask doesn\'t match any of your '
|
||||||
|
'known hostmasks.'), Raise=True)
|
||||||
ircdb.users.setUser(user, flush=False)
|
ircdb.users.setUser(user, flush=False)
|
||||||
irc.reply(_('You are now authenticated as %s with %s.')
|
irc.reply(_('You are now authenticated as %s.') %
|
||||||
% (user.name, keyid))
|
user.name)
|
||||||
return
|
return
|
||||||
elif keyid or kprint in pkeys[x]["keyid"] and keyid not in user.gpgkeys and kprint is in user.gpgkeys and keyid is not kprint:
|
|
||||||
user.addAuth(msg.prefix)
|
|
||||||
ircdb.users.setUser(user, flush=False)
|
|
||||||
irc.reply(_('You are now authenticated as %s with %s using the %s subkey.')
|
|
||||||
% (user.name, keyid, kprint))
|
|
||||||
return
|
|
||||||
elif keyid or kprint in pkeys[x]["keyid"] and keyid is kprint and keyid not in user.gpgkeys:
|
|
||||||
irc.error(_('I have a record of key %s, but it is not associated with the %s account.') % (keyid, user.name))
|
|
||||||
return
|
|
||||||
elif keyid or kprint in pkeys[x]["keyid"] and keyid is not kprint and keyid not in user.gpgkeys and kprint not in user.gpgkeys:
|
|
||||||
irc.error(_('I have a record of key %s, but it is not associated with any account.') % (keyid))
|
|
||||||
return
|
|
||||||
elif keyid is kprint and keyid not in pkeys[x]["keyid"] and keyid in user.gpgkeys:
|
|
||||||
irc.error(_('The %s key is registered to the %s account, but not currently available to me. Please add the key again') % (keyid, user.name))
|
|
||||||
# Possibly replace this with key retrieval attempt.
|
|
||||||
# try:
|
|
||||||
# code to retrieve key from server
|
|
||||||
# except AnErrorOfSomeKind:
|
|
||||||
# the current error message.
|
|
||||||
return
|
|
||||||
elif keyid and kprint not in pkeys[x]["keyid"] and keyid is not kprint and keyid not in user.gpgkeys and kprint not in user.gpgkeys:
|
|
||||||
irc.error(_('Unknown GPG key.'), Raise=True)
|
|
||||||
return
|
|
||||||
#for (id, user) in ircdb.users.items():
|
|
||||||
# if keyid in [x[-len(keyid):] for x in user.gpgkeys]:
|
|
||||||
# user.addAuth(msg.prefix)
|
|
||||||
# try:
|
|
||||||
# user.addAuth(msg.prefix)
|
|
||||||
# except ValueError:
|
|
||||||
# irc.error(_('Your secure flag is true and your '
|
|
||||||
# 'hostmask doesn\'t match any of your '
|
|
||||||
# 'known hostmasks.'), Raise=True)
|
|
||||||
# ircdb.users.setUser(user, flush=False)
|
|
||||||
# irc.reply(_('You are now authenticated as %s.') %
|
|
||||||
# user.name)
|
|
||||||
# return
|
|
||||||
irc.error(_('Unknown GPG key.'), Raise=True)
|
irc.error(_('Unknown GPG key.'), Raise=True)
|
||||||
else:
|
else:
|
||||||
irc.error(_('Signature could not be verified. Make sure '
|
irc.error(_('Signature could not be verified. Make sure '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user