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.

Set exact initial modes in NAS executable controls

pulse-triage[bot]d636bfdaea31
diff --git a/internal/agentupdate/coverage_test.go b/internal/agentupdate/coverage_test.go
index 0ec8da460c..1fb5b8aacc 100644
--- a/internal/agentupdate/coverage_test.go
+++ b/internal/agentupdate/coverage_test.go
@@ -1600,13 +1600,11 @@ func TestPersistentBinaryCopyFailuresRetainExecutable(t *testing.T) {
dir := t.TempDir()
execPath := filepath.Join(dir, "runtime")
persistPath := filepath.Join(dir, "pulse-agent")
- if err := os.WriteFile(execPath, newBinary, 0755); err != nil {
- t.Fatal(err)
- }
+ writeNASUpdateExecutable(t, execPath, newBinary)
if phase == "same-file" {
persistPath = execPath
- } else if err := os.WriteFile(persistPath, oldBinary, 0755); err != nil {
- t.Fatal(err)
+ } else {
+ writeNASUpdateExecutable(t, persistPath, oldBinary)
}
if phase == "hardlink" {
if err := os.Link(persistPath, persistPath+".old-link"); err != nil {
diff --git a/internal/agentupdate/update_http_test.go b/internal/agentupdate/update_http_test.go
index edb9ff1f00..3eca63bee0 100644
--- a/internal/agentupdate/update_http_test.go
+++ b/internal/agentupdate/update_http_test.go
@@ -69,6 +69,18 @@ func runNASUpdateExecutable(t *testing.T, path, wantVersion string) {
}
}
+func writeNASUpdateExecutable(t *testing.T, path string, data []byte) {
+ t.Helper()
+ if err := os.WriteFile(path, data, 0755); err != nil {
+ t.Fatal(err)
+ }
+ // The controls run under a restrictive umask. Set the old executable's
+ // exact starting mode rather than assuming WriteFile overrides that mask.
+ if err := os.Chmod(path, 0755); err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestNASAuthenticatedUpdateKeepsExecutableCopies(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("QNAP/Unraid executable-layout controls require Linux")
@@ -94,9 +106,7 @@ func TestNASAuthenticatedUpdateKeepsExecutableCopies(t *testing.T) {
execPath = persistPath
}
for _, path := range []string{execPath, persistPath} {
- if err := os.WriteFile(path, oldBinary, 0755); err != nil {
- t.Fatal(err)
- }
+ writeNASUpdateExecutable(t, path, oldBinary)
}
if layout == "qnap-directory-alias" {
alias := filepath.Join(dir, "state-alias")