From cb261508209b7566ac8049edfcdca404c101be74 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Tue, 3 Jul 2018 17:20:41 -0700 Subject: [PATCH] Use useradd rather than adduser to create users Better suited for scripting use. adduser also seemed to cause issues when root user's password had expired, so let's see if useradd fixes that! --- tljh/user.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tljh/user.py b/tljh/user.py index 83bfa7f..e9c9085 100644 --- a/tljh/user.py +++ b/tljh/user.py @@ -22,10 +22,7 @@ def ensure_user(username): pass subprocess.check_call([ - 'adduser', - '--disabled-password', - '--force-badname', - '--quiet', + 'useradd', username ]) @@ -51,16 +48,9 @@ def ensure_group(groupname): """ Ensure given group exists """ - try: - grp.getgrnam(groupname) - # Group exists, nothing to do! - return - except KeyError: - pass - subprocess.check_call([ - 'addgroup', - '--quiet', + 'groupadd', + '--force', groupname ])