Made sure chanop capability supercedes everything else.

This commit is contained in:
Jeremy Fincher 2003-09-13 12:59:22 +00:00
parent d3a81688fa
commit 5a15783e7a
2 changed files with 24 additions and 9 deletions

View File

@ -564,17 +564,18 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
#debug.printf('isChannelCapability true, user found too.')
(channel, capability) = fromChannelCapability(capability)
try:
chanop = makeChannelCapability(channel, 'op')
if u.checkCapability(chanop):
return _x(capability, True)
except KeyError:
pass
c = channels.getChannel(channel)
#debug.printf('channel found')
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.defaultCapabilities')
return True

View File

@ -35,6 +35,7 @@ import os
import unittest
import conf
import debug
import ircdb
import ircutils
@ -296,6 +297,7 @@ class CheckCapabilityTestCase(unittest.TestCase):
anticap = ircdb.makeAntiCapability(cap)
chancap = ircdb.makeChannelCapability(channel, cap)
antichancap = ircdb.makeAntiCapability(chancap)
chanop = ircdb.makeChannelCapability(channel, 'op')
channelnothing = ircdb.IrcChannel()
channelcap = ircdb.IrcChannel()
channelcap.addCapability(cap)
@ -393,6 +395,18 @@ class CheckCapabilityTestCase(unittest.TestCase):
self.failUnless(self.checkCapability(self.justchanfoo, self.chancap))
self.failIf(self.checkCapability(self.justchanfoo, self.antichancap))
def testChanOpCountsAsEverything(self):
self.channels.setChannel(self.channel, self.channelanticap)
id = self.users.getUserId('nothing')
u = self.users.getUser(id)
u.addCapability(self.chanop)
self.users.setUser(id, u)
self.failUnless(self.checkCapability(self.nothing, self.chancap))
self.channels.setChannel(self.channel, self.channelnothing)
self.failUnless(self.checkCapability(self.nothing, self.chancap))
self.channelnothing.defaultAllow = not self.channelnothing.defaultAllow
self.failUnless(self.checkCapability(self.nothing, self.chancap))
def testAntiChanFoo(self):
self.channels.setChannel(self.channel, self.channelnothing)
self.failIf(self.checkCapability(self.antichanfoo, self.chancap))