diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/msec/config.py | 2 | ||||
-rwxr-xr-x | src/msec/libmsec.py | 12 | ||||
-rwxr-xr-x | src/msec/msec.py | 9 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/msec/config.py b/src/msec/config.py index cdf017c..843e21b 100644 --- a/src/msec/config.py +++ b/src/msec/config.py @@ -105,7 +105,7 @@ SETTINGS = {'BASE_LEVEL': ("libmsec.base_level", # password stuff 'ENABLE_PASSWORD': ("libmsec.enable_password", ['yes', 'no']), 'PASSWORD_HISTORY': ("libmsec.password_history", ['*']), - # format: min length, num upper, num digits + # format: min length, num upper, num digits 'PASSWORD_LENGTH': ("libmsec.password_length", ['*']), 'SHELL_HISTORY_SIZE': ("libmsec.set_shell_history_size", ['*']), 'SHELL_TIMEOUT': ("libmsec.set_shell_timeout", ['*']), diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py index b1448a8..61aaa52 100755 --- a/src/msec/libmsec.py +++ b/src/msec/libmsec.py @@ -272,12 +272,13 @@ class Log: class ConfigFiles: """This class is responsible to store references to all configuration files, mark them as changed, and update on disk when necessary""" - def __init__(self, log): + def __init__(self, log, root=''): """Initializes list of ConfigFiles""" self.files = {} self.modified_files = [] self.action_assoc = [] self.log = log + self.root = root def add(self, file, path): """Appends a path to list of files""" @@ -293,7 +294,7 @@ class ConfigFiles: try: return self.files[path] except KeyError: - return ConfigFile(path, self, self.log, suffix=suffix) + return ConfigFile(path, self, self.log, suffix=suffix, root=self.root) def add_config_assoc(self, regex, action): """Adds association between a file and an action""" @@ -706,11 +707,12 @@ class ConfigFile: # {{{ MSEC - main class class MSEC: """Main msec class. Contains all functions and performs the actions""" - def __init__(self, log): + def __init__(self, log, root=''): """Initializes config files and associations""" # all config files self.log = log - self.configfiles = ConfigFiles(log) + self.root = root + self.configfiles = ConfigFiles(log, root=root) # associate helper commands with files self.configfiles.add_config_assoc(INITTAB, '/sbin/telinit q') @@ -727,7 +729,7 @@ class MSEC: def reset(self): """Resets the configuration""" self.log.debug("Resetting msec data.") - self.configfiles = ConfigFiles(self.log) + self.configfiles = ConfigFiles(self.log, root=self.root) def get_action(self, name): """Determines correspondent function for requested action.""" diff --git a/src/msec/msec.py b/src/msec/msec.py index f86152b..88fd8ba 100755 --- a/src/msec/msec.py +++ b/src/msec/msec.py @@ -52,6 +52,7 @@ Arguments to msec: -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 # }}} @@ -60,10 +61,11 @@ if __name__ == "__main__": force_level = False log_level = logging.INFO commit = True + root = '' # parse command line try: - opt, args = getopt.getopt(sys.argv[1:], 'hl:f:dp', ['help', 'list=', 'force=', 'debug', 'pretend']) + opt, args = getopt.getopt(sys.argv[1:], 'hl:f:dpr:', ['help', 'list=', 'force=', 'debug', 'pretend', 'root=']) except getopt.error: usage() sys.exit(1) @@ -88,6 +90,9 @@ if __name__ == "__main__": elif o[0] == '-f' or o[0] == '--force': level = o[1] force_level = True + # custom root + elif o[0] == '-r' or o[0] == '--root': + root = o[1] # debugging elif o[0] == '-d' or o[0] == '--debug': log_level = logging.DEBUG @@ -130,7 +135,7 @@ if __name__ == "__main__": msec_config.load() # load the msec library - msec = MSEC(log) + msec = MSEC(log, root=root) # apply the config to msec msec.apply(msec_config) |