mirror of
https://github.com/mikefarah/yq.git
synced 2026-06-27 15:37:47 +00:00
* Initial plan * Replace gopkg.in/op/go-logging.v1 with log/slog Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com> Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/aa9c12f4-21b9-4633-9868-6b56585b247f --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>
26 lines
475 B
Go
26 lines
475 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)
|
|
|
|
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.Infof("Skipping chown: %v", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|