diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-09-18 08:25:12 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-09-18 08:25:12 -0400 |
commit | 09e510adfa71985c6dec8fb501fa3b18b7b28649 (patch) | |
tree | 5adbe1b7cad769d11febadfaa6844f9cd5da6f42 /src/lib/Bcfg2 | |
parent | 3ab678e7fcff5dc5537e8518f5b76e83da9338b7 (diff) | |
download | bcfg2-09e510adfa71985c6dec8fb501fa3b18b7b28649.tar.gz bcfg2-09e510adfa71985c6dec8fb501fa3b18b7b28649.tar.bz2 bcfg2-09e510adfa71985c6dec8fb501fa3b18b7b28649.zip |
SEModules: fixed handling of module names again
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/SELinux.py | 12 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/SEModules.py | 21 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/SELinux.py b/src/lib/Bcfg2/Client/Tools/SELinux.py index f060a1374..babdaf6bf 100644 --- a/src/lib/Bcfg2/Client/Tools/SELinux.py +++ b/src/lib/Bcfg2/Client/Tools/SELinux.py @@ -703,14 +703,8 @@ class SELinuxModuleHandler(SELinuxEntryHandler): return rv def _filepath(self, entry): - path = os.path.join("/usr/share/selinux", self.setype, - entry.get("name").lstrip("/")) - if not path.endswith(".pp"): - # the entry name we get from the SEModules plugin should - # always have .pp on the end, but we double check just to - # make absolutely certain - path = path + ".pp" - return path + return os.path.join("/usr/share/selinux", self.setype, + entry.get("name") + '.pp') def _pathentry(self, entry): pathentry = copy.deepcopy(entry) @@ -737,7 +731,7 @@ class SELinuxModuleHandler(SELinuxEntryHandler): try: # if seobject has the moduleRecords attribute, install the # module using the seobject library - self.records + self.records # pylint: disable=W0104 return self._install_seobject(entry) except AttributeError: # seobject doesn't have the moduleRecords attribute, so diff --git a/src/lib/Bcfg2/Server/Plugins/SEModules.py b/src/lib/Bcfg2/Server/Plugins/SEModules.py index 324c2309f..ce75be044 100644 --- a/src/lib/Bcfg2/Server/Plugins/SEModules.py +++ b/src/lib/Bcfg2/Server/Plugins/SEModules.py @@ -20,7 +20,7 @@ class SEModules(Bcfg2.Server.Plugin.GroupSpool): entry_type = 'SELinux' experimental = True - def _get_module_name(self, entry): + def _get_module_filename(self, entry): """ GroupSpool stores entries as /foo.pp, but we want people to be able to specify module entries as name='foo' or name='foo.pp', so we put this abstraction in between """ @@ -28,17 +28,32 @@ class SEModules(Bcfg2.Server.Plugin.GroupSpool): name = entry.get("name") else: name = entry.get("name") + ".pp" + return "/" + name + + def _get_module_name(self, entry): + """ On the client we do most of our logic on just the module + name, but we want people to be able to specify module entries + as name='foo' or name='foo.pp', so we put this abstraction in + between""" + if entry.get("name").endswith(".pp"): + name = entry.get("name")[:-3] + else: + name = entry.get("name") return name.lstrip("/") def HandlesEntry(self, entry, metadata): + print "entry.tag = %s, self.Entries = %s" % (entry.tag, self.Entries.keys()) + print "entry type = %s" % entry.get('type') if entry.tag in self.Entries and entry.get('type') == 'module': - return "/" + self._get_module_name(entry) in self.Entries[entry.tag] + print " filename = %s, self.Entries[%s] = %s" % (self._get_module_filename(entry), entry.tag, self.Entries[entry.tag].keys()) + return self._get_module_filename(entry) in self.Entries[entry.tag] return Bcfg2.Server.Plugin.GroupSpool.HandlesEntry(self, entry, metadata) def HandleEntry(self, entry, metadata): entry.set("name", self._get_module_name(entry)) - return self.Entries[entry.tag]["/" + entry.get("name")](entry, metadata) + bind = self.Entries[entry.tag][self._get_module_filename(entry)] + return bind(entry, metadata) def add_entry(self, event): self.filename_pattern = \ |