Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker/daemon: set umask to the default on startup #13941

Merged
merged 1 commit into from
Jun 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docker/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions docker/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
package main

import (
"fmt"
"os"
"syscall"

apiserver "github.com/docker/docker/api/server"
"github.com/docker/docker/daemon"
Expand All @@ -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
}
5 changes: 5 additions & 0 deletions docker/daemon_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}