ircdb: Honor ignoreDefaultAllow for unknown users too.

This commit is contained in:
Valentin Lorentz 2014-02-27 19:04:54 +00:00
parent a3c79d61f8
commit 59ae6f987d

View File

@ -1035,7 +1035,8 @@ def _x(capability, ret):
else: else:
return ret return ret
def _checkCapabilityForUnknownUser(capability, users=users, channels=channels): def _checkCapabilityForUnknownUser(capability, users=users, channels=channels,
ignoreDefaultAllow=False):
if isChannelCapability(capability): if isChannelCapability(capability):
(channel, capability) = fromChannelCapability(capability) (channel, capability) = fromChannelCapability(capability)
try: try:
@ -1043,12 +1044,14 @@ def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
if capability in c.capabilities: if capability in c.capabilities:
return c._checkCapability(capability) return c._checkCapability(capability)
else: else:
return _x(capability, c.defaultAllow) return _x(capability, (not ignoreDefaultAllow) and c.defaultAllow)
except KeyError: except KeyError:
pass pass
defaultCapabilities = conf.supybot.capabilities() defaultCapabilities = conf.supybot.capabilities()
if capability in defaultCapabilities: if capability in defaultCapabilities:
return defaultCapabilities.check(capability) return defaultCapabilities.check(capability)
elif ignoreDefaultAllow:
return _x(capability, False)
else: else:
return _x(capability, conf.supybot.capabilities.default()) return _x(capability, conf.supybot.capabilities.default())
@ -1082,12 +1085,12 @@ def checkCapability(hostmask, capability, users=users, channels=channels,
except KeyError: except KeyError:
# Raised when no hostmasks match. # Raised when no hostmasks match.
return _checkCapabilityForUnknownUser(capability, users=users, return _checkCapabilityForUnknownUser(capability, users=users,
channels=channels) channels=channels, ignoreDefaultAllow=ignoreDefaultAllow)
except ValueError as e: except ValueError as e:
# Raised when multiple hostmasks match. # Raised when multiple hostmasks match.
log.warning('%s: %s', hostmask, e) log.warning('%s: %s', hostmask, e)
return _checkCapabilityForUnknownUser(capability, users=users, return _checkCapabilityForUnknownUser(capability, users=users,
channels=channels) channels=channels, ignoreDefaultAllow=ignoreDefaultAllow)
if capability in u.capabilities: if capability in u.capabilities:
try: try:
return u._checkCapability(capability, ignoreOwner) return u._checkCapability(capability, ignoreOwner)
@ -1112,6 +1115,8 @@ def checkCapability(hostmask, capability, users=users, channels=channels,
defaultCapabilities = conf.supybot.capabilities() defaultCapabilities = conf.supybot.capabilities()
if capability in defaultCapabilities: if capability in defaultCapabilities:
return defaultCapabilities.check(capability) return defaultCapabilities.check(capability)
elif ignoreDefaultAllow:
return _x(capability, False)
else: else:
return _x(capability, conf.supybot.capabilities.default()) return _x(capability, conf.supybot.capabilities.default())