Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/verify-split-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ on:
- "tests/uv-required-version.sh"
- "tests/docker-lxcfs.sh"
- "tests/java-memory.sh"
- "tests/sudo-env.sh"
- "tests/deb822-local-keyring.sh"
- "tests/gpu-pci-class.sh"
- "tests/nvidia-version-pin.sh"
Expand Down Expand Up @@ -90,6 +91,7 @@ on:
- "tests/uv-required-version.sh"
- "tests/docker-lxcfs.sh"
- "tests/java-memory.sh"
- "tests/sudo-env.sh"
- "tests/deb822-local-keyring.sh"
- "tests/gpu-pci-class.sh"
- "tests/nvidia-version-pin.sh"
Expand Down Expand Up @@ -174,6 +176,9 @@ jobs:
- name: Java memory drop-in tests
run: bash tests/java-memory.sh

- name: sudo environment tests
run: bash tests/sudo-env.sh

- name: deb822 local keyring tests
run: bash tests/deb822-local-keyring.sh

Expand Down
3 changes: 3 additions & 0 deletions core/build.func
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-$_CS_DEFAULT_URL}"
COMMUNITY_SCRIPTS_CORE_URL="${COMMUNITY_SCRIPTS_CORE_URL:-$_CS_CORE_DEFAULT_URL}"
export COMMUNITY_SCRIPTS_URL COMMUNITY_SCRIPTS_CORE_URL

# Left by sudo; pnpm 12 refuses global commands while SUDO_USER is set.
unset SUDO_USER SUDO_UID SUDO_GID SUDO_HOME SUDO_COMMAND

# ── Resolution ────────────────────────────────────────────────────────────────
# Local file for a virtual path, or non-zero when it must be fetched remotely.
# Every branch is -f guarded: an unguarded assignment used to shadow the
Expand Down
28 changes: 28 additions & 0 deletions tests/sudo-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail

CORE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
BUILD="$CORE_DIR/core/build.func"
passed=0 failed=0

check() {
if [[ "$3" == "$2" ]]; then
echo "PASS $1"
passed=$((passed + 1))
else
echo "FAIL $1: expected <$2>, got <$3>" >&2
failed=$((failed + 1))
fi
}

line="$(grep -m1 '^unset SUDO_USER' "$BUILD" || true)"
left="$(SUDO_USER=bob SUDO_UID=1000 SUDO_GID=1000 SUDO_HOME=/home/bob SUDO_COMMAND=update \
bash -c "${line:-:}; env | grep '^SUDO_' | cut -d= -f1 | xargs || true")"
check "build.func drops every SUDO_ variable" "" "$left"

unset_at="$(grep -n -m1 '^unset SUDO_USER' "$BUILD" | cut -d: -f1 || true)"
probes_at="$(grep -n -m1 '^_cs_start_host_probes$' "$BUILD" | cut -d: -f1)"
check "before the first child process starts" yes "$([[ -n "$unset_at" && "$unset_at" -lt "$probes_at" ]] && echo yes || echo no)"

printf '%s passed, %s failed\n' "$passed" "$failed"
((failed == 0))
Loading