mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
18 lines
413 B
Go
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 %03o`, old)
|
|
}
|
|
return nil
|
|
}
|