From db8b644bb8af35997079f1fe5a00b46207c54514 Mon Sep 17 00:00:00 2001 From: Eugeni Dodonov Date: Fri, 2 Oct 2009 16:02:35 +0000 Subject: Correctly saving new levels. --- src/msec/config.py | 8 ++++++++ src/msec/msec.py | 2 +- src/msec/msecperms.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/msec/config.py b/src/msec/config.py index e928ab4..9561300 100644 --- a/src/msec/config.py +++ b/src/msec/config.py @@ -334,6 +334,14 @@ class PermConfig(MsecConfig): self.log = log self.regexp = re.compile("^([^\s]*)\s*([a-z]*)\.([a-z]*)\s*([\d]?\d\d\d|current)\s*(force)?$") + def merge(self, newconfig, overwrite=False): + """Merges parameters from newconfig to current config""" + for opt in newconfig.list_options(): + if overwrite: + self.set(opt, newconfig.get(opt)) + else: + self.get(opt, newconfig.get(opt)) + def reset(self): MsecConfig.reset(self) del self.options_order diff --git a/src/msec/msec.py b/src/msec/msec.py index 0bb43a6..879ec19 100755 --- a/src/msec/msec.py +++ b/src/msec/msec.py @@ -147,7 +147,7 @@ if __name__ == "__main__": # saving current setting as new level if save: newlevel = config.MsecConfig(log, config=config.SECURITY_LEVEL % (root, level)) - newlevel.merge(msec_config) + newlevel.merge(permconf, overwrite=True) # update new level name newlevel.set("BASE_LEVEL", level) newlevel.save() diff --git a/src/msec/msecperms.py b/src/msec/msecperms.py index cdb9b0e..f07b745 100755 --- a/src/msec/msecperms.py +++ b/src/msec/msecperms.py @@ -164,8 +164,8 @@ if __name__ == "__main__": # saving current setting as new level if save: - newlevel = config.MsecConfig(log, config=config.SECURITY_LEVEL % (root, level)) - newlevel.merge(permconf) + newlevel = config.PermConfig(log, config=config.PERMISSIONS_LEVEL % (root, level)) + newlevel.merge(permconf, overwrite=True) newlevel.save() sys.exit(0) -- cgit v1.2.1