Browse Source

added an object that represents the ACL instead of messing with array indices

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
facb069dad
  1. 34
      pyweb/mumble/mmobjects.py
  2. 34
      pyweb/mumble/models.py
  3. 2
      pyweb/settings.py

34
pyweb/mumble/mmobjects.py

@ -218,3 +218,37 @@ class mmPlayer( object ):
def visit( self, callback, lvl = 0 ):
callback( self, lvl );
class mmACL:
def __init__( self, channelId, aclObj ):
aclsrc, groupsrc, inherit = aclObj;
self.channelId = channelId;
self.acls = [];
for line in aclsrc:
acl = {};
acl['applyHere'], acl['applySubs'], acl['inherited'], acl['playerid'], acl['group'], acl['allow'], acl['deny'] = line;
self.acls.append( acl );
self.groups = [];
for line in groupsrc:
group = {};
group['name'], group['inherited'], group['inherit'], group['inheritable'], group['add'], group['remove'], group['members'] = line;
self.groups.append( group );
if group['name'] == "admin":
self.admingroup = group;
self.inherit = inherit;
def pack( self ):
return (
self.channelId,
[( acl['applyHere'], acl['applySubs'], acl['inherited'], acl['playerid'], acl['group'], acl['allow'], acl['deny'] ) for acl in self.acls ],
[( group['name'], group['inherited'], group['inherit'], group['inheritable'], group['add'], group['remove'], group['members'] ) for group in self.groups ],
self.inherit
);

34
pyweb/mumble/models.py

@ -33,7 +33,7 @@
from django.contrib.auth.models import User
from django.db import models
from mmobjects import mmServer
from mmobjects import mmServer, mmACL
import dbus
import socket
@ -187,27 +187,27 @@ class MumbleUser( models.Model ):
def getAdmin( self ):
# Get ACL of root Channel, get the admin group and see if I'm in it
bus = self.server.getDbusObject();
aclinfo, groupinfo, inherit = bus.getACL(0);
acl = mmACL( bus.getACL(0) );
for grp in groupinfo:
if grp[0] == 'admin':
return self.mumbleid in grp[4];
return False;
if not hasattr( acl, "admingroup" ):
raise ValueError( "The admin group was not found in the ACL's groups list!" );
return self.mumbleid in acl.admingroup['add'];
def setAdmin( self, value ):
# Get ACL of root Channel, get the admin group and see if I'm in it
bus = self.server.getDbusObject();
aclinfo, groupinfo, inherit = bus.getACL(0);
for grp in groupinfo:
if grp[0] == 'admin':
if value != ( self.mumbleid in grp[4] ):
if value:
grp[4].append( self.mumbleid );
else:
grp[4].remove( self.mumbleid );
break;
bus.setACL( 0, aclinfo, groupinfo, inherit );
acl = mmACL( 0, bus.getACL(0) );
if not hasattr( acl, "admingroup" ):
raise ValueError( "The admin group was not found in the ACL's groups list!" );
if value != ( self.mumbleid in acl.admingroup['add'] ):
if value:
acl.admingroup['add'].append( dbus.Int32(self.mumbleid) );
else:
acl.admingroup['add'].remove( self.mumbleid );
bus.setACL( *acl.pack() );
return value;

2
pyweb/settings.py

@ -6,7 +6,7 @@
## The only setting you normally need to alter is this path. ##
## Set this to the path where you extracted mumble-django. ##
## ##
MUMBLE_DJANGO_ROOT = '/home/mistagee/mumble-django/hgrep'; ##
MUMBLE_DJANGO_ROOT = '/home/mistagee/mumble-django'; ##
## ##
## For a basic installation, this is all you need to edit in ##
## this file, the rest will be handled automatically! ##

Loading…
Cancel
Save