mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-30 20:36:51 +02:00
Fix for escaping ValueError from ircdb.checkCapability.
This commit is contained in:
parent
046be171eb
commit
3d990599fe
37
src/ircdb.py
37
src/ircdb.py
@ -550,20 +550,7 @@ def _x(capability, ret):
|
||||
else:
|
||||
return ret
|
||||
|
||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||
"""Checks that the user specified by name/hostmask has the capabilty given.
|
||||
"""
|
||||
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
||||
if world.startup:
|
||||
#debug.printf('world.startup is active.')
|
||||
return _x(capability, True)
|
||||
try:
|
||||
u = users.getUser(hostmask)
|
||||
if u.secure and not u.checkHostmask(hostmask, useAuth=False):
|
||||
debug.printf('Secure user with non-matching hostmask.')
|
||||
raise KeyError
|
||||
except KeyError:
|
||||
#debug.printf('user could not be found.')
|
||||
def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
|
||||
if isChannelCapability(capability):
|
||||
#debug.printf('isChannelCapability true.')
|
||||
(channel, capability) = fromChannelCapability(capability)
|
||||
@ -587,6 +574,28 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||
else:
|
||||
#debug.printf('returning appropriate value given no good reason')
|
||||
return _x(capability, conf.defaultAllow)
|
||||
|
||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||
"""Checks that the user specified by name/hostmask has the capabilty given.
|
||||
"""
|
||||
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
||||
if world.startup:
|
||||
#debug.printf('world.startup is active.')
|
||||
return _x(capability, True)
|
||||
try:
|
||||
u = users.getUser(hostmask)
|
||||
if u.secure and not u.checkHostmask(hostmask, useAuth=False):
|
||||
debug.printf('Secure user with non-matching hostmask.')
|
||||
raise KeyError
|
||||
except KeyError:
|
||||
# Raised when no hostmasks match.
|
||||
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||
channels=channels)
|
||||
except ValueError, e:
|
||||
# Raised when multiple hostmasks match.
|
||||
debug.msg('%s: %s' % (hostmask, e))
|
||||
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||
channels=channels)
|
||||
#debug.printf('user found.')
|
||||
if capability in u.capabilities:
|
||||
#debug.printf('found capability in u.capabilities.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user