From 24476593032c29876d64d5690848fb62b684411f Mon Sep 17 00:00:00 2001 From: Eugeni Dodonov Date: Thu, 5 Feb 2009 21:22:15 +0000 Subject: Support for getting config and logging from a different root. --- src/msec/config.py | 12 ++++++------ src/msec/msec.py | 8 ++++---- src/msec/msecperms.py | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') 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) -- cgit v1.2.1