aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2009-02-05 21:21:51 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2009-02-05 21:21:51 +0000
commit99d20f31a6a94c982e071e55867fda020097c9a9 (patch)
tree514f64fb93eee25aa11bb5fd31f1bcfffc5e2b4b /src
parenta01ec3e1575a1466e5a96f10601ef974e8267d26 (diff)
downloadmsec-99d20f31a6a94c982e071e55867fda020097c9a9.tar
msec-99d20f31a6a94c982e071e55867fda020097c9a9.tar.gz
msec-99d20f31a6a94c982e071e55867fda020097c9a9.tar.bz2
msec-99d20f31a6a94c982e071e55867fda020097c9a9.tar.xz
msec-99d20f31a6a94c982e071e55867fda020097c9a9.zip
Support for running msecperms with custom root.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/msec/libmsec.py5
-rwxr-xr-xsrc/msec/msecperms.py9
2 files changed, 10 insertions, 4 deletions
diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py
index 61aaa52..6d26b87 100755
--- a/src/msec/libmsec.py
+++ b/src/msec/libmsec.py
@@ -1614,9 +1614,10 @@ class MSEC:
# {{{ PERMS - permissions handling
class PERMS:
"""Permission checking/enforcing."""
- def __init__(self, log):
+ def __init__(self, log, root=''):
"""Initializes internal variables"""
self.log = log
+ self.root = root
self.USER = {}
self.GROUP = {}
self.USERID = {}
@@ -1776,7 +1777,7 @@ class PERMS:
group = self.get_group_id(group_s)
# now check the permissions
- for f in glob.glob(file):
+ for f in glob.glob('%s%s' % (self.root, file)):
# get file properties
f = os.path.realpath(f)
try:
diff --git a/src/msec/msecperms.py b/src/msec/msecperms.py
index f073b94..e4ebc58 100755
--- a/src/msec/msecperms.py
+++ b/src/msec/msecperms.py
@@ -64,6 +64,7 @@ Available parameters:
-p, --pretend only pretend to change the level, perform no real
actions. Use this to see what operations msec
will perform.
+ -r, --root <path> path to use as root
""" % (version, config.PERMCONF, config.PERMCONF)
# }}}
@@ -73,10 +74,11 @@ if __name__ == "__main__":
force_level = False
commit = True
enforce = False
+ root = ''
# parse command line
try:
- opt, args = getopt.getopt(sys.argv[1:], 'hel:f:dp', ['help', 'enforce', 'list=', 'force=', 'debug', 'pretend'])
+ opt, args = getopt.getopt(sys.argv[1:], 'hel:f:dpr:', ['help', 'enforce', 'list=', 'force=', 'debug', 'pretend', 'root='])
except getopt.error:
usage()
sys.exit(1)
@@ -110,6 +112,9 @@ if __name__ == "__main__":
# permission enforcing
elif o[0] == '-e' or o[0] == '--enforce':
enforce = True
+ # custom root
+ elif o[0] == '-r' or o[0] == '--root':
+ root = o[1]
# check-only mode
elif o[0] == '-p' or o[0] == '--pretend':
commit = False
@@ -148,7 +153,7 @@ if __name__ == "__main__":
permconf.load()
# load the main permission class
- perm = PERMS(log)
+ perm = PERMS(log, root=root)
# check permissions
changed_files = perm.check_perms(permconf, files_to_check=args)