mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-26 00:02:19 +03:00
registration enable user
This commit is contained in:
commit
62ae30fc50
1 changed files with 17 additions and 1 deletions
|
@ -362,7 +362,6 @@ class Registration:
|
||||||
System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
||||||
|
|
||||||
def disable_local_users(self):
|
def disable_local_users(self):
|
||||||
import time
|
|
||||||
passwd_cmd = 'passwd -l {}'
|
passwd_cmd = 'passwd -l {}'
|
||||||
change_home = 'usermod -m -d {0} {1}'
|
change_home = 'usermod -m -d {0} {1}'
|
||||||
change_username = 'usermod -l {0} {1}'
|
change_username = 'usermod -l {0} {1}'
|
||||||
|
@ -504,3 +503,20 @@ class Registration:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Error while running clean command. Error Message {0}'.format(str(e)))
|
print('Error while running clean command. Error Message {0}'.format(str(e)))
|
||||||
|
|
||||||
|
def enable_local_users(self):
|
||||||
|
passwd_cmd = 'passwd -u {}'
|
||||||
|
change_home = 'usermod -m -d {0} {1}'
|
||||||
|
change_username = 'usermod -l {0} {1}'
|
||||||
|
content = self.util.read_file('/etc/passwd')
|
||||||
|
for p in pwd.getpwall():
|
||||||
|
if not sysx.shell_is_interactive(p.pw_shell):
|
||||||
|
continue
|
||||||
|
if p.pw_uid == 0:
|
||||||
|
continue
|
||||||
|
if p.pw_name in content:
|
||||||
|
new_home_dir = p.pw_dir.rstrip('-local/') + '/'
|
||||||
|
new_username = p.pw_name.rstrip('-local')
|
||||||
|
self.util.execute(passwd_cmd.format(p.pw_name))
|
||||||
|
self.util.execute(change_username.format(new_username, p.pw_name))
|
||||||
|
self.util.execute(change_home.format(new_home_dir, new_username))
|
||||||
|
self.logger.debug("User: '{0}' will be enabled and changed username and home directory of username".format(p.pw_name))
|
||||||
|
|
Loading…
Reference in a new issue