1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2024-12-27 00:12:31 +01:00
dnscrypt-proxy/vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go

20 lines
393 B
Go
Raw Normal View History

package lumberjack
import (
"os"
"syscall"
)
2023-02-07 10:14:52 +01:00
// 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)
2023-02-07 10:14:52 +01:00
return osChown(name, int(stat.Uid), int(stat.Gid))
}