mox/moxio/umask.go
Mechiel Lukkien cb229cb6cf
mox!
2023-01-30 14:27:06 +01:00

18 lines
413 B
Go

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
}