Skip to content

Commit 185a9f7

Browse files
authored
Merge pull request #833 from javabrett/chown-logging-and-tests
chown: add logging and a test
2 parents 0d96d93 + e29f669 commit 185a9f7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

base-notebook/start.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ if [ $(id -u) == 0 ] ; then
5050
# Handle case where provisioned storage does not have the correct permissions by default
5151
# Ex: default NFS/EFS (no auto-uid/gid)
5252
if [[ "$CHOWN_HOME" == "1" || "$CHOWN_HOME" == 'yes' ]]; then
53-
echo "Changing ownership of /home/$NB_USER to $NB_UID:$NB_GID"
53+
echo "Changing ownership of /home/$NB_USER to $NB_UID:$NB_GID with options '${CHOWN_HOME_OPTS}'"
5454
chown $CHOWN_HOME_OPTS $NB_UID:$NB_GID /home/$NB_USER
5555
fi
5656
if [ ! -z "$CHOWN_EXTRA" ]; then
5757
for extra_dir in $(echo $CHOWN_EXTRA | tr ',' ' '); do
58+
echo "Changing ownership of ${extra_dir} to $NB_UID:$NB_GID with options '${CHOWN_EXTRA_OPTS}'"
5859
chown $CHOWN_EXTRA_OPTS $NB_UID:$NB_GID $extra_dir
5960
done
6061
fi

base-notebook/test/test_container_options.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ def test_gid_change(container):
6161
assert 'groups=110(jovyan),100(users)' in logs
6262

6363

64+
def test_chown_extra(container):
65+
"""Container should change the UID/GID of CHOWN_EXTRA."""
66+
c = container.run(
67+
tty=True,
68+
user='root',
69+
environment=['NB_UID=1010',
70+
'NB_GID=101',
71+
'CHOWN_EXTRA=/opt/conda',
72+
'CHOWN_EXTRA_OPTS=-R',
73+
],
74+
command=['start.sh', 'bash', '-c', 'stat -c \'%n:%u:%g\' /opt/conda/LICENSE.txt']
75+
)
76+
# chown is slow so give it some time
77+
c.wait(timeout=120)
78+
assert '/opt/conda/LICENSE.txt:1010:101' in c.logs(stdout=True).decode('utf-8')
79+
80+
6481
def test_sudo(container):
6582
"""Container should grant passwordless sudo to the default user."""
6683
c = container.run(

0 commit comments

Comments
 (0)