Files
Privatae d62da8adb4
ci / personal-data (push) Successful in 4s
ci / fuzz (push) Successful in 2m44s
ci / test (push) Successful in 2m11s
bastion 0.54.0
2026-10-21 22:29:10 +00:00

37 lines
945 B
Go

//go:build linux || darwin
package main
import (
"os"
"strconv"
"syscall"
)
// mcpAdminOwners: root owns files in any account's home without that being
// another account's file.
var mcpAdminOwners = map[string]bool{"0": true}
// mcpFileOwner is the uid that owns an opened file, as mcpOwnerAllowed
// compares it.
func mcpFileOwner(fi os.FileInfo) string {
if st, ok := fi.Sys().(*syscall.Stat_t); ok {
return strconv.FormatUint(uint64(st.Uid), 10)
}
return mcpOwnerUnknown // matches no account and not root: the file is skipped
}
// mcpPathOwner is the uid that owns an account's home: the account whose
// files are read there. A home that cannot be looked at gives root, so only
// root-owned files would be read in it.
func mcpPathOwner(dir string) string {
st, err := os.Stat(dir)
if err != nil {
return "0"
}
if s, ok := st.Sys().(*syscall.Stat_t); ok {
return strconv.FormatUint(uint64(s.Uid), 10)
}
return "0"
}