summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Connon <richard@connon.me.uk>2014-02-04 16:03:17 +0000
committerRichard Connon <richard@connon.me.uk>2014-02-04 16:03:17 +0000
commitd208eed80e048ea2081165c7aaaa92c558c38b25 (patch)
tree51d9f61c70d0fae290ebff7495d7b8f8786ccfc5
parenta40c7fe2457688fd574558de7b8e31e9c30afb96 (diff)
downloadbcfg2-d208eed80e048ea2081165c7aaaa92c558c38b25.tar.gz
bcfg2-d208eed80e048ea2081165c7aaaa92c558c38b25.tar.bz2
bcfg2-d208eed80e048ea2081165c7aaaa92c558c38b25.zip
fix for "Too many branches" in _verify_acls
-rw-r--r--src/lib/Bcfg2/Client/Tools/POSIX/base.py43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/POSIX/base.py b/src/lib/Bcfg2/Client/Tools/POSIX/base.py
index 4ef4ae3f5..4fb3c7b34 100644
--- a/src/lib/Bcfg2/Client/Tools/POSIX/base.py
+++ b/src/lib/Bcfg2/Client/Tools/POSIX/base.py
@@ -643,26 +643,7 @@ class POSIXTool(Bcfg2.Client.Tools.Tool):
def _verify_acls(self, entry, path=None):
""" verify POSIX ACLs on the given entry. return True if all
ACLS are correct, false otherwise """
- if not HAS_ACLS:
- if entry.findall("ACL"):
- self.logger.debug("POSIX: ACLs listed for %s but no pylibacl "
- "library installed" % entry.get('name'))
- return True
-
- if path is None:
- path = entry.get("name")
-
- # create lists of normalized representations of the ACLs we want
- # and the ACLs we have. this will make them easier to compare
- # than trying to mine that data out of the ACL objects and XML
- # objects and compare it at the same time.
- wanted = self._list_entry_acls(entry)
- existing = self._list_file_acls(path)
-
- missing = []
- extra = []
- wrong = []
- for aclkey, perms in wanted.items():
+ def _verify_acl(aclkey, perms):
if aclkey not in existing:
missing.append(self._acl2string(aclkey, perms))
elif existing[aclkey] != perms:
@@ -689,6 +670,28 @@ class POSIXTool(Bcfg2.Client.Tools.Tool):
aclentry.set(aclentry.get("scope"), qual)
entry.append(aclentry)
+ if not HAS_ACLS:
+ if entry.findall("ACL"):
+ self.logger.debug("POSIX: ACLs listed for %s but no pylibacl "
+ "library installed" % entry.get('name'))
+ return True
+
+ if path is None:
+ path = entry.get("name")
+
+ # create lists of normalized representations of the ACLs we want
+ # and the ACLs we have. this will make them easier to compare
+ # than trying to mine that data out of the ACL objects and XML
+ # objects and compare it at the same time.
+ wanted = self._list_entry_acls(entry)
+ existing = self._list_file_acls(path)
+
+ missing = []
+ extra = []
+ wrong = []
+ for aclkey, perms in wanted.items():
+ _verify_acl(aclkey, perms)
+
for aclkey, perms in existing.items():
if aclkey not in wanted:
extra.append(self._acl2string(aclkey, perms))