//go:build unix package bundle import ( "os" "syscall" ) // chownLike gives p the owner of root, when this runs as root: the mirror // runs as its own user, and a version it cannot remove is one `mirror // remove` and the admin page fail on. func chownLike(root, p string) { if os.Geteuid() != 0 { return } info, err := os.Stat(root) if err != nil { return } st, ok := info.Sys().(*syscall.Stat_t) if !ok { return } _ = os.Lchown(p, int(st.Uid), int(st.Gid)) }