From e17475f0237576c3b581daa7b8df1e48adfce8e9 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 2 May 2021 11:28:28 +0200 Subject: login: T1948: use long options when calling adduser ... just to make it easier for users to read the commandline. --- src/conf_mode/system-login.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/conf_mode/system-login.py b/src/conf_mode/system-login.py index c8b81d80a..da0fc2a25 100755 --- a/src/conf_mode/system-login.py +++ b/src/conf_mode/system-login.py @@ -209,27 +209,27 @@ def apply(login): for user, user_config in login['user'].items(): # make new user using vyatta shell and make home directory (-m), # default group of 100 (users) - command = 'useradd -m -N' + command = 'useradd --create-home --no-user-group' # check if user already exists: if user in get_local_users(): # update existing account command = 'usermod' # all accounts use /bin/vbash - command += ' -s /bin/vbash' + command += ' --shell /bin/vbash' # we need to use '' quotes when passing formatted data to the shell # else it will not work as some data parts are lost in translation tmp = dict_search('authentication.encrypted_password', user_config) - if tmp: command += f" -p '{tmp}'" + if tmp: command += f" --password '{tmp}'" tmp = dict_search('full_name', user_config) - if tmp: command += f" -c '{tmp}'" + if tmp: command += f" --comment '{tmp}'" tmp = dict_search('home_directory', user_config) - if tmp: command += f" -d '{tmp}'" - else: command += f" -d '/home/{user}'" + if tmp: command += f" --home '{tmp}'" + else: command += f" --home '/home/{user}'" - command += f' -G frrvty,vyattacfg,sudo,adm,dip,disk {user}' + command += f' --groups frrvty,vyattacfg,sudo,adm,dip,disk {user}' try: cmd(command) @@ -254,7 +254,7 @@ def apply(login): call(f'pkill -HUP -u {user}') # Remove user account but leave home directory to be safe - call(f'userdel -r {user}', stderr=DEVNULL) + call(f'userdel --remove {user}', stderr=DEVNULL) except Exception as e: raise ConfigError(f'Deleting user "{user}" raised exception: {e}') -- cgit v1.2.3