mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
e2b8933d21
Signed-off-by: Martijn Dwars <ikben@martijndwars.nl>
18 lines
366 B
Go
18 lines
366 B
Go
// +build daemon
|
|
|
|
package utils
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// IsFileOwner checks whether the current user is the owner of the given file.
|
|
func IsFileOwner(f string) bool {
|
|
if fileInfo, err := os.Stat(f); err == nil && fileInfo != nil {
|
|
if stat, ok := fileInfo.Sys().(*syscall.Stat_t); ok && int(stat.Uid) == os.Getuid() {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|