def _add_project_user_aux1(self, user, raw_passwd, project): acl_file = '/var/tmp/%d' % int(time.time()) if os.path.exists(acl_file): os.unlink(acl_file) f = UserList() f.load_file(acl_file, True) f.update_raw(user, raw_passwd) f.save() cmd = ("%s/proj-admin au %s --acl %s" % (self.HGSCRIPT, project, acl_file)) out = pm_utils.run(cmd) os.unlink(acl_file) return out
def _change_password(self, req, user): '''Change user password.''' self._check_post(req) self._check_name(req, 'pwd1', 'No password.') self._check_name(req, 'pwd2', 'No password.') pwd1 = req.args['pwd1'] pwd2 = req.args['pwd2'] if pwd1 != pwd2: raise PMGeneralError('Two passwords do not match.') ul = UserList() ul.load_file(self.GLOBAL_ACL) if not ul.has_user(user): raise PMGeneralError("User %s does not exist." % user) ul.update(user, pwd1) raw_passwd = ul.password(user) ul.save() u2 = UserList() for p in self._foreach_project(): ul.load_project(self._mainpage, p) if ul.has_user(user): ul.update_raw(user, raw_passwd) ul.save() for m in os.listdir(self.PROJROOT + "/" + p): self.log.debug("checking module " + m) if m in self.HIDDEN_DIRS: continue u2.load_module(self._mainpage, p, m) if u2.has_user(user): u2.update_raw(user, raw_passwd) u2.save() data = {'pm_href' : req.href.pmmm(), 'pm_user' : user} return 'pm_user_done.html', data, None