mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Fix for escaping ValueError from ircdb.checkCapability.
This commit is contained in:
parent
046be171eb
commit
3d990599fe
57
src/ircdb.py
57
src/ircdb.py
@ -550,6 +550,31 @@ def _x(capability, ret):
|
|||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
|
||||||
|
if isChannelCapability(capability):
|
||||||
|
#debug.printf('isChannelCapability true.')
|
||||||
|
(channel, capability) = fromChannelCapability(capability)
|
||||||
|
try:
|
||||||
|
c = channels.getChannel(channel)
|
||||||
|
if capability in c.capabilities:
|
||||||
|
#debug.printf('capability in c.capabilities')
|
||||||
|
return c.checkCapability(capability)
|
||||||
|
else:
|
||||||
|
#debug.printf('capability not in c.capabilities')
|
||||||
|
return _x(capability, c.defaultAllow)
|
||||||
|
except KeyError:
|
||||||
|
#debug.printf('no such channel %s' % channel)
|
||||||
|
pass
|
||||||
|
if capability in conf.defaultCapabilities:
|
||||||
|
#debug.printf('capability in conf.defaultCapability')
|
||||||
|
return True
|
||||||
|
elif invertCapability(capability) in conf.defaultCapabilities:
|
||||||
|
#debug.printf('inverse capability in conf.defaultCapability')
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
#debug.printf('returning appropriate value given no good reason')
|
||||||
|
return _x(capability, conf.defaultAllow)
|
||||||
|
|
||||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||||
"""Checks that the user specified by name/hostmask has the capabilty given.
|
"""Checks that the user specified by name/hostmask has the capabilty given.
|
||||||
"""
|
"""
|
||||||
@ -563,30 +588,14 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
debug.printf('Secure user with non-matching hostmask.')
|
debug.printf('Secure user with non-matching hostmask.')
|
||||||
raise KeyError
|
raise KeyError
|
||||||
except KeyError:
|
except KeyError:
|
||||||
#debug.printf('user could not be found.')
|
# Raised when no hostmasks match.
|
||||||
if isChannelCapability(capability):
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
#debug.printf('isChannelCapability true.')
|
channels=channels)
|
||||||
(channel, capability) = fromChannelCapability(capability)
|
except ValueError, e:
|
||||||
try:
|
# Raised when multiple hostmasks match.
|
||||||
c = channels.getChannel(channel)
|
debug.msg('%s: %s' % (hostmask, e))
|
||||||
if capability in c.capabilities:
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
#debug.printf('capability in c.capabilities')
|
channels=channels)
|
||||||
return c.checkCapability(capability)
|
|
||||||
else:
|
|
||||||
#debug.printf('capability not in c.capabilities')
|
|
||||||
return _x(capability, c.defaultAllow)
|
|
||||||
except KeyError:
|
|
||||||
#debug.printf('no such channel %s' % channel)
|
|
||||||
pass
|
|
||||||
if capability in conf.defaultCapabilities:
|
|
||||||
#debug.printf('capability in conf.defaultCapability')
|
|
||||||
return True
|
|
||||||
elif invertCapability(capability) in conf.defaultCapabilities:
|
|
||||||
#debug.printf('inverse capability in conf.defaultCapability')
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
#debug.printf('returning appropriate value given no good reason')
|
|
||||||
return _x(capability, conf.defaultAllow)
|
|
||||||
#debug.printf('user found.')
|
#debug.printf('user found.')
|
||||||
if capability in u.capabilities:
|
if capability in u.capabilities:
|
||||||
#debug.printf('found capability in u.capabilities.')
|
#debug.printf('found capability in u.capabilities.')
|
||||||
|
Loading…
Reference in New Issue
Block a user