diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-04-15 22:20:25 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-04-15 22:20:25 +0200 |
commit | 2bdd37a165c0e85dee371cff64e995d83d8cb118 (patch) | |
tree | 1b1f7141476eee511fe1961c0bbfb55e0a08aedf /src/conf_mode | |
parent | 0c9bdca72519b6b2bd0e17b491d80b4015bef529 (diff) | |
download | vyos-1x-2bdd37a165c0e85dee371cff64e995d83d8cb118.tar.gz vyos-1x-2bdd37a165c0e85dee371cff64e995d83d8cb118.zip |
login: T2295: move from calling an os binary to Python crypt() function
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/system-login.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/conf_mode/system-login.py b/src/conf_mode/system-login.py index 6008ca0b3..91e2b369f 100755 --- a/src/conf_mode/system-login.py +++ b/src/conf_mode/system-login.py @@ -16,6 +16,7 @@ import os +from crypt import crypt, METHOD_SHA512 from psutil import users from pwd import getpwall, getpwnam from stat import S_IRUSR, S_IWUSR, S_IRWXU, S_IRGRP, S_IXGRP @@ -52,11 +53,6 @@ def get_local_users(): return local_users - -def get_crypt_pw(password): - return cmd(f'/usr/bin/mkpasswd --method=sha-512 {password}') - - def get_config(): login = default_config_data conf = Config() @@ -204,7 +200,7 @@ def generate(login): # calculate users encrypted password for user in login['add_users']: if user['password_plaintext']: - user['password_encrypted'] = get_crypt_pw(user['password_plaintext']) + user['password_encrypted'] = crypt(user['password_plaintext'], METHOD_SHA512) user['password_plaintext'] = '' # remove old plaintext password |