ceph-csi/vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go
Madhu Rajanna ff3e84ad67 rebase: update kubernetes to 1.28.0 in main
updating kubernetes to 1.28.0
in the main repo.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
2023-08-17 13:43:15 +00:00

20 lines
393 B
Go

package lumberjack
import (
"os"
"syscall"
)
// osChown is a var so we can mock it out during tests.
var osChown = os.Chown
func chown(name string, info os.FileInfo) error {
f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, info.Mode())
if err != nil {
return err
}
f.Close()
stat := info.Sys().(*syscall.Stat_t)
return osChown(name, int(stat.Uid), int(stat.Gid))
}