mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-03 05:59:30 +00:00
91d37be1da
* 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
36 lines
602 B
Go
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)
|
|
}
|
|
}
|