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('genesis', 'bind_host', '') != vars.getvalue('bind_host', ''): self._changed = True if self.app.gconfig.get('genesis', 'bind_port', '') != vars.getvalue('bind_port', ''): self._changed = True if self.app.gconfig.get('genesis', 'ssl', '') != vars.getvalue('ssl', ''): self._changed = True self.app.gconfig.set('genesis', 'bind_host', vars.getvalue('bind_host', '')) self.app.gconfig.set('genesis', 'bind_port', vars.getvalue('bind_port', '8000')) self.app.gconfig.set('genesis', 'ssl', vars.getvalue('ssl', '0')) self.app.gconfig.set('genesis', 'cert_file', vars.getvalue('cert_file', '')) self.app.gconfig.set('genesis', 'cert_key', vars.getvalue('cert_key', '')) self.app.gconfig.set('genesis', 'auth_enabled', vars.getvalue('httpauth', '0')) self.app.gconfig.set('genesis', 'nofx', vars.getvalue('nofx', '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('genesis', 'credentials'): u, p = rcfg.get('genesis', 'credentials').split(':') cfg.remove_option('users', 'admin') if not p.startswith('{SHA}'): p = hashpw(p) cfg.set('users', u, p) if rcfg.has_option('genesis', 'plugins'): for x in rcfg.get('genesis', 'plugins').split(): shell('genesis-pkg get ' + x) if rcfg.has_option('genesis', 'ssl'): c, k = rcfg.get('genesis', 'ssl').split() cfg.set('ssl', '1') cfg.set('cert_key', k) cfg.set('cert_file', c) if rcfg.has_option('genesis', 'port'): cfg.set('genesis', 'bind_port', rcfg.get('genesis', 'port')) if rcfg.has_option('genesis', 'host'): cfg.set('genesis', 'bind_host', rcfg.get('genesis', 'host')) cfg.set('genesis', 'firstrun', 'no') cfg.save() os.unlink(RCFG_FILE)
def add_user(self, user, passwd): ic = [] if os.path.exists('/etc/radicale/users'): for x in open('/etc/radicale/users', 'r').read().split('\n'): ic.append(x) f = open('/etc/radicale/users', 'w') for x in ic: f.write(x + '\n') f.write('%s:%s' % (user, hashpw(passwd, 'ssha'))) f.close() try: os.makedirs('/home/radicale/.config/radicale/collections/%s' % user) os.chown('/home/radicale/.config/radicale/collections/%s' % user, pwd.getpwnam('radicale').pw_uid, grp.getgrnam('radicale').gr_gid) except os.error: pass open( os.path.join('/home/radicale/.config/radicale/collections', user, 'contacts.vcf'), 'w') os.chown( os.path.join('/home/radicale/.config/radicale/collections', user, 'contacts.vcf'), pwd.getpwnam('radicale').pw_uid, grp.getgrnam('radicale').gr_gid)
def reconfigure(cfg): if not os.path.exists(RCFG_FILE): return rcfg = ConfigParser() rcfg.read(RCFG_FILE) if rcfg.has_option('genesis', 'credentials'): u,p = rcfg.get('genesis', 'credentials').split(':') cfg.remove_option('users', 'admin') if not p.startswith('{SHA}'): p = hashpw(p) cfg.set('users', u, p) if rcfg.has_option('genesis', 'plugins'): for x in rcfg.get('genesis', 'plugins').split(): shell('genesis-pkg get ' + x) if rcfg.has_option('genesis', 'ssl'): c,k = rcfg.get('genesis', 'ssl').split() cfg.set('ssl', '1') cfg.set('cert_key', k) cfg.set('cert_file', c) if rcfg.has_option('genesis', 'port'): cfg.set('genesis', 'bind_port', rcfg.get('genesis', 'port')) if rcfg.has_option('genesis', 'host'): cfg.set('genesis', 'bind_host', rcfg.get('genesis', 'host')) cfg.set('genesis', 'firstrun', 'no') cfg.save() os.unlink(RCFG_FILE)
def add_user(self, user, passwd): ic = [] if os.path.exists('/etc/radicale/users'): for x in open('/etc/radicale/users', 'r').read().split('\n'): ic.append(x) f = open('/etc/radicale/users', 'w') for x in ic: f.write(x+'\n') f.write('%s:%s'%(user, hashpw(passwd, 'ssha'))) f.close()
def add_user(self, user, passwd): ic = [] if os.path.exists('/etc/radicale/users'): for x in open('/etc/radicale/users', 'r').read().split('\n'): ic.append(x) f = open('/etc/radicale/users', 'w') for x in ic: f.write(x + '\n') f.write('%s:%s' % (user, hashpw(passwd, 'ssha'))) f.close()
def add_user(self, user, passwd): ic = [] if os.path.exists('/etc/radicale/users'): for x in open('/etc/radicale/users', 'r').read().split('\n'): ic.append(x) f = open('/etc/radicale/users', 'w') for x in ic: f.write(x+'\n') f.write('%s:%s'%(user, hashpw(passwd, 'ssha'))) f.close() try: os.makedirs('/home/radicale/.config/radicale/collections/%s' % user) os.chown('/home/radicale/.config/radicale/collections/%s' % user, pwd.getpwnam('radicale').pw_uid, grp.getgrnam('radicale').gr_gid) except os.error: pass open(os.path.join('/home/radicale/.config/radicale/collections', user, 'contacts.vcf'), 'w') os.chown(os.path.join('/home/radicale/.config/radicale/collections', user, 'contacts.vcf'), pwd.getpwnam('radicale').pw_uid, grp.getgrnam('radicale').gr_gid)