Skip to content

Commit 8958ba7

Browse files
committed
Warn if NB_USER not jovyan and can't rename home
1 parent c772e98 commit 8958ba7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

base-notebook/start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ else
199199
rm /tmp/passwd
200200

201201
_log "Added new ${NB_USER} user ($(id -u):$(id -g)). Fixed UID!"
202+
203+
if [[ "${NB_USER}" != "jovyan" ]]; then
204+
_log "WARNING: user is ${NB_USER} but home is /home/jovyan. You must run as root to rename the home directory!"
205+
fi
202206
else
203207
_log "WARNING: unable to fix missing /etc/passwd entry because we don't have write permission. Try setting gid=0 with \"--user=$(id -u):0\"."
204208
fi

base-notebook/test/test_container_options.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,12 @@ def test_set_uid_and_nb_user(container):
286286
assert rv == 0 or rv["StatusCode"] == 0
287287
logs = c.logs(stdout=True).decode("utf-8")
288288
assert "ERROR" not in logs
289-
assert "WARNING" not in logs
290289
assert "uid=1010(kitten) gid=0(root)" in logs
290+
warnings = [
291+
warning for warning in logs.split("\n") if warning.startswith("WARNING")
292+
]
293+
assert len(warnings) == 1
294+
assert "user is kitten but home is /home/jovyan" in warnings[0]
291295

292296

293297
def test_container_not_delete_bind_mount(container, tmp_path):

0 commit comments

Comments
 (0)