mox/moxio/umask.go

19 lines
413 B
Go
Raw Normal View History

2023-01-30 16:27:06 +03:00
package moxio
import (
"fmt"
"syscall"
)
// CheckUmask checks that the umask is 7 for "other". Because files written
// should not be world-accessible. E.g. database files, and the control unix
// domain socket.
func CheckUmask() error {
old := syscall.Umask(007)
syscall.Umask(old)
if old&7 != 7 {
return fmt.Errorf(`umask must have "7" for world/other, e.g. 007, not current %o`, old)
}
return nil
}