Skip to content

Commit 8129dc2

Browse files
authored
scripts/run_vim.sh: only use su for root user (#48)
1 parent a4466b7 commit 8129dc2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

scripts/run_vim.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ while [ $# -gt 0 ]; do
2323
shift
2424
done
2525

26-
# Run as the vimtest user. This is not really for security. It is for running
27-
# Vim as a user that's unable to write to your volume.
28-
exec su -l vimtest -c "cd /testplugin && /vim-build/bin/$BIN $ARGS"
26+
# Run as the vimtest user (when no USER is specified in the Dockerfile, i.e.
27+
# when running as root).
28+
# This is not really for security. It is for running Vim as a user that's
29+
# unable to write to your volume.
30+
if [ "$(id -u)" = 0 ]; then
31+
exec su -l vimtest -c "cd /testplugin && /vim-build/bin/$BIN $ARGS"
32+
fi
33+
34+
cd /testplugin || exit
35+
36+
# shellcheck disable=SC2086
37+
exec "/vim-build/bin/$BIN" $ARGS

0 commit comments

Comments
 (0)