diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Client/Tools/POSIX.py | 36 | ||||
-rwxr-xr-x | src/sbin/bcfg2-repo-validate | 2 |
2 files changed, 31 insertions, 7 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py index d2611130c..c883fc17a 100644 --- a/src/lib/Client/Tools/POSIX.py +++ b/src/lib/Client/Tools/POSIX.py @@ -671,12 +671,36 @@ class POSIX(Bcfg2.Client.Tools.Tool): def Installnonexistent(self, entry): '''Remove nonexistent entries''' - try: - os.remove(entry.get('name')) - return True - except OSError: - self.logger.error('Failed to remove %s' % entry.get('name')) - return False + ename = entry.get('name') + if entry.get('recursive') in ['True', 'true']: + # ensure that configuration spec is consistent first + if [e for e in self.buildModlist() \ + if e.startswith(ename) and e != ename]: + self.logger.error('Not installing %s. One or more files ' + 'in this directory are specified in ' + 'your configuration.' % ename) + return False + try: + shutil.rmtree(ename) + except OSError, e: + self.logger.error('Failed to remove %s: %s' % (ename, + e.strerror)) + else: + if os.path.isdir(ename): + try: + os.rmdir(ename) + return True + except OSError, e: + self.logger.error('Failed to remove %s: %s' % (ename, + e.strerror)) + return False + try: + os.remove(ename) + return True + except OSError, e: + self.logger.error('Failed to remove %s: %s' % (ename, + e.strerror)) + return False def Verifypermissions(self, entry, _): """Verify Path type='permissions' entry""" diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate index 3d5efb093..554e4f72b 100755 --- a/src/sbin/bcfg2-repo-validate +++ b/src/sbin/bcfg2-repo-validate @@ -94,7 +94,7 @@ if __name__ == '__main__': 'hardlink': ['name', 'to'], 'symlink': ['name', 'to'], 'ignore': ['name'], - 'nonexist': ['name'], + 'nonexistent': ['name'], 'permissions': ['name', 'owner', 'group', 'perms']} for rfile in rules_list: try: |