From b4d2d6f58308374dabb5f57102c1c45eb0dc6d81 Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Wed, 31 Jan 2018 08:51:52 -0500 Subject: [PATCH 1/2] Support provisioned storage with incorrect permissions I ran into an issue when trying to get this to work with a NFS server which I did not have direct control over (EFS). As part of the PersistentVolumeClaim, there is no easy way to set the UID and GID of the created directory.on the networked FS. My only concern with this chown is that some user out there might be running jupyterhub in an odd configuration where $NB_USER is not supposed to have these exact permissions on the storage. I think this is quite unlikely, but it is worth mentioning. I chronicled my experiences with working around this issue and setting up z2jh on EFS in https://github.com/jupyterhub/zero-to-jupyterhub-k8s/issues/421 with @yuvipanda. --- base-notebook/start.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base-notebook/start.sh b/base-notebook/start.sh index 53872983ce..52999f90fe 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -17,6 +17,10 @@ if [ $(id -u) == 0 ] ; then # Handle username change. Since this is cheap, do this unconditionally echo "Set username to: $NB_USER" usermod -d /home/$NB_USER -l $NB_USER jovyan + + # Handle case where provisioned storage does not have the correct permissions by default + # Ex: default NFS/EFS (no auto-uid/gid) + chown $NB_UID:$NB_GID /home/$NB_USER # handle home and working directory if the username changed if [[ "$NB_USER" != "jovyan" ]]; then From 272476e2d7e2b9539d81c393d35133edfe05a8ea Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Wed, 31 Jan 2018 09:05:01 -0500 Subject: [PATCH 2/2] Gate chown /home/$NB_USER behind $CHOWN_HOME --- base-notebook/start.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/base-notebook/start.sh b/base-notebook/start.sh index 52999f90fe..4795dee607 100755 --- a/base-notebook/start.sh +++ b/base-notebook/start.sh @@ -20,7 +20,10 @@ 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) - chown $NB_UID:$NB_GID /home/$NB_USER + if [[ "$CHOWN_HOME" == "1" || "$CHOWN_HOME" == 'yes' ]]; then + echo "Changing ownership of /home/$NB_USER to $NB_UID:$NB_GID" + chown $NB_UID:$NB_GID /home/$NB_USER + fi # handle home and working directory if the username changed if [[ "$NB_USER" != "jovyan" ]]; then