Fix in add_user

This commit is contained in:
absurdo 2023-07-30 22:58:25 +02:00
parent d4009d8f09
commit 92cab96c85

View file

@ -45,10 +45,12 @@ def add_user(user, password='', group='', user_directory='', shell='/usr/sbin/no
if call(func_user, shell=True, stdout=DEVNULL) > 0:
return (True, '')
return (False, 'Error executing useradd command')
else:
return (False, 'Error executing useradd command')
return (True, '')
def change_password(user, new_password):
@ -58,9 +60,11 @@ def change_password(user, new_password):
if call("sudo echo \"%s:%s\" | sudo chpasswd" % (user, new_password), shell=True, stdout=DEVNULL) > 0:
return (True, 'Change password successfully')
else:
return (False, 'I cannot change password, permissions?')
else:
return (True, 'Change password successfully')
except KeyError:
@ -69,10 +73,7 @@ def change_password(user, new_password):
def del_user(user):
if call("sudo userdel -r %s" % user, shell=True, stdout=DEVNULL, stderr=DEVNULL) > 0:
return (True, 'Deleted user successfully')
else:
return (False, '')
else:
return (True, 'Deleted user successfully')