Fix in add_user
This commit is contained in:
parent
d4009d8f09
commit
92cab96c85
1 changed files with 10 additions and 9 deletions
|
|
@ -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:
|
if call(func_user, shell=True, stdout=DEVNULL) > 0:
|
||||||
|
|
||||||
return (True, '')
|
return (False, 'Error executing useradd command')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return (False, 'Error executing useradd command')
|
|
||||||
|
return (True, '')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def change_password(user, new_password):
|
def change_password(user, new_password):
|
||||||
|
|
@ -58,10 +60,12 @@ def change_password(user, new_password):
|
||||||
|
|
||||||
if call("sudo echo \"%s:%s\" | sudo chpasswd" % (user, new_password), shell=True, stdout=DEVNULL) > 0:
|
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?')
|
return (False, 'I cannot change password, permissions?')
|
||||||
|
|
||||||
|
else:
|
||||||
|
return (True, 'Change password successfully')
|
||||||
|
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
||||||
return (False, 'I cannot change password, user exists?')
|
return (False, 'I cannot change password, user exists?')
|
||||||
|
|
@ -69,10 +73,7 @@ def change_password(user, new_password):
|
||||||
def del_user(user):
|
def del_user(user):
|
||||||
|
|
||||||
if call("sudo userdel -r %s" % user, shell=True, stdout=DEVNULL, stderr=DEVNULL) > 0:
|
if call("sudo userdel -r %s" % user, shell=True, stdout=DEVNULL, stderr=DEVNULL) > 0:
|
||||||
|
return (False, '')
|
||||||
|
else:
|
||||||
return (True, 'Deleted user successfully')
|
return (True, 'Deleted user successfully')
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
return (False, '')
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue