2026-03-12 07:38:54 +01:00
|
|
|
#!/bin/bash
|
2026-03-12 18:02:18 +01:00
|
|
|
# Strip PKG_EXECPATH so the child's pkg bootstrap starts fresh.
|
|
|
|
|
# When PKG_EXECPATH is inherited, bootstrap treats argv[1] as a module path
|
|
|
|
|
# causing "Cannot find module '/--connect'" or '/--install-missing-components'.
|
|
|
|
|
# env -u unsets only PKG_EXECPATH; all auth/config/session vars are kept.
|
|
|
|
|
# Depth guard prevents infinite recursion.
|
2026-03-12 16:03:50 +01:00
|
|
|
|
|
|
|
|
DEPTH="${PUREVPN_SUDO_DEPTH:-0}"
|
|
|
|
|
if [[ "$DEPTH" -ge 2 ]]; then
|
2026-03-12 18:02:18 +01:00
|
|
|
echo "[sudo-wrapper] depth $DEPTH — exiting 0" >&2
|
2026-03-12 16:03:50 +01:00
|
|
|
exit 0
|
|
|
|
|
fi
|
2026-03-12 07:38:54 +01:00
|
|
|
|
2026-03-12 18:02:18 +01:00
|
|
|
args=()
|
2026-03-12 07:38:54 +01:00
|
|
|
for a in "$@"; do
|
2026-03-12 18:02:18 +01:00
|
|
|
case "$a" in -E|-n|-H) ;; *) args+=("$a") ;; esac
|
2026-03-12 07:38:54 +01:00
|
|
|
done
|
|
|
|
|
|
2026-03-12 18:02:18 +01:00
|
|
|
echo "[sudo-wrapper] depth=$(( DEPTH+1 )): ${args[*]}" >&2
|
|
|
|
|
exec env -u PKG_EXECPATH PUREVPN_SUDO_DEPTH=$(( DEPTH+1 )) "${args[@]}"
|