diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-02-05 19:32:55 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-02-05 19:35:27 +0100 |
commit | 0d88ad9642ccf0b8780c063a3a77cac74dd0ee0d (patch) | |
tree | 031a1b7b1de914c7493d7b69137e624dbdf1cb56 /src | |
parent | 3a64047c2f1b6279de4b1ada7e87aa5c871f5604 (diff) | |
download | vyos-1x-0d88ad9642ccf0b8780c063a3a77cac74dd0ee0d.tar.gz vyos-1x-0d88ad9642ccf0b8780c063a3a77cac74dd0ee0d.zip |
user: T1948: fix system user creation
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/system-login-user.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/conf_mode/system-login-user.py b/src/conf_mode/system-login-user.py index 3317f87d8..a9e194859 100755 --- a/src/conf_mode/system-login-user.py +++ b/src/conf_mode/system-login-user.py @@ -118,6 +118,7 @@ def get_config(): return login def verify(login): + # TODO: should we be able to delete ourself? pass def generate(login): @@ -156,16 +157,16 @@ def apply(login): cmd = "usermod" # encrypted password must be quited in '' else it won't work! - cmd += " -p '{}'".format(user['password_encrypted']) - cmd += " -s /bin/vbash" + cmd += ' -p "{}"'.format(user['password_encrypted']) + cmd += ' -s /bin/vbash' if user['full_name']: - cmd += " -c {}".format(user['full_name']) + cmd += ' -c "{}"'.format(user['full_name']) if user['home_dir']: - cmd += " -d '{}'".format(user['home_dir']) + cmd += ' -d "{}"'.format(user['home_dir']) - cmd += " -G frrvty,vyattacfg,sudo,adm,dip,disk" - cmd += " {}".format(user['name']) + cmd += ' -G frrvty,vyattacfg,sudo,adm,dip,disk' + cmd += ' {}'.format(user['name']) try: os.system(cmd) @@ -197,10 +198,11 @@ def apply(login): os.chmod(key_file, S_IRUSR | S_IWUSR) except Exception as e: - print('Adding user "{}" raised an exception'.format(user)) + print('Adding user "{}" raised an exception: {}'.format(user['name'], e)) for user in login['del_users']: try: + # TODO: check if user is logged in and force logout # Remove user account but leave home directory to be safe os.system('userdel {}'.format(user)) except Exception as e: |