Files
Programming-Contests/files/security/team-vscode-extensions
T
2026-10-15 20:44:05 -03:00

20 lines
923 B
Bash

#!/bin/bash
# Prepares the VS Code extensions of the team account at boot, as root, with
# the script of the ICPC image. The image runs that script at login through
# sudo, which every account could then use as root. The paths it mounts and
# changes are checked first: a symbolic link there could point anywhere.
set -eu
USER_NAME=team
home=$(getent passwd "$USER_NAME" | cut -d: -f6)
for path in "$home/.pki" "$home/.pki/nssdb" "$home/.vscode" \
"$home/.vscode/extensions" "$home/.vscode/extensions-work" \
"$home/.vscode/extensions-overlay" "$home/.vscode/extensions-root"; do
if [ -L "$path" ]; then
logger -t team-vscode-extensions "removing the symbolic link $path"
rm -f "$path"
fi
done
[ -L "$home" ] && { echo "$home is a symbolic link" >&2; exit 1; }
export SUDO_UID=$(id -u "$USER_NAME") SUDO_GID=$(id -g "$USER_NAME")
exec /usr/local/bin/vscode-extension-install