25 lines
473 B
Go
25 lines
473 B
Go
![]() |
// +build !windows
|
||
|
|
||
|
package daemon
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"github.com/docker/docker/pkg/system"
|
||
|
)
|
||
|
|
||
|
// copyOwnership copies the permissions and uid:gid of the source file
|
||
|
// into the destination file
|
||
|
func copyOwnership(source, destination string) error {
|
||
|
stat, err := system.Stat(source)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
if err := os.Chown(destination, int(stat.Uid()), int(stat.Gid())); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return os.Chmod(destination, os.FileMode(stat.Mode()))
|
||
|
}
|