github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/wrench/wrench_nix.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  // +build !windows
     4  
     5  package wrench
     6  
     7  import (
     8  	"os"
     9  	"syscall"
    10  )
    11  
    12  func isOwnedByJujuUser(fi os.FileInfo) bool {
    13  	statStruct, ok := fi.Sys().(*syscall.Stat_t)
    14  	if !ok {
    15  		// Uid check is not supported on this platform so assume
    16  		// the owner is ok.
    17  		return true
    18  	}
    19  	return int(statStruct.Uid) == jujuUid
    20  }