aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2009-02-05 21:22:15 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2009-02-05 21:22:15 +0000
commit24476593032c29876d64d5690848fb62b684411f (patch)
tree8f71c1797d3c196c7a648663e427cb82dfef46fb /src
parent1c15c696a048aee1632917e76d336ccc3e1030a8 (diff)
downloadmsec-24476593032c29876d64d5690848fb62b684411f.tar
msec-24476593032c29876d64d5690848fb62b684411f.tar.gz
msec-24476593032c29876d64d5690848fb62b684411f.tar.bz2
msec-24476593032c29876d64d5690848fb62b684411f.tar.xz
msec-24476593032c29876d64d5690848fb62b684411f.zip
Support for getting config and logging from a different root.
Diffstat (limited to 'src')
-rw-r--r--src/msec/config.py12
-rwxr-xr-xsrc/msec/msec.py8
-rwxr-xr-xsrc/msec/msecperms.py8
3 files changed, 14 insertions, 14 deletions
diff --git a/src/msec/config.py b/src/msec/config.py
index 9d055f9..c6df685 100644
--- a/src/msec/config.py
+++ b/src/msec/config.py
@@ -22,14 +22,14 @@ import os
NONE_LEVEL="none"
STANDARD_LEVEL="standard"
SECURE_LEVEL="secure"
-SECURITY_LEVEL="/etc/security/msec/level.%s"
+SECURITY_LEVEL="%s/etc/security/msec/level.%s"
# msec configuration file
SECURITYCONF = '/etc/security/msec/security.conf'
# permissions
PERMCONF = '/etc/security/msec/perms.conf'
-PERMISSIONS_LEVEL = '/etc/security/msec/perm.%s' # for level
+PERMISSIONS_LEVEL = '%s/etc/security/msec/perm.%s' # for level
# logging
SECURITYLOG = '/var/log/msec.log'
@@ -163,19 +163,19 @@ def find_valid_params(param):
return valid_params
# helper functions
-def load_defaults(log, level):
+def load_defaults(log, level, root=''):
"""Loads default configuration for given security level, returning a
MsecConfig instance.
"""
- config = MsecConfig(log, config=SECURITY_LEVEL % level)
+ config = MsecConfig(log, config=SECURITY_LEVEL % (root, level))
config.load()
return config
-def load_default_perms(log, level):
+def load_default_perms(log, level, root=''):
"""Loads default permissions for given security level, returning a
MsecConfig instance.
"""
- config = PermConfig(log, config=PERMISSIONS_LEVEL % level)
+ config = PermConfig(log, config=PERMISSIONS_LEVEL % (root, level))
config.load()
return config
diff --git a/src/msec/msec.py b/src/msec/msec.py
index 88fd8ba..ef93281 100755
--- a/src/msec/msec.py
+++ b/src/msec/msec.py
@@ -111,19 +111,19 @@ if __name__ == "__main__":
interactive = sys.stdin.isatty()
if interactive:
# logs to file and to terminal
- log = Log(log_path=config.SECURITYLOG, interactive=True, log_syslog=False, log_level=log_level)
+ log = Log(log_path="%s%s" % (root, config.SECURITYLOG), interactive=True, log_syslog=False, log_level=log_level)
else:
# TODO: review logging messages
#log_level = logging.WARN
- log = Log(log_path=config.SECURITYLOG, interactive=False, log_syslog=False, log_level=log_level)
+ log = Log(log_path="%s%s" % (root, config.SECURITYLOG), interactive=False, log_syslog=False, log_level=log_level)
# loading initial config
- msec_config = config.MsecConfig(log, config=config.SECURITYCONF)
+ msec_config = config.MsecConfig(log, config="%s%s" % (root, config.SECURITYCONF))
# forcing new level
if force_level:
# first load the default configuration for level
- levelconf = config.load_defaults(log, level)
+ levelconf = config.load_defaults(log, level, root=root)
params = levelconf.list_options()
if not params:
log.error(_("Level '%s' not found, aborting.") % level)
diff --git a/src/msec/msecperms.py b/src/msec/msecperms.py
index e4ebc58..f6744ea 100755
--- a/src/msec/msecperms.py
+++ b/src/msec/msecperms.py
@@ -130,18 +130,18 @@ if __name__ == "__main__":
interactive = sys.stdin.isatty()
if interactive:
# logs to file and to terminal
- log = Log(log_path=config.SECURITYLOG, interactive=True, log_syslog=False, log_level=log_level)
+ log = Log(log_path="%s%s" % (root, config.SECURITYLOG), interactive=True, log_syslog=False, log_level=log_level)
else:
log_level = logging.WARN
- log = Log(log_path=config.SECURITYLOG, interactive=True, log_syslog=False, log_level=log_level)
+ log = Log(log_path="%s%s" % (root, config.SECURITYLOG), interactive=True, log_syslog=False, log_level=log_level)
# loading permissions
- permconf = config.PermConfig(log, config=config.PERMCONF)
+ permconf = config.PermConfig(log, config="%s%s" % (root, config.PERMCONF))
# forcing new level
if force_level:
# first load the default configuration for level
- standard_permconf = config.load_default_perms(log, level)
+ standard_permconf = config.load_default_perms(log, level, root=root)
params = standard_permconf.list_options()
if not params:
log.error(_("Level '%s' not found, aborting.") % level)