Adjust some more ACLs in bf2 module

This commit is contained in:
Stefan Hacker 2010-12-31 16:49:31 +01:00
parent 60081ec154
commit 9c4e28c261
2 changed files with 56 additions and 29 deletions

View File

@ -134,7 +134,7 @@ class bf2(MumoModule):
log = self.log()
sid = server.id()
session = newstate.session
session = newstate.session
newoldchannel = newstate.channel
try:
@ -181,12 +181,10 @@ class bf2(MumoModule):
server.removeUserFromGroup(ogcfg["base"], session, "bf2_%s_game" % (og or ogcfgname))
squadname = self.id_to_squad_name[opi["squad"]]
if opi["squad"] != 0:
server.removeUserFromGroup(ogcfg["%s_commander" % opi["team"]], session, "bf2_commander")
server.removeUserFromGroup(ogcfg["%s_%s_squad_leader" % (opi["team"], squadname)], session, "bf2_squad_leader")
server.removeUserFromGroup(ogcfg["%s_%s_squad_leader" % (opi["team"], squadname)], session, "bf2_%s_squad_leader" % squadname)
server.removeUserFromGroup(ogcfg["%s_%s_squad" % (opi["team"], squadname)], session, "bf2_%s_squad_member" % squadname)
server.removeUserFromGroup(ogcfg[opi["team"]], session, "bf2_commander")
server.removeUserFromGroup(ogcfg[opi["team"]], session, "bf2_squad_leader")
server.removeUserFromGroup(ogcfg[opi["team"]], session, "bf2_%s_squad_leader" % squadname)
server.removeUserFromGroup(ogcfg[opi["team"]], session, "bf2_%s_squad" % squadname)
server.removeUserFromGroup(ogcfg[opi["team"]], session, "bf2_team")
channame = "left"
newstate.channel = ogcfg["left"]
@ -209,8 +207,7 @@ class bf2(MumoModule):
log.debug("Added '%s' @ %s to group %s in %s", newstate.name, ng or ngcfgname, group, location)
# Then add to squad group
location = "%s_%s_squad" % (npi["team"], squadname)
group = "bf2_%s_squad_member" % squadname
group = "bf2_%s_squad" % squadname
server.addUserToGroup(ngcfg[location], session, group)
log.debug("Added '%s' @ %s to group %s in %s", newstate.name, ng or ngcfgname, group, location)
@ -219,7 +216,6 @@ class bf2(MumoModule):
if npi["squad_leader"]:
# In case the leader flag is set add to leader group
location = "%s_%s_squad_leader" % (npi["team"], squadname)
group = "bf2_%s_squad_leader" % squadname
server.addUserToGroup(ngcfg[location], session, group)
log.debug("Added '%s' @ %s to group %s in %s", newstate.name, ng or ngcfgname, group, location)
@ -233,7 +229,6 @@ class bf2(MumoModule):
newstate.channel = ngcfg[channame]
if npi["commander"]:
location = "%s_commander" % npi["team"]
group = "bf2_commander"
server.addUserToGroup(ngcfg[location], session, group)
log.debug("Added '%s' @ %s to group %s in %s", newstate.name, ng or ngcfgname, group, location)

View File

@ -157,6 +157,8 @@ if __name__ == "__main__":
print "Creating channel structure:"
ACL = Murmur.ACL
EAT = Murmur.PermissionEnter | Murmur.PermissionTraverse
W = Murmur.PermissionWhisper
S = Murmur.PermissionSpeak
print name
ini['left'] = basechan
gamechan = server.addChannel(name, basechan)
@ -169,57 +171,87 @@ if __name__ == "__main__":
server.setACL(gamechan,
[ACL(applyHere = True,
applySubs = True,
userid = -1,
userid = -1,
group = 'all',
deny = EAT),
ACL(applyHere = True,
applySubs = False,
userid = -1,
group = 'bf2_linked',
allow = EAT)],
deny = EAT | W | S),
ACL(applyHere = True,
applySubs = True,
userid = -1,
group = '~bf2_%s_game' % name,
allow = S),
ACL(applyHere = True,
applySubs = False,
userid = -1,
group = '~bf2_%s_game' % name,
allow = EAT | W)],
[], True)
gamechanstate = server.getChannelState(gamechan)
teams = ["blufor", "opfor"]
id_to_squad_name = ["no", "alpha", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel", "india"]
for team in teams:
print name + "/" + team
ini[team] = server.addChannel(team, gamechan)
cid = server.addChannel(team, gamechan)
gamechanstate.links.append(cid)
ini[team] = cid
server.setACL(ini[team],
[ACL(applyHere = True,
applySubs = False,
userid = -1,
group = 'bf2%s_%s' % (name, team),
allow = EAT)],
group = '~bf2_team',
allow = EAT | W)],
[], True)
print name + "/" + team + "_commander"
ini[team + "_commander"] = server.addChannel("commander", ini[team])
cid = server.addChannel("commander", ini[team])
gamechanstate.links.append(cid)
ini[team + "_commander"] = cid
server.setACL(ini[team + "_commander"],
[ACL(applyHere = True,
applySubs = False,
userid = -1,
group = 'bf2%s_%s_commander' % (name, team),
allow = EAT)],
group = '~bf2_commander',
allow = EAT | W),
ACL(applyHere = True,
applySubs = False,
userid = -1,
group = '~bf2_squad_leader',
allow = W)],
[], True)
state = server.getChannelState(ini[team+"_commander"])
state.position = -1
server.setChannelState(state)
ini[team + "_no_squad"] = ini[team]
for squad in id_to_squad_name[1:]:
for squad in id_to_squad_name:
print name + "/" + team + "/" + squad
ini[team + "_" + squad + "_squad"] = server.addChannel(squad, ini[team])
cid = server.addChannel(squad, ini[team])
gamechanstate.links.append(cid)
ini[team + "_" + squad + "_squad"] = cid
ini[team + "_" + squad + "_squad_leader"] = ini[team + "_" + squad + "_squad"]
server.setACL(ini[team + "_" + squad + "_squad"],
[ACL(applyHere = True,
applySubs = False,
userid = -1,
group = 'bf2%s_%s_%s_squad' % (name, team, squad),
allow = EAT)],
group = '~bf2_%s_squad' % squad,
allow = EAT | W),
ACL(applyHere = True,
applySubs = False,
userid = -1,
group = '~bf2_commander',
allow = EAT | W),
ACL(applyHere = True,
applySubs = False,
userid = -1,
group = '~bf2_squad_leader',
allow = W)],
[], True)
server.setChannelState(gamechanstate)
print "Channel structure created"
print "Writing configuration to output file '%s'..." % option.out,