Use gpasswd instead of usermod

usermod also calls checkfn, which freaks out when root
password has expired. gpasswd does exactly what we want and
nothing more.
This commit is contained in:
yuvipanda
2018-07-03 17:34:57 -07:00
parent cb26150820
commit 4c7cd6a4b5

View File

@@ -57,7 +57,7 @@ def ensure_group(groupname):
def remove_group(groupname): def remove_group(groupname):
""" """
Remove user from system if exists Remove group from system if exists
""" """
try: try:
grp.getgrnam(groupname) grp.getgrnam(groupname)
@@ -83,11 +83,10 @@ def ensure_user_group(username, groupname):
return return
subprocess.check_call([ subprocess.check_call([
'usermod', 'gpasswd',
'--append', '--add',
'--groups', username,
groupname, groupname
username
]) ])
@@ -100,8 +99,8 @@ def remove_user_group(username, groupname):
return return
subprocess.check_call([ subprocess.check_call([
'deluser', 'gpasswd',
'--quiet', '--delete',
username, username,
groupname groupname
]) ])