From 4c7cd6a4b5503341c4c4997783c114ad11e36fd1 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Tue, 3 Jul 2018 17:34:57 -0700 Subject: [PATCH] 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. --- tljh/user.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tljh/user.py b/tljh/user.py index e9c9085..51c1c7f 100644 --- a/tljh/user.py +++ b/tljh/user.py @@ -57,7 +57,7 @@ def ensure_group(groupname): def remove_group(groupname): """ - Remove user from system if exists + Remove group from system if exists """ try: grp.getgrnam(groupname) @@ -83,11 +83,10 @@ def ensure_user_group(username, groupname): return subprocess.check_call([ - 'usermod', - '--append', - '--groups', - groupname, - username + 'gpasswd', + '--add', + username, + groupname ]) @@ -100,8 +99,8 @@ def remove_user_group(username, groupname): return subprocess.check_call([ - 'deluser', - '--quiet', + 'gpasswd', + '--delete', username, groupname ])