mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
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!
This commit is contained in:
16
tljh/user.py
16
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
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user