From 168aa5f9d31f310caa2d8fb87b5d46d6e23b5821 Mon Sep 17 00:00:00 2001 From: Matt Schwager Date: Wed, 17 Oct 2012 13:44:43 -0400 Subject: IP based ACLs working for CherryPy and Builtin Server. Rudimentary tests performed and passed. --- src/lib/Bcfg2/Server/Plugins/Acl.py | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins/Acl.py') diff --git a/src/lib/Bcfg2/Server/Plugins/Acl.py b/src/lib/Bcfg2/Server/Plugins/Acl.py index dd1077da1..71275de27 100644 --- a/src/lib/Bcfg2/Server/Plugins/Acl.py +++ b/src/lib/Bcfg2/Server/Plugins/Acl.py @@ -3,40 +3,40 @@ import logging import Bcfg2.Server.Plugin class AclFile(Bcfg2.Server.Plugin.XMLFileBacked): - """ representation of ACL config.xml """ - - # 'name' error without this tag - __identifier__ = None - - def __init__(self, filename, core=None): - # create config.xml if missing - if not os.path.exists(filename): - LOGGER.warning("Acl: %s missing. " - "Creating empty one for you." % filename) - open(filename, "w").write("") - - try: - fam = core.fam - except AttributeError: - fam = None - - Bcfg2.Server.Plugin.XMLFileBacked.__init__(self, filename, fam=fam, - should_monitor=True) - self.core = core - self.ips = [] - self.logger = logging.getLogger(self.__class__.__name__) - - def Index(self): - Bcfg2.Server.Plugin.XMLFileBacked.Index(self) - for entry in self.xdata.xpath('//IPs'): - [self.ips.append(i.get('name')) for i in entry.findall('IP')] + """ representation of ACL config.xml """ + + # 'name' error without this tag + __identifier__ = None + + def __init__(self, filename, core=None): + # create config.xml if missing + if not os.path.exists(filename): + LOGGER.warning("Acl: %s missing. " + "Creating empty one for you." % filename) + open(filename, "w").write("") + + try: + fam = core.fam + except AttributeError: + fam = None + + Bcfg2.Server.Plugin.XMLFileBacked.__init__(self, filename, fam=fam, + should_monitor=True) + self.core = core + self.ips = [] + self.logger = logging.getLogger(self.__class__.__name__) + + def Index(self): + Bcfg2.Server.Plugin.XMLFileBacked.Index(self) + for entry in self.xdata.xpath('//IPs'): + [self.ips.append(i.get('name')) for i in entry.findall('IP')] class Acl(Bcfg2.Server.Plugin.Plugin, - Bcfg2.Server.Plugin.Connector): - """ allow connections to bcfg-server based on IP address """ + Bcfg2.Server.Plugin.Connector): + """ allow connections to bcfg-server based on IP address """ - def __init__(self, core, datastore): - Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) - Bcfg2.Server.Plugin.Connector.__init__(self) - self.config = AclFile(os.path.join(self.data, 'config.xml'), core=core) + def __init__(self, core, datastore): + Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore) + Bcfg2.Server.Plugin.Connector.__init__(self) + self.config = AclFile(os.path.join(self.data, 'config.xml'), core=core) -- cgit v1.2.3-1-g7c22