open-vault/vault/diagnose/file_checks_unix.go
2022-01-05 12:02:03 -06:00

21 lines
329 B
Go

//go:build !windows
package diagnose
import (
"io/fs"
"syscall"
)
// IsOwnedByRoot checks if a file is owned by root
func IsOwnedByRoot(info fs.FileInfo) bool {
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
uid := int(stat.Uid)
gid := int(stat.Gid)
if uid == 0 && gid == 0 {
return true
}
}
return false
}