Skip to content

Commit 2df9c49

Browse files
committed
set setuid/setgid bits in fix-permissions
ensures files have the right owner:group unfortunately, not enough to get group-writable permissions (need acl or umask for that), so we still need to run it after each install
1 parent c6c1ce4 commit 2df9c49

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

base-notebook/Dockerfile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ ENV CONDA_DIR=/opt/conda \
3737
SHELL=/bin/bash \
3838
NB_USER=jovyan \
3939
NB_UID=1000 \
40-
NB_OWNER_GROUP=user-writable \
41-
NB_OWNER_GID=10000 \
40+
NB_GID=100 \
4241
LC_ALL=en_US.UTF-8 \
4342
LANG=en_US.UTF-8 \
4443
LANGUAGE=en_US.UTF-8
@@ -51,10 +50,9 @@ ADD fix-permissions /usr/local/bin/fix-permissions
5150
# files we want users to write (/home/jovyan, packages)
5251
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
5352
mkdir -p $CONDA_DIR && \
54-
chown $NB_USER $CONDA_DIR && \
55-
groupadd -g $NB_OWNER_GID $NB_OWNER_GROUP && \
56-
usermod -G $NB_OWNER_GROUP $NB_USER && \
57-
fix-permissions /home/$NB_USER
53+
chown $NB_USER:$NB_GID $CONDA_DIR && \
54+
fix-permissions $HOME && \
55+
fix-permissions $CONDA_DIR
5856

5957
USER $NB_USER
6058

@@ -65,15 +63,14 @@ RUN mkdir /home/$NB_USER/work && \
6563
# Install conda as jovyan and check the md5 sum provided on the download site
6664
ENV MINICONDA_VERSION 4.3.21
6765
RUN cd /tmp && \
68-
mkdir -p $CONDA_DIR && \
6966
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh && \
7067
echo "c1c15d3baba15bf50293ae963abef853 *Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh" | md5sum -c - && \
7168
/bin/bash Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
7269
rm Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh && \
7370
$CONDA_DIR/bin/conda config --system --prepend channels conda-forge && \
7471
$CONDA_DIR/bin/conda config --system --set auto_update_conda false && \
7572
$CONDA_DIR/bin/conda config --system --set show_channel_urls true && \
76-
$CONDA_DIR/bin/conda update --all && \
73+
$CONDA_DIR/bin/conda update --all --quiet --yes && \
7774
conda clean -tipsy && \
7875
fix-permissions $CONDA_DIR
7976

base-notebook/fix-permissions

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# set permissions on a directory
33
# after any installation, if a directory needs to be (human) user-writable,
44
# run this script on it.
5-
# It will make everything in the directory owned by the group $NB_OWNER_GROUP
5+
# It will make everything in the directory owned by the group $NB_GID
66
# and writable by that group.
77
# Deployments that want to set a specific user id can preserve permissions
88
# by adding the `--group-add user-writable` line to `docker run`.
@@ -11,17 +11,25 @@
1111
# which would cause massive image explosion
1212

1313
# right permissions are:
14-
# group=$NB_OWNER_GROUP
14+
# group=$NB_GID
1515
# AND permissions include group rwX (directory-execute)
16+
# AND directories have setuid,setgid bits set
1617

1718
set -e
1819

1920
for d in $@; do
2021
find "$d" \
2122
! \( \
22-
-group $NB_OWNER_GROUP \
23+
-group $NB_GID \
2324
-a -perm -g+rwX \
2425
\) \
25-
-exec chgrp $NB_OWNER_GROUP {} \; \
26+
-exec chgrp $NB_GID {} \; \
2627
-exec chmod g+rwX {} \;
28+
# setuid,setgid *on directories only*
29+
find "$d" \
30+
\( \
31+
-type d \
32+
-a ! -perm -6000 \
33+
\) \
34+
-exec chmod +6000 {} \;
2735
done

0 commit comments

Comments
 (0)