Skip to content

Commit 3e165b3

Browse files
committed
Revert broken sed --in-place command
1 parent 42071c6 commit 3e165b3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

base-notebook/start.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,16 @@ else
177177
echo "There is no entry in /etc/passwd for our UID. Attempting to fix..."
178178
if [[ -w /etc/passwd ]]; then
179179
echo "Renaming old jovyan user to nayvoj ($(id -u jovyan):$(id -g jovyan))"
180-
sed --in-place "s/^jovyan:/nayvoj:/" /etc/passwd
181180

182-
echo "jovyan:x:$(id -u):$(id -g):,,,:/home/jovyan:/bin/bash" >> /etc/passwd
181+
# We cannot use "sed --in-place" since sed tries to create a temp file in
182+
# /etc/ and we may not have write access. Apply sed on our own temp file:
183+
sed --expression="s/^jovyan:/nayvoj:/" /etc/passwd > /tmp/passwd
184+
echo "jovyan:x:$(id -u):$(id -g):,,,:/home/jovyan:/bin/bash" >> /tmp/passwd
185+
cat /tmp/passwd > /etc/passwd
186+
rm /tmp/passwd
187+
183188
echo "Added new jovyan user ($(id -u):$(id -g)). Fixed UID!"
189+
184190
else
185191
echo "WARNING: unable to fix missing /etc/passwd entry because we don't have write permission."
186192
fi

0 commit comments

Comments
 (0)