summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/server/configurationentries.txt2
-rw-r--r--doc/server/plugins/generators/rules.txt19
-rw-r--r--src/lib/Client/Tools/POSIX.py36
-rwxr-xr-xsrc/sbin/bcfg2-repo-validate2
4 files changed, 43 insertions, 16 deletions
diff --git a/doc/server/configurationentries.txt b/doc/server/configurationentries.txt
index 8741e56f5..6e6ab79f7 100644
--- a/doc/server/configurationentries.txt
+++ b/doc/server/configurationentries.txt
@@ -87,7 +87,7 @@ necessary for the Path type specified.
| | | applies to only | |
| | | YUMng) | |
+-------------+----------------------+-----------------+--------------------------+
-| nonexistent | New | Specify a path | name |
+| nonexistent | New | Specify a path | name, recursive |
| | | that should not | |
| | | exist | |
+-------------+----------------------+-----------------+--------------------------+
diff --git a/doc/server/plugins/generators/rules.txt b/doc/server/plugins/generators/rules.txt
index fe60a24fd..c3c4b61c4 100644
--- a/doc/server/plugins/generators/rules.txt
+++ b/doc/server/plugins/generators/rules.txt
@@ -251,14 +251,17 @@ hardlink
nonexistent
^^^^^^^^^^^
-+------+--------------------+-------------+
-| Name | Description | Values |
-+======+====================+=============+
-| name | Name of the | String |
-| | (nonexistent) file | |
-+------+--------------------+-------------+
-| type | Type of file | nonexistent |
-+------+--------------------+-------------+
++-----------+--------------------+-------------+
+| Name | Description | Values |
++===========+====================+=============+
+| name | Name of the | String |
+| | (nonexistent) file | |
++-----------+--------------------+-------------+
+| type | Type of file | nonexistent |
++-----------+--------------------+-------------+
+| recursive | Recursively remove | true |
+| | directory contents | |
++-----------+--------------------+-------------+
permissions
^^^^^^^^^^^
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: