2015-05-15 19:34:26 -04:00
|
|
|
// +build daemon,!windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-06-15 09:36:19 -04:00
|
|
|
"fmt"
|
2015-05-15 19:34:26 -04:00
|
|
|
"os"
|
2015-06-15 09:36:19 -04:00
|
|
|
"syscall"
|
2015-05-15 19:34:26 -04:00
|
|
|
|
|
|
|
apiserver "github.com/docker/docker/api/server"
|
|
|
|
"github.com/docker/docker/daemon"
|
|
|
|
"github.com/docker/docker/pkg/system"
|
|
|
|
|
|
|
|
_ "github.com/docker/docker/daemon/execdriver/native"
|
|
|
|
)
|
|
|
|
|
2015-07-21 01:15:44 -04:00
|
|
|
func setPlatformServerConfig(serverConfig *apiserver.Config, daemonCfg *daemon.Config) *apiserver.Config {
|
2015-05-15 19:34:26 -04:00
|
|
|
serverConfig.SocketGroup = daemonCfg.SocketGroup
|
2015-07-16 17:14:58 -04:00
|
|
|
serverConfig.EnableCors = daemonCfg.EnableCors
|
|
|
|
serverConfig.CorsHeaders = daemonCfg.CorsHeaders
|
|
|
|
|
2015-05-15 19:34:26 -04:00
|
|
|
return serverConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
// currentUserIsOwner checks whether the current user is the owner of the given
|
|
|
|
// file.
|
|
|
|
func currentUserIsOwner(f string) bool {
|
|
|
|
if fileInfo, err := system.Stat(f); err == nil && fileInfo != nil {
|
2015-07-28 12:13:12 -04:00
|
|
|
if int(fileInfo.UID()) == os.Getuid() {
|
2015-05-15 19:34:26 -04:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2015-06-15 09:36:19 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
2015-07-30 15:39:19 -04:00
|
|
|
|
|
|
|
func getDaemonConfDir() string {
|
|
|
|
return "/etc/docker"
|
|
|
|
}
|