go-firewall/configfile_unix.go
2026-07-08 15:54:48 -05:00

18 lines
410 B
Go

//go:build unix
package firewall
import (
"os"
"syscall"
)
// statOwner extracts the uid and gid from a Unix FileInfo. The final return is
// false when the underlying stat data is unavailable, leaving ownership
// unchanged on Commit.
func statOwner(fi os.FileInfo) (uid, gid int, ok bool) {
if st, ok := fi.Sys().(*syscall.Stat_t); ok {
return int(st.Uid), int(st.Gid), true
}
return 0, 0, false
}