1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

docker/daemon: set umask to the default on startup

This sets up the umask so that it's the same on all systems.

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
unclejack 2015-06-15 16:36:19 +03:00
parent ee40f29712
commit 6578ad90c3
3 changed files with 23 additions and 0 deletions

View file

@ -3,7 +3,9 @@
package main
import (
"fmt"
"os"
"syscall"
apiserver "github.com/docker/docker/api/server"
"github.com/docker/docker/daemon"
@ -28,3 +30,15 @@ func currentUserIsOwner(f string) bool {
}
return false
}
// setDefaultUmask sets the umask to 0022 to avoid problems
// caused by custom umask
func setDefaultUmask() error {
desiredUmask := 0022
syscall.Umask(desiredUmask)
if umask := syscall.Umask(desiredUmask); umask != desiredUmask {
return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask)
}
return nil
}