2
0
mirror of https://github.com/42wim/matterbridge synced 2024-11-09 07:10:25 +00:00
matterbridge/vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go
2018-11-25 21:21:04 +01:00

20 lines
396 B
Go

package lumberjack
import (
"os"
"syscall"
)
// os_Chown is a var so we can mock it out during tests.
var os_Chown = 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 os_Chown(name, int(stat.Uid), int(stat.Gid))
}