2023-01-03 04:52:01 +00:00
|
|
|
//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)
|
2023-01-15 00:36:52 +00:00
|
|
|
|
|
|
|
err := os.Chown(file.Name(), uid, gid)
|
|
|
|
if err != nil {
|
|
|
|
// this happens with snap confinement
|
|
|
|
// not really a big issue as users can chown
|
|
|
|
// the file themselves if required.
|
|
|
|
log.Info("Skipping chown: %v", err)
|
|
|
|
}
|
2023-01-03 04:52:01 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|