mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 15:18:06 +00:00
19 lines
284 B
Go
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
|
||
|
}
|