yq/pkg/yqlib/chown_linux.go
2022-12-17 11:05:08 +11:00

19 lines
284 B
Go

//go:build linux
package yqlib
import (
"io/fs"
"os"
"syscall"
)
func changeOwner(info fs.FileInfo, file *os.File) error {
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
uid := int(stat.Uid)
gid := int(stat.Gid)
return os.Chown(file.Name(), uid, gid)
}
return nil
}