Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Supply GNU archive and rename tools to macOS server fixtures

pulse-triage[bot]05e9c32febea
diff --git a/.github/workflows/unified-agent-native.yml b/.github/workflows/unified-agent-native.yml
index 2adf9b2a04..edc7edd04a 100644
--- a/.github/workflows/unified-agent-native.yml
+++ b/.github/workflows/unified-agent-native.yml
@@ -170,26 +170,30 @@ jobs:
run: go build -o pulse-agent-helper-native ./cmd/pulse-agent-helper
# Server/LXC fixtures execute Linux-only scripts, not a macOS installer.
- # Keep their supported Bash/GNU metadata semantics local to that step;
+ # Keep their Bash/GNU metadata, archive and rename semantics local to that step;
# native macOS agent/runtime tests still use the runner's own utilities.
- name: Supply Linux server installer fixture tools on macOS
if: runner.os == 'macOS'
shell: bash
run: |
set -euo pipefail
- brew install bash
+ brew install bash gnu-tar
linux_bash="$(brew --prefix bash)/bin/bash"
test -x "$linux_bash"
"$linux_bash" -c '(( BASH_VERSINFO[0] >= 5 ))'
coreutils_bin="$(brew --prefix coreutils)/bin"
fixture_bin="$(mktemp -d "$RUNNER_TEMP/pulse-installer-fixture-tools.XXXXXX")"
ln -s "$linux_bash" "$fixture_bin/bash"
- for tool in stat chmod chown; do
+ for tool in stat chmod chown mv; do
executable="$coreutils_bin/g$tool"
test -x "$executable"
"$executable" --version | grep -q 'GNU coreutils'
ln -s "$executable" "$fixture_bin/$tool"
done
+ gnu_tar="$(brew --prefix gnu-tar)/bin/gtar"
+ test -x "$gnu_tar"
+ "$gnu_tar" --version | grep -q 'GNU tar'
+ ln -s "$gnu_tar" "$fixture_bin/tar"
printf 'PULSE_INSTALLER_FIXTURE_BIN=%s\n' "$fixture_bin" >> "$GITHUB_ENV"
- name: Test native Unix installer contracts
diff --git a/scripts/installtests/native_installer_fixture_tools_test.go b/scripts/installtests/native_installer_fixture_tools_test.go
index 67e6d96c9a..5f93de2e71 100644
--- a/scripts/installtests/native_installer_fixture_tools_test.go
+++ b/scripts/installtests/native_installer_fixture_tools_test.go
@@ -52,11 +52,11 @@ func nativeInstallerFixtureSteps(t *testing.T) (nativeGuidanceStep, nativeGuidan
func TestNativeInstallerFixtureToolsAreRealAndStepLocal(t *testing.T) {
supply, installer := nativeInstallerFixtureSteps(t)
- for _, scenario := range []string{"real tools", "install failure", "missing bash", "legacy bash", "missing stat", "non-GNU chmod"} {
+ for _, scenario := range []string{"real tools", "install failure", "missing bash", "legacy bash", "missing stat", "non-GNU chmod", "missing mv", "non-GNU mv", "missing tar", "non-GNU tar"} {
t.Run(scenario, func(t *testing.T) {
root := t.TempDir()
- bin, prefix, runnerTemp := filepath.Join(root, "bin"), filepath.Join(root, "brew with spaces"), filepath.Join(root, "runner temp")
- for _, path := range []string{bin, filepath.Join(prefix, "bin"), runnerTemp} {
+ bin, prefix, tarPrefix, runnerTemp := filepath.Join(root, "bin"), filepath.Join(root, "brew with spaces"), filepath.Join(root, "gnu tar with spaces"), filepath.Join(root, "runner temp")
+ for _, path := range []string{bin, filepath.Join(prefix, "bin"), filepath.Join(tarPrefix, "bin"), runnerTemp} {
if err := os.MkdirAll(path, 0700); err != nil {
t.Fatal(err)
}
@@ -64,24 +64,31 @@ func TestNativeInstallerFixtureToolsAreRealAndStepLocal(t *testing.T) {
brew := `#!/bin/sh
printf '%s\n' "$*" >> "$BREW_CALLS"
case "$*" in
- 'install bash') exit "${BREW_EXIT:-0}" ;;
+ 'install bash gnu-tar') exit "${BREW_EXIT:-0}" ;;
'--prefix bash'|'--prefix coreutils') printf '%s\n' "$TOOLS_PREFIX" ;;
+ '--prefix gnu-tar') printf '%s\n' "$TAR_PREFIX" ;;
*) exit 64 ;;
esac
`
if err := os.WriteFile(filepath.Join(bin, "brew"), []byte(brew), 0700); err != nil {
t.Fatal(err)
}
- for _, name := range []string{"bash", "stat", "chmod", "chown"} {
- if scenario == "missing "+name {
- continue
- }
- leaf := name
+ tools := []string{"bash", "stat", "chmod", "chown", "mv", "tar"}
+ installed := make(map[string]string)
+ for _, name := range tools {
+ leaf, toolPrefix := name, prefix
if name != "bash" {
leaf = "g" + name
}
- path := filepath.Join(prefix, "bin", leaf)
- if (scenario == "legacy bash" && name == "bash") || (scenario == "non-GNU chmod" && name == "chmod") {
+ if name == "tar" {
+ toolPrefix = tarPrefix
+ }
+ path := filepath.Join(toolPrefix, "bin", leaf)
+ installed[name] = path
+ if scenario == "missing "+name {
+ continue
+ }
+ if (scenario == "legacy bash" && name == "bash") || scenario == "non-GNU "+name {
fake := "#!/bin/sh\nprintf 'BSD utility\\n'\n"
if name == "bash" {
fake = "#!/bin/sh\nexit 1\n"
@@ -99,13 +106,21 @@ esac
}
}
}
+ // Native macOS defaults must not be the fallback for Linux-only
+ // archive extraction or atomic replacement. The supplied real GNU
+ // tools below must win even when the native names are unsuitable.
+ for _, name := range []string{"mv", "tar"} {
+ if err := os.WriteFile(filepath.Join(bin, name), []byte("#!/bin/sh\nprintf 'native BSD utility reached\\n' >&2\nexit 64\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
envFile, calls := filepath.Join(root, "github-env"), filepath.Join(root, "brew-calls")
installExit := "0"
if scenario == "install failure" {
installExit = "23"
}
env := append(os.Environ(), "PATH="+bin+":"+os.Getenv("PATH"), "TOOLS_PREFIX="+prefix,
- "BREW_CALLS="+calls, "BREW_EXIT="+installExit, "RUNNER_TEMP="+runnerTemp, "GITHUB_ENV="+envFile)
+ "TAR_PREFIX="+tarPrefix, "BREW_CALLS="+calls, "BREW_EXIT="+installExit, "RUNNER_TEMP="+runnerTemp, "GITHUB_ENV="+envFile)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "bash", "-c", supply.Run)
@@ -140,29 +155,37 @@ esac
t.Fatal("fixture tools escaped the owned runner directory")
}
entries, err := os.ReadDir(fixtureBin)
- if err != nil || len(entries) != 4 {
- t.Fatal("fixture supply must select only Bash/stat/chmod/chown")
+ if err != nil || len(entries) != len(tools) {
+ t.Fatal("fixture supply must select only Bash/stat/chmod/chown/mv/tar")
}
- for _, name := range []string{"bash", "stat", "chmod", "chown"} {
- leaf := name
- if name != "bash" {
- leaf = "g" + name
- }
- if target, err := os.Readlink(filepath.Join(fixtureBin, name)); err != nil || target != filepath.Join(prefix, "bin", leaf) {
+ for _, name := range tools {
+ if target, err := os.Readlink(filepath.Join(fixtureBin, name)); err != nil || target != installed[name] {
t.Fatalf("%s did not bind the verified installed executable", name)
}
}
- if data, err := os.ReadFile(calls); err != nil || string(data) != "install bash\n--prefix bash\n--prefix coreutils\n" {
+ if data, err := os.ReadFile(calls); err != nil || string(data) != "install bash gnu-tar\n--prefix bash\n--prefix coreutils\n--prefix gnu-tar\n" {
t.Fatal("fixture supply changed its fixed package/resource selection")
}
// Exercise the actual workflow step's local PATH boundary, replacing
// only Python's containing suite to avoid recursively starting Go.
probe := `#!/bin/sh
+set -eu
test "$*" = 'scripts/installtests/run_unix_contracts.py' || exit 91
test "$(command -v bash)" = "$PULSE_INSTALLER_FIXTURE_BIN/bash" || exit 92
-for tool in stat chmod chown; do
+for tool in stat chmod chown mv tar; do
test "$(command -v "$tool")" = "$PULSE_INSTALLER_FIXTURE_BIN/$tool" || exit 93
done
+# Exercise the actual Linux-only flags with real executables and file bytes.
+# Neither a filename check nor a --version double can establish these semantics.
+printf 'archive bytes\n' > "$PROBE_ROOT/source"
+tar -czf "$PROBE_ROOT/source.tgz" -C "$PROBE_ROOT" source
+mkdir -p "$PROBE_ROOT/extracted"
+tar --no-same-owner --no-overwrite-dir -xzf "$PROBE_ROOT/source.tgz" -C "$PROBE_ROOT/extracted"
+cmp "$PROBE_ROOT/source" "$PROBE_ROOT/extracted/source"
+cp "$PROBE_ROOT/extracted/source" "$PROBE_ROOT/staged"
+mv -T "$PROBE_ROOT/staged" "$PROBE_ROOT/published"
+cmp "$PROBE_ROOT/source" "$PROBE_ROOT/published"
+test ! -e "$PROBE_ROOT/staged"
exit "${SUITE_EXIT:-0}"
`
if err := os.WriteFile(filepath.Join(bin, "python3"), []byte(probe), 0700); err != nil {
@@ -170,7 +193,7 @@ exit "${SUITE_EXIT:-0}"
}
for _, code := range []string{"0", "23"} {
cmd := exec.CommandContext(ctx, "bash", "-c", installer.Run)
- cmd.Env = append(env, "PULSE_INSTALLER_FIXTURE_BIN="+fixtureBin, "SUITE_EXIT="+code)
+ cmd.Env = append(env, "PULSE_INSTALLER_FIXTURE_BIN="+fixtureBin, "PROBE_ROOT="+root, "SUITE_EXIT="+code)
output, err := cmd.CombinedOutput()
if code == "0" && err != nil {
t.Fatalf("fixture-local path did not reach the suite: %v: %s", err, output)