diff --git a/Utils/distroutils.py b/Utils/distroutils.py index 23359e5ec..be06ed2f1 100644 --- a/Utils/distroutils.py +++ b/Utils/distroutils.py @@ -13,7 +13,7 @@ def get_my_distro(config, os_name=None): if 'FreeBSD' in platform.system(): return FreeBSDDistro(config) - + if os_name is None: if os.path.isfile(constants.os_release): os_name = ext_utils.get_line_starting_with("NAME", constants.os_release) @@ -280,8 +280,8 @@ def __init__(self, config): # noinspection PyMethodOverriding - def chpasswd(self, user, password): - return ext_utils.run_send_stdin(['pw', 'usermod', 'user', '-h', '0'], password, log_cmd=False) + def chpasswd(self, user, password, **kwargs): + return ext_utils.run_send_stdin(['pw', 'usermod', 'user', '-h', '0'], password.encode('utf-8'), log_cmd=False) def create_account(self, user, password, expiration, thumbprint, enable_nopasswd): """ @@ -296,8 +296,8 @@ def create_account(self, user, password, expiration, thumbprint, enable_nopasswd pass uidmin = None try: - if os.path.isfile("/etc/login.defs"): - uidmin = int(ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1]) + if os.path.isfile("/etc/pw.conf"): + uidmin = int(ext_utils.get_line_starting_with("minuid", "/etc/pw.conf").split('=')[1].strip(' "')) except (ValueError, KeyError, AttributeError, EnvironmentError): pass pass @@ -374,9 +374,8 @@ def delete_account(self, user): return uidmin = None try: - if os.path.isfile("/etc/login.defs"): - uidmin = int( - ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1]) + if os.path.isfile("/etc/pw.conf"): + uidmin = int(ext_utils.get_line_starting_with("minuid", "/etc/pw.conf").split('=')[1].strip(' "')) except (ValueError, KeyError, AttributeError, EnvironmentError): pass if uidmin is None: @@ -554,4 +553,4 @@ def restart_ssh_service(self): retcode = ext_utils.run(ssh_restart_cmd) if retcode > 0: logger.error("Failed to restart SSH service with return code:" + str(retcode)) - return retcode \ No newline at end of file + return retcode