mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 18:14:10 +00:00
Added support for consistent UIDs at user creation time
This commit is contained in:
@@ -660,6 +660,15 @@ class LocalAuthenticator(Authenticator):
|
||||
# This appears to be the Linux non-interactive adduser command:
|
||||
return ['adduser', '-q', '--gecos', '""', '--disabled-password']
|
||||
|
||||
uids = Dict(
|
||||
help="""
|
||||
Dictionary of uids to use at user creation time.
|
||||
This helps ensure that users created from the database
|
||||
get the same uid each time they are created
|
||||
in temporary deployments or containers.
|
||||
"""
|
||||
).tag(config=True)
|
||||
|
||||
group_whitelist = Set(
|
||||
help="""
|
||||
Whitelist all users from this UNIX group.
|
||||
@@ -762,7 +771,15 @@ class LocalAuthenticator(Authenticator):
|
||||
Tested to work on FreeBSD and Linux, at least.
|
||||
"""
|
||||
name = user.name
|
||||
cmd = [arg.replace('USERNAME', name) for arg in self.add_user_cmd] + [name]
|
||||
cmd = [arg.replace('USERNAME', name) for arg in self.add_user_cmd]
|
||||
try:
|
||||
uid = self.uids[name]
|
||||
cmd += ['--uid', '%d' % uid]
|
||||
except AttributeError:
|
||||
pass
|
||||
except KeyError:
|
||||
self.log.warning("No UID for user %s" % name)
|
||||
cmd += [name]
|
||||
self.log.info("Creating user: %s", ' '.join(map(pipes.quote, cmd)))
|
||||
p = Popen(cmd, stdout=PIPE, stderr=STDOUT)
|
||||
p.wait()
|
||||
|
Reference in New Issue
Block a user