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:
@@ -36,7 +36,10 @@ func openMeshDir(path string, mode os.FileMode, made func(dir string, fd int) er
|
||||
// (novox/hq issue 358): opened by openMeshDir, made there when missing, judged a directory by fstat on it, changed
|
||||
// with fchmod and fchown on it, and read back from it. The parents it makes inside the owner's home are the owner's,
|
||||
// as makeDirs gives them (novox/hq ADR 0182).
|
||||
func applyMeshDirectory(r *declaration.Directory, out Outcome, mode os.FileMode, existed bool) (Outcome, error) {
|
||||
//
|
||||
// Its owner changed, it gives its contents the new owner too, but for what placed names (giveContents; H-A-545 (2),
|
||||
// H-A-550).
|
||||
func applyMeshDirectory(r *declaration.Directory, out Outcome, mode os.FileMode, existed bool, placed map[string]bool) (Outcome, error) {
|
||||
uid, gid, chown := 0, 0, r.Owner != ""
|
||||
var err error
|
||||
if chown {
|
||||
@@ -92,6 +95,11 @@ func applyMeshDirectory(r *declaration.Directory, out Outcome, mode os.FileMode,
|
||||
if err := unix.Fchmod(fd, unixDirMode(mode)); err != nil {
|
||||
return out, &os.PathError{Op: "chmod", Path: r.Path, Err: err}
|
||||
}
|
||||
if existed && !created {
|
||||
if _, err := giveContents(walk.At, [2]int{beforeUID, beforeGID}, [2]int{uid, gid}, placed); err != nil {
|
||||
return out, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read back, from the descriptor that was changed.
|
||||
|
||||
Reference in New Issue
Block a user