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:
parent
ee40f29712
commit
6578ad90c3
3 changed files with 23 additions and 0 deletions
|
@ -91,6 +91,10 @@ func mainDaemon() {
|
||||||
|
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{TimestampFormat: timeutils.RFC3339NanoFixed})
|
logrus.SetFormatter(&logrus.TextFormatter{TimestampFormat: timeutils.RFC3339NanoFixed})
|
||||||
|
|
||||||
|
if err := setDefaultUmask(); err != nil {
|
||||||
|
logrus.Fatalf("Failed to set umask: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
var pfile *pidfile.PidFile
|
var pfile *pidfile.PidFile
|
||||||
if daemonCfg.Pidfile != "" {
|
if daemonCfg.Pidfile != "" {
|
||||||
pf, err := pidfile.New(daemonCfg.Pidfile)
|
pf, err := pidfile.New(daemonCfg.Pidfile)
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
apiserver "github.com/docker/docker/api/server"
|
apiserver "github.com/docker/docker/api/server"
|
||||||
"github.com/docker/docker/daemon"
|
"github.com/docker/docker/daemon"
|
||||||
|
@ -28,3 +30,15 @@ func currentUserIsOwner(f string) bool {
|
||||||
}
|
}
|
||||||
return false
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -16,3 +16,8 @@ func setPlatformServerConfig(serverConfig *apiserver.ServerConfig, daemonCfg *da
|
||||||
func currentUserIsOwner(f string) bool {
|
func currentUserIsOwner(f string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setDefaultUmask doesn't do anything on windows
|
||||||
|
func setDefaultUmask() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue