Commit fc72be36 authored by Richard Darst's avatar Richard Darst

Update group handling: set primary gid, leave suplemental with group users

- If NB_GID is set, it is likely that files created should have NB_GID
  as their gid (if it doesn't matter, then this change is irrelevant.
  If it does matter, the liklihood that 100 matches with what the user
  wants is low).
- When NB_GID is set, create a new group with that gid.  Then, set
  this as the primary gid of the user.  Set the user's supplemental
  gids to NB_GID,100.
parent 8d22c86e
...@@ -70,11 +70,12 @@ if [ $(id -u) == 0 ] ; then ...@@ -70,11 +70,12 @@ if [ $(id -u) == 0 ] ; then
usermod -u $NB_UID $NB_USER usermod -u $NB_UID $NB_USER
fi fi
# Add NB_USER to NB_GID if it's not the default group # Set NB_USER primary gid to NB_GID (after making the group). Set
# supplementary gids to NB_GID and 100.
if [ "$NB_GID" != $(id -g $NB_USER) ] ; then if [ "$NB_GID" != $(id -g $NB_USER) ] ; then
echo "Add $NB_USER to group: $NB_GID" echo "Add $NB_USER to group: $NB_GID"
groupadd -g $NB_GID -o $NB_USER groupadd -g $NB_GID -o ${NB_GROUP:-${NB_USER}}
usermod -a -G $NB_GID $NB_USER usermod -g $NB_GID -a -G $NB_GID,100 $NB_USER
fi fi
# Enable sudo if requested # Enable sudo if requested
......
...@@ -57,8 +57,8 @@ def test_gid_change(container): ...@@ -57,8 +57,8 @@ def test_gid_change(container):
) )
c.wait(timeout=10) c.wait(timeout=10)
logs = c.logs(stdout=True).decode('utf-8') logs = c.logs(stdout=True).decode('utf-8')
assert 'gid=100(users)' in logs assert 'gid=110(jovyan)' in logs
assert 'groups=100(users),110(jovyan)' in logs assert 'groups=110(jovyan),100(users)' in logs
def test_sudo(container): def test_sudo(container):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment