Set exact initial modes in NAS executable controls

The chosen source proof runs with umask 077. Explicitly chmod the inert pre-update binaries so failure controls can require exact preservation of a 0755 executable rather than assuming WriteFile overrides the caller's mask. This changes only fixture setup; production permission, trust and recovery assertions are retained.

Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-10-13 13:22:11 +01:00
parent a38ef3734d
commit d636bfdaea
2 changed files with 16 additions and 8 deletions
+3 -5
View File
@@ -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 {
+13 -3
View File
@@ -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")