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

@ -91,6 +91,10 @@ func mainDaemon() {
logrus.SetFormatter(&logrus.TextFormatter{TimestampFormat: timeutils.RFC3339NanoFixed})
if err := setDefaultUmask(); err != nil {
logrus.Fatalf("Failed to set umask: %v", err)
}
var pfile *pidfile.PidFile
if daemonCfg.Pidfile != "" {
pf, err := pidfile.New(daemonCfg.Pidfile)

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
}

View file

@ -16,3 +16,8 @@ func setPlatformServerConfig(serverConfig *apiserver.ServerConfig, daemonCfg *da
func currentUserIsOwner(f string) bool {
return false
}
// setDefaultUmask doesn't do anything on windows
func setDefaultUmask() error {
return nil
}