summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-06-20 12:07:16 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-06-20 12:20:05 -0500
commit19586bc42aa90543cf27e33ec32bd7df222138e8 (patch)
tree7a3643ff01c0921730d11814fff8e07c981f6c3a /src/lib/Server/Plugins
parent4f762722925113c56582a10dd4abead6cd84facc (diff)
downloadbcfg2-19586bc42aa90543cf27e33ec32bd7df222138e8.tar.gz
bcfg2-19586bc42aa90543cf27e33ec32bd7df222138e8.tar.bz2
bcfg2-19586bc42aa90543cf27e33ec32bd7df222138e8.zip
Cfg: Add support for perms='inherit' (Ticket #642)
This feature allows you to use the on-disk permissions of the file in the Cfg repository rather than specifying them using the traditional means in info.xml. Note that this only works for the octal permissions of the file on disk since the owner/group may not exist on the destination machine. Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r--src/lib/Server/Plugins/Cfg.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index c93b76488..23ba0a745 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -8,6 +8,7 @@ import operator
import os
import os.path
import re
+import stat
import sys
import tempfile
@@ -97,6 +98,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
Bcfg2.Server.Plugin.EntrySet.__init__(self, basename, path,
entry_type, encoding)
self.specific = CfgMatcher(path.split('/')[-1])
+ path = path
def sort_by_specific(self, one, other):
return cmp(one.specific, other.specific)
@@ -121,6 +123,11 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
self.bind_info_to_entry(entry, metadata)
used = self.get_pertinent_entries(metadata)
basefile = used.pop(0)
+ if entry.get('perms').lower() == 'inherit':
+ # use on-disk permissions
+ fname = "%s/%s" % (self.path, entry.get('name'))
+ entry.set('perms',
+ str(oct(stat.S_IMODE(os.stat(fname).st_mode))))
if entry.tag == 'Path':
entry.set('type', 'file')
if basefile.name.endswith(".genshi"):