A directory whose owner changes gives its contents the new owner

A module moved to an account of its own (runs-as) has files below its
directories that it wrote as the account it ran as before (gitea's webhook
secret, 0600, as the operator's account); the node-engine changed only the
directory's owner, so the new account could not read them. Now applyDirectory
and applyMeshDirectory give the new owner to what the previous owner held below
the directory, but never a path the declaration or another module's composition
places (and what lies below it), never an entry another account owns, never
through a link (Lchown) and never on another file system.

Builds: design 47 H2 H-A-545 (2), H-A-550
This commit is contained in:
2026-11-23 12:07:40 +01:00
parent 1a19492541
commit d16c4cd003
8 changed files with 228 additions and 11 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ func aMeshDirectory(t *testing.T) (base string, r *declaration.Directory, previo
t.Helper()
base = t.TempDir()
r = &declaration.Directory{ID: "mod.state", Path: filepath.Join(base, "parent", "state"), Mode: "0700"}
out, err := applyDirectory(r, store.Applied{}, false)
out, err := applyDirectory(r, store.Applied{}, false, nil)
if err != nil {
t.Fatalf("the first apply: %v", err)
}
@@ -69,7 +69,7 @@ func TestAParentSwappedForALinkLeavesItsTargetUntouched(t *testing.T) {
base, r, previous := aMeshDirectory(t)
target := swapParentForLink(t, base, filepath.Join(base, "elsewhere"))
_, err := applyDirectory(r, previous, true)
_, err := applyDirectory(r, previous, true, nil)
var refusal *PlacementRefusedError
if !errors.As(err, &refusal) {
t.Fatalf("the directory reached through a link was not refused: %v", err)