woodpecker/vendor/github.com/docker/cli/cli/config/configfile/file_unix.go
6543 91d37be1da
Update Dependencies (#486)
* github.com/Microsoft/go-winio

* github.com/bradrydzewski/togo

* github.com/containerd/containerd

* github.com/docker/cli

* github.com/docker/docker

* github.com/docker/docker-credential-helpers

* github.com/franela/goblin

* github.com/google/go-github/v39

* github.com/joho/godotenv

* github.com/lib/pq

* github.com/moby/moby

* github.com/prometheus/client_golang

* github.com/tevino/abool

* github.com/woodpecker-ci/togo

* github.com/xanzy/go-gitlab

* github.com/xeipuuv/gojsonschema

* github.com/mattn/go-sqlite3
2021-10-28 12:11:52 +02:00

36 lines
602 B
Go

// +build !windows
package configfile
import (
"os"
"syscall"
)
// copyFilePermissions copies file ownership and permissions from "src" to "dst",
// ignoring any error during the process.
func copyFilePermissions(src, dst string) {
var (
mode os.FileMode = 0600
uid, gid int
)
fi, err := os.Stat(src)
if err != nil {
return
}
if fi.Mode().IsRegular() {
mode = fi.Mode()
}
if err := os.Chmod(dst, mode); err != nil {
return
}
uid = int(fi.Sys().(*syscall.Stat_t).Uid)
gid = int(fi.Sys().(*syscall.Stat_t).Gid)
if uid > 0 && gid > 0 {
_ = os.Chown(dst, uid, gid)
}
}