diff options
author | Eugeni Dodonov <eugeni@mandriva.org> | 2010-01-29 14:42:31 +0000 |
---|---|---|
committer | Eugeni Dodonov <eugeni@mandriva.org> | 2010-01-29 14:42:31 +0000 |
commit | 148dc78cd3bf63dbc20ea8b4c13bf7ffc8b47745 (patch) | |
tree | 390d516b726b1b8ce66245240d566a14ca52f5e1 /src | |
parent | 72b974639ca0bd1f83761ddf3859861929239b27 (diff) | |
download | msec-148dc78cd3bf63dbc20ea8b4c13bf7ffc8b47745.tar msec-148dc78cd3bf63dbc20ea8b4c13bf7ffc8b47745.tar.gz msec-148dc78cd3bf63dbc20ea8b4c13bf7ffc8b47745.tar.bz2 msec-148dc78cd3bf63dbc20ea8b4c13bf7ffc8b47745.tar.xz msec-148dc78cd3bf63dbc20ea8b4c13bf7ffc8b47745.zip |
Properly handle base levels in msecgui and with deleted parameters.
Diffstat (limited to 'src')
-rw-r--r-- | src/msec/config.py | 7 | ||||
-rwxr-xr-x | src/msec/libmsec.py | 2 | ||||
-rwxr-xr-x | src/msec/msec.py | 8 | ||||
-rwxr-xr-x | src/msec/msecgui.py | 27 |
4 files changed, 32 insertions, 12 deletions
diff --git a/src/msec/config.py b/src/msec/config.py index 4e300a4..7669619 100644 --- a/src/msec/config.py +++ b/src/msec/config.py @@ -253,8 +253,8 @@ class MsecConfig: # TODO: integrate with remove() if value == None or value == OPTION_DISABLED: self.log.debug("Skipping %s" % option) - else: - print >>fd, "%s=%s" % (option, self.options[option]) + value="" + print >>fd, "%s=%s" % (option, value) return True # }}} @@ -446,6 +446,9 @@ class PermConfig(MsecConfig): if value == new_value: self.log.debug("Option %s=%s already on base level!" % (file, value)) continue + if not value: + # the option was removed + continue user, group, perm, force = value if force: force = "\tforce" diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py index f4e2b01..bcd7e7b 100755 --- a/src/msec/libmsec.py +++ b/src/msec/libmsec.py @@ -746,7 +746,7 @@ class MSEC: # validating parameters param = curconfig.get(opt) # if param is None, this option is to be skipped - if param == None: + if param == None or len(param) == 0: self.log.debug("Skipping %s" % opt) continue if param not in valid_params and '*' not in valid_params: diff --git a/src/msec/msec.py b/src/msec/msec.py index 3f3d489..556a082 100755 --- a/src/msec/msec.py +++ b/src/msec/msec.py @@ -156,6 +156,12 @@ if __name__ == "__main__": else: msec_config.load() + # load base levels + baselevel_name = msec_config.get_base_level() + if baselevel_name: + levelconf = config.load_defaults(log, baselevel_name, root=root) + standard_permconf = config.load_default_perms(log, baselevel_name, root=root) + # load variables from base levels config.merge_with_baselevel(log, msec_config, msec_config.get_base_level(), config.load_defaults, root='') config.merge_with_baselevel(log, permconf, msec_config.get_base_level(), config.load_default_perms, root='') @@ -181,7 +187,7 @@ if __name__ == "__main__": # writing back changes msec.commit(commit) # saving updated config - if force_level and commit: + if commit: if not msec_config.save(levelconf): log.error(_("Unable to save config!")) if not permconf.save(standard_permconf): diff --git a/src/msec/msecgui.py b/src/msec/msecgui.py index f276cf5..4260c04 100755 --- a/src/msec/msecgui.py +++ b/src/msec/msecgui.py @@ -362,13 +362,16 @@ class MsecGui: # new base level self.msecconfig.set("BASE_LEVEL", self.base_level) + levelconf = config.load_defaults(log, self.base_level) + standard_permconf = config.load_default_perms(log, self.base_level) + # saving the configuration - self.msecconfig.save() + self.msecconfig.save(levelconf) self.msec.apply(self.msecconfig) self.msec.commit(True) # saving permissions - self.permconfig.save() + self.permconfig.save(standard_permconf) self.reload_config() @@ -379,9 +382,11 @@ class MsecGui: # msecconfig self.msecconfig.reset() self.msecconfig.load() + config.merge_with_baselevel(log, self.msecconfig, self.msecconfig.get_base_level(), config.load_defaults, root='') # permconfig self.permconfig.reset() self.permconfig.load() + config.merge_with_baselevel(log, self.permconfig, self.msecconfig.get_base_level(), config.load_default_perms, root='') # exceptions self.exceptions.reset() self.exceptions.load() @@ -664,6 +669,9 @@ class MsecGui: iter = options.iter_next(iter) elif curconfig.__class__ == config.PermConfig: # Use should enforce it in the Permission tab + print options + print self.base_level + self.reset_permissions(None, options, level=level) pass else: #print curconfig.__class__ @@ -930,10 +938,10 @@ class MsecGui: # button.connect('clicked', self.move_rule_up, lstore) # hbox.pack_start(button, False) - # default - button = gtk.Button(_("Reset to default level permissions")) - button.connect('clicked', self.reset_permissions, lstore) - hbox.pack_start(button, False) + # # default + # button = gtk.Button(_("Reset to default level permissions")) + # button.connect('clicked', self.reset_permissions, lstore) + # hbox.pack_start(button, False) # add button = gtk.Button(_("Add a rule")) @@ -954,11 +962,14 @@ class MsecGui: return vbox - def reset_permissions(self, widget, model): + def reset_permissions(self, widget, model, level=None): """Reset permissions to default specified by level""" model.clear() self.permconfig.reset() - defperms = self.perm_defaults[self.base_level] + if not level: + defperms = self.perm_defaults[self.base_level] + else: + defperms = self.perm_defaults[level] for file in defperms.list_options(): user_s, group_s, perm_s, force_s = defperms.get(file) |