def on_submit(self, event, params, vars=None): if params[0] == 'dlgAddUser': if vars.getvalue('action', '') == 'OK': self.app.gconfig.set('users', vars.getvalue('login', ''), hashpw(vars.getvalue('password', ''))) self.app.gconfig.save() self._adding_user = False if params[0] == 'frmGeneral': if vars.getvalue('action', '') == 'OK': if self.app.gconfig.get('netcontrol', 'bind_host', '') != vars.getvalue('bind_host', ''): self._changed = True if self.app.gconfig.get('netcontrol', 'bind_port', '') != vars.getvalue('bind_port', ''): self._changed = True if self.app.gconfig.get('netcontrol', 'ssl', '') != vars.getvalue('ssl', ''): self._changed = True self.app.gconfig.set('netcontrol', 'bind_host', vars.getvalue('bind_host', '')) self.app.gconfig.set('netcontrol', 'bind_port', vars.getvalue('bind_port', '8000')) self.app.gconfig.set('netcontrol', 'ssl', vars.getvalue('ssl', '0')) self.app.gconfig.set('netcontrol', 'cert_file', vars.getvalue('cert_file', '')) self.app.gconfig.set('netcontrol', 'cert_key', vars.getvalue('cert_key', '')) self.app.gconfig.set('netcontrol', 'auth_enabled', vars.getvalue('httpauth', '0')) self.app.gconfig.save() self.put_message('info', 'Saved') if params[0] == 'dlgEditModuleConfig': if vars.getvalue('action','') == 'OK': cfg = self.app.get_config_by_classname(self._config) cfg.apply_vars(vars) cfg.save() self._config = None
def reconfigure(cfg): if not os.path.exists(RCFG_FILE): return rcfg = ConfigParser() rcfg.read(RCFG_FILE) if rcfg.has_option('netcontrol', 'credentials'): u, p = rcfg.get('netcontrol', 'credentials').split(':') cfg.remove_option('users', 'admin') if not p.startswith('{SHA}'): p = hashpw(p) cfg.set('users', u, p) if rcfg.has_option('netcontrol', 'plugins'): for x in rcfg.get('netcontrol', 'plugins').split(): shell('netcontrol-pkg get ' + x) if rcfg.has_option('netcontrol', 'ssl'): c, k = rcfg.get('netcontrol', 'ssl').split() cfg.set('ssl', '1') cfg.set('cert_key', k) cfg.set('cert_file', c) if rcfg.has_option('netcontrol', 'port'): cfg.set('netcontrol', 'bind_port', rcfg.get('netcontrol', 'port')) if rcfg.has_option('netcontrol', 'host'): cfg.set('netcontrol', 'bind_host', rcfg.get('netcontrol', 'host')) cfg.set('netcontrol', 'firstrun', 'no') cfg.save() os.unlink(RCFG_FILE)
def reconfigure(cfg): if not os.path.exists(RCFG_FILE): return rcfg = ConfigParser() rcfg.read(RCFG_FILE) if rcfg.has_option("netcontrol", "credentials"): u, p = rcfg.get("netcontrol", "credentials").split(":") cfg.remove_option("users", "admin") if not p.startswith("{SHA}"): p = hashpw(p) cfg.set("users", u, p) if rcfg.has_option("netcontrol", "plugins"): for x in rcfg.get("netcontrol", "plugins").split(): shell("netcontrol-pkg get " + x) if rcfg.has_option("netcontrol", "ssl"): c, k = rcfg.get("netcontrol", "ssl").split() cfg.set("ssl", "1") cfg.set("cert_key", k) cfg.set("cert_file", c) if rcfg.has_option("netcontrol", "port"): cfg.set("netcontrol", "bind_port", rcfg.get("netcontrol", "port")) if rcfg.has_option("netcontrol", "host"): cfg.set("netcontrol", "bind_host", rcfg.get("netcontrol", "host")) cfg.set("netcontrol", "firstrun", "no") cfg.save() os.unlink(RCFG_FILE)
def on_submit(self, event, params, vars=None): if params[0] == 'dlgAddUser': if vars.getvalue('action', '') == 'OK': self.app.gconfig.set('users', vars.getvalue('login', ''), hashpw(vars.getvalue('password', ''))) self.app.gconfig.save() self._adding_user = False if params[0] == 'frmGeneral': if vars.getvalue('action', '') == 'OK': if self.app.gconfig.get('netcontrol', 'bind_host', '') != vars.getvalue('bind_host', ''): self._changed = True if self.app.gconfig.get('netcontrol', 'bind_port', '') != vars.getvalue('bind_port', ''): self._changed = True if self.app.gconfig.get('netcontrol', 'ssl', '') != vars.getvalue('ssl', ''): self._changed = True self.app.gconfig.set('netcontrol', 'bind_host', vars.getvalue('bind_host', '')) self.app.gconfig.set('netcontrol', 'bind_port', vars.getvalue('bind_port', '8000')) self.app.gconfig.set('netcontrol', 'ssl', vars.getvalue('ssl', '0')) self.app.gconfig.set('netcontrol', 'cert_file', vars.getvalue('cert_file', '')) self.app.gconfig.set('netcontrol', 'cert_key', vars.getvalue('cert_key', '')) self.app.gconfig.set('netcontrol', 'auth_enabled', vars.getvalue('httpauth', '0')) self.app.gconfig.save() self.put_message('info', 'Saved') if params[0] == 'dlgEditModuleConfig': if vars.getvalue('action', '') == 'OK': cfg = self.app.get_config_by_classname(self._config) cfg.apply_vars(vars) cfg.save() self._config = None