utils_daemon.go 352 B

123456789101112131415161718
  1. // +build daemon
  2. package utils
  3. import (
  4. "github.com/docker/docker/pkg/system"
  5. "os"
  6. )
  7. // IsFileOwner checks whether the current user is the owner of the given file.
  8. func IsFileOwner(f string) bool {
  9. if fileInfo, err := system.Stat(f); err == nil && fileInfo != nil {
  10. if int(fileInfo.Uid()) == os.Getuid() {
  11. return true
  12. }
  13. }
  14. return false
  15. }