mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-18 17:28:04 +08:00
config: fix file/folder ownership
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
50
vendor/github.com/tonistiigi/fsutil/copy/mkdir_unix.go
generated
vendored
Normal file
50
vendor/github.com/tonistiigi/fsutil/copy/mkdir_unix.go
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func fixRootDirectory(p string) string {
|
||||
return p
|
||||
}
|
||||
|
||||
func Utimes(p string, tm *time.Time) error {
|
||||
if tm == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
ts, err := unix.TimeToTimespec(*tm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
timespec := []unix.Timespec{ts, ts}
|
||||
if err := unix.UtimesNanoAt(unix.AT_FDCWD, p, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil {
|
||||
return errors.Wrapf(err, "failed to utime %s", p)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Chown(p string, old *User, fn Chowner) error {
|
||||
if fn == nil {
|
||||
return nil
|
||||
}
|
||||
user, err := fn(old)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if user != nil {
|
||||
if err := os.Lchown(p, user.UID, user.GID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user