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.

Fix native agent release lifecycle verification

rcourtman11bf0c9e7433
diff --git a/.github/workflows/build-release-candidate.yml b/.github/workflows/build-release-candidate.yml
index 497609061e..71192ca558 100644
--- a/.github/workflows/build-release-candidate.yml
+++ b/.github/workflows/build-release-candidate.yml
@@ -131,9 +131,21 @@ jobs:
--key AuthKey.p8 \
--key-id "$APPLE_NOTARY_KEY_ID" \
--issuer "$APPLE_NOTARY_ISSUER_ID" \
- --wait
+ --wait \
+ --output-format json > notarization-result.json
+ python3 - <<'PY'
+ import json
+ from pathlib import Path
+
+ result = json.loads(Path('notarization-result.json').read_text())
+ if result.get('status') != 'Accepted':
+ raise SystemExit(f"Apple notarization was not accepted: {result.get('status', 'unknown')}")
+ PY
for binary in native-agent-binaries/pulse-agent-darwin-*; do
- spctl --assess --type execute --verbose=2 "$binary"
+ # Gatekeeper's spctl app assessment rejects bare command-line
+ # Mach-O binaries even when the notary service accepted them.
+ # Verify the signed bytes that will be packaged instead.
+ codesign --verify --deep --strict --verbose=2 "$binary"
done
- name: Upload signed macOS binaries
diff --git a/scripts/install.sh b/scripts/install.sh
index 72ff98969c..84558bdb9d 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -593,12 +593,31 @@ teardown_openrc_agent_service() {
rm -f "$init_path"
}
-teardown_service_command_agent() {
- local service_path="$1"
- service "${AGENT_NAME}" stop 2>/dev/null || true
- if [[ -n "$service_path" ]]; then
- rm -f "$service_path"
+teardown_freebsd_agent_service() {
+ local service_path="${1:-/usr/local/etc/rc.d/${AGENT_NAME}}"
+
+ # Stop the rc.d supervisor before removing the executable. Killing only the
+ # child is insufficient because daemon(8) immediately restarts it.
+ if [[ -x "$service_path" ]]; then
+ "$service_path" stop 2>/dev/null || true
+ elif command -v service >/dev/null 2>&1; then
+ service "${AGENT_NAME}" stop 2>/dev/null || true
fi
+
+ if command -v sysrc >/dev/null 2>&1; then
+ sysrc -x pulse_agent_enable >/dev/null 2>&1 || true
+ else
+ for rc_config in /etc/rc.conf /etc/rc.conf.local; do
+ if [[ -f "$rc_config" ]]; then
+ sed -i '' '/^[[:space:]]*pulse_agent_enable[[:space:]]*=/d' "$rc_config" 2>/dev/null || \
+ sed -i '/^[[:space:]]*pulse_agent_enable[[:space:]]*=/d' "$rc_config" 2>/dev/null || true
+ fi
+ done
+ fi
+
+ rm -f "$service_path"
+ rm -f /usr/local/etc/rc.d/pulse_agent.sh
+ rm -f /var/run/pulse_agent.pid /var/run/pulse_agent.child.pid
}
teardown_sysv_agent_service() {
@@ -2678,7 +2697,7 @@ if [[ "$UNINSTALL" == "true" ]]; then
teardown_systemd_agent_service
elif [[ "$(uname -s)" == "FreeBSD" ]]; then
log_info "Removing TrueNAS CORE installation..."
- teardown_service_command_agent "/usr/local/etc/rc.d/${AGENT_NAME}"
+ teardown_freebsd_agent_service "/usr/local/etc/rc.d/${AGENT_NAME}"
fi
# Remove Init/Shutdown task
if command -v midclt >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1; then
@@ -2696,6 +2715,13 @@ if [[ "$UNINSTALL" == "true" ]]; then
teardown_openrc_agent_service
fi
+ # Vanilla FreeBSD, OPNsense, and pfSense all use the rc.d service rendered
+ # by this installer. This must run even when no TrueNAS marker is present.
+ if [[ "$(uname -s)" == "FreeBSD" ]]; then
+ log_info "Removing FreeBSD rc.d installation..."
+ teardown_freebsd_agent_service "/usr/local/etc/rc.d/${AGENT_NAME}"
+ fi
+
# SysV init (legacy systems like Asustor, older Debian/RHEL, etc.)
if [[ -f "/etc/init.d/${AGENT_NAME}" ]]; then
teardown_sysv_agent_service "/etc/init.d/${AGENT_NAME}"
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index dec26b1711..af2bf38562 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -715,17 +715,27 @@ func TestAgentRuntimeImagePersistsAgentIdentityByDefault(t *testing.T) {
}
func TestReleaseCandidateRequiresPlatformNativeAgentSigning(t *testing.T) {
- assertFileContainsAll(t, repoFile(".github", "workflows", "build-release-candidate.yml"),
+ candidateWorkflowPath := repoFile(".github", "workflows", "build-release-candidate.yml")
+ assertFileContainsAll(t, candidateWorkflowPath,
`require_platform_signing:`,
`sign-macos-agent:`,
`codesign --force --timestamp --options runtime`,
`xcrun notarytool submit`,
- `spctl --assess --type execute`,
+ `--output-format json > notarization-result.json`,
+ `result.get('status') != 'Accepted'`,
+ `codesign --verify --deep --strict --verbose=2`,
`sign-windows-agent:`,
`signtool sign`,
`signtool verify /pa /v`,
`PULSE_AGENT_NATIVE_BINARIES_DIR:`,
)
+ candidateWorkflow, err := os.ReadFile(candidateWorkflowPath)
+ if err != nil {
+ t.Fatalf("read build-release-candidate.yml: %v", err)
+ }
+ if strings.Contains(string(candidateWorkflow), `spctl --assess --type execute`) {
+ t.Fatal("bare command-line Mach-O binaries must not use Gatekeeper app assessment after notarization")
+ }
assertFileContainsAll(t, repoFile(".github", "workflows", "create-release.yml"),
`require_platform_signing: true`,
)
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index 069cb71af4..2655b1bbcf 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -1374,10 +1374,10 @@ func TestInstallSHUsesCanonicalServiceTeardownHelpers(t *testing.T) {
required := []string{
`teardown_systemd_agent_service() {`,
`teardown_openrc_agent_service() {`,
- `teardown_service_command_agent() {`,
+ `teardown_freebsd_agent_service() {`,
`teardown_sysv_agent_service() {`,
`teardown_systemd_agent_service`,
- `teardown_service_command_agent "/usr/local/etc/rc.d/${AGENT_NAME}"`,
+ `teardown_freebsd_agent_service "/usr/local/etc/rc.d/${AGENT_NAME}"`,
`teardown_openrc_agent_service`,
`teardown_sysv_agent_service "/etc/init.d/${AGENT_NAME}"`,
}
@@ -1670,6 +1670,29 @@ func TestInstallSHUsesCanonicalFreeBSDAgentEnablement(t *testing.T) {
}
}
+func TestInstallSHUsesCanonicalFreeBSDAgentTeardown(t *testing.T) {
+ content, err := os.ReadFile(repoFile("scripts", "install.sh"))
+ if err != nil {
+ t.Fatalf("read install.sh: %v", err)
+ }
+
+ script := string(content)
+ required := []string{
+ `teardown_freebsd_agent_service() {`,
+ `"$service_path" stop 2>/dev/null || true`,
+ `sysrc -x pulse_agent_enable >/dev/null 2>&1 || true`,
+ `rm -f /usr/local/etc/rc.d/pulse_agent.sh`,
+ `rm -f /var/run/pulse_agent.pid /var/run/pulse_agent.child.pid`,
+ `log_info "Removing FreeBSD rc.d installation..."`,
+ `teardown_freebsd_agent_service "/usr/local/etc/rc.d/${AGENT_NAME}"`,
+ }
+ for _, needle := range required {
+ if !strings.Contains(script, needle) {
+ t.Fatalf("install.sh missing canonical FreeBSD teardown contract: %s", needle)
+ }
+ }
+}
+
func TestInstallSHUsesCanonicalSysVEnablementHelper(t *testing.T) {
content, err := os.ReadFile(repoFile("scripts", "install.sh"))
if err != nil {