From 7dc56ab821fb41b94f40a19b587517faa4db2e01 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Wed, 20 Mar 2019 10:41:27 +1100 Subject: [PATCH 1/3] Added logging of chown of CHOWN_EXTRA directories. Signed-off-by: Brett Randall --- base-notebook/start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/base-notebook/start.sh b/base-notebook/start.sh index b9067acd..f9002110 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -55,6 +55,7 @@ if [ $(id -u) == 0 ] ; then fi if [ ! -z "$CHOWN_EXTRA" ]; then for extra_dir in $(echo $CHOWN_EXTRA | tr ',' ' '); do + echo "Changing ownership of ${extra_dir} to $NB_UID:$NB_GID" chown $CHOWN_EXTRA_OPTS $NB_UID:$NB_GID $extra_dir done fi From 2d9aa71f69f7a623b073769b43998ba0078246ce Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Wed, 20 Mar 2019 10:43:58 +1100 Subject: [PATCH 2/3] Added logging of CHOWN_HOME_OPTS and CHOWN_EXTRA_OPTS. Signed-off-by: Brett Randall --- base-notebook/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base-notebook/start.sh b/base-notebook/start.sh index f9002110..1d30ca9e 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -50,12 +50,12 @@ if [ $(id -u) == 0 ] ; then # Handle case where provisioned storage does not have the correct permissions by default # Ex: default NFS/EFS (no auto-uid/gid) if [[ "$CHOWN_HOME" == "1" || "$CHOWN_HOME" == 'yes' ]]; then - echo "Changing ownership of /home/$NB_USER to $NB_UID:$NB_GID" + echo "Changing ownership of /home/$NB_USER to $NB_UID:$NB_GID with options '${CHOWN_HOME_OPTS}'" chown $CHOWN_HOME_OPTS $NB_UID:$NB_GID /home/$NB_USER fi if [ ! -z "$CHOWN_EXTRA" ]; then for extra_dir in $(echo $CHOWN_EXTRA | tr ',' ' '); do - echo "Changing ownership of ${extra_dir} to $NB_UID:$NB_GID" + echo "Changing ownership of ${extra_dir} to $NB_UID:$NB_GID with options '${CHOWN_EXTRA_OPTS}'" chown $CHOWN_EXTRA_OPTS $NB_UID:$NB_GID $extra_dir done fi From e29f669fb835bdac6241ce5c9afd2f6380203d36 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Wed, 20 Mar 2019 11:17:59 +1100 Subject: [PATCH 3/3] Added CHOWN_EXTRA test. Signed-off-by: Brett Randall --- base-notebook/test/test_container_options.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/base-notebook/test/test_container_options.py b/base-notebook/test/test_container_options.py index 451074c8..1fccc926 100644 --- a/base-notebook/test/test_container_options.py +++ b/base-notebook/test/test_container_options.py @@ -61,6 +61,23 @@ def test_gid_change(container): assert 'groups=110(jovyan),100(users)' in logs +def test_chown_extra(container): + """Container should change the UID/GID of CHOWN_EXTRA.""" + c = container.run( + tty=True, + user='root', + environment=['NB_UID=1010', + 'NB_GID=101', + 'CHOWN_EXTRA=/opt/conda', + 'CHOWN_EXTRA_OPTS=-R', + ], + command=['start.sh', 'bash', '-c', 'stat -c \'%n:%u:%g\' /opt/conda/LICENSE.txt'] + ) + # chown is slow so give it some time + c.wait(timeout=120) + assert '/opt/conda/LICENSE.txt:1010:101' in c.logs(stdout=True).decode('utf-8') + + def test_sudo(container): """Container should grant passwordless sudo to the default user.""" c = container.run(