def add_pf_user(self, pf, name): pe = PasswdEntry() pe.user(name) pe.crypt(self.user_crypt_credentials(name)) pe.uid(TestCase._tmp_id) pe.gid(TestCase._tmp_id*10) TestCase._tmp_id += 1 pe.directory(os.path.join(os.environ['TMP_DIR'],name)) pe.shell('/bin/sh') pf[pe.user()] = pe return
def _update_superuser(username, directory='/root', shell='/sbin/nologin', crypt=None, uid=None, gid=None): if crypt is None: crypt = '' if uid is None: uid = 0 users = PasswdFile() users.load() groups = GroupFile() groups.load() if username not in groups: group = GroupEntry() group.group(username) group.crypt("*") if gid is None: gid = users.new_uid() while gid in groups: gid = users.new_uid(gid) group.gid(gid) group.user_list((username, )) groups[username] = group groups.save() gid = groups[username].gid() if username in users: user = users[username] else: user = PasswdEntry() user.crypt(crypt) user.gid(gid) user.uid(uid) user.user(username) user.shell(shell) user.directory(directory) if crypt: user.crypt(crypt) users[username] = user users.save() user = users[username] if user.gid() != gid: user.gid(gid) users[user.user()] = user users.save() return
def _update_superuser(username, directory="/root", shell="/sbin/nologin", crypt=None, uid=None, gid=None): if crypt is None: crypt = "" if uid is None: uid = 0 users = PasswdFile() users.load() groups = GroupFile() groups.load() if username not in groups: group = GroupEntry() group.group(username) group.crypt("*") if gid is None: gid = users.new_uid() while gid in groups: gid = users.new_uid(gid) group.gid(gid) group.user_list((username,)) groups[username] = group groups.save() gid = groups[username].gid() if username in users: user = users[username] else: user = PasswdEntry() user.crypt(crypt) user.gid(gid) user.uid(uid) user.user(username) user.shell(shell) user.directory(directory) if crypt: user.crypt(crypt) users[username] = user users.save() user = users[username] if user.gid() != gid: user.gid(gid) users[user.user()] = user users.save() return