github.com/tompao/docker@v1.9.1/docker/daemon_unix.go (about)

     1  // +build daemon,!windows
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"os"
     8  	"syscall"
     9  
    10  	apiserver "github.com/docker/docker/api/server"
    11  	"github.com/docker/docker/daemon"
    12  	"github.com/docker/docker/pkg/system"
    13  
    14  	_ "github.com/docker/docker/daemon/execdriver/native"
    15  )
    16  
    17  func setPlatformServerConfig(serverConfig *apiserver.Config, daemonCfg *daemon.Config) *apiserver.Config {
    18  	serverConfig.SocketGroup = daemonCfg.SocketGroup
    19  	serverConfig.EnableCors = daemonCfg.EnableCors
    20  	serverConfig.CorsHeaders = daemonCfg.CorsHeaders
    21  
    22  	return serverConfig
    23  }
    24  
    25  // currentUserIsOwner checks whether the current user is the owner of the given
    26  // file.
    27  func currentUserIsOwner(f string) bool {
    28  	if fileInfo, err := system.Stat(f); err == nil && fileInfo != nil {
    29  		if int(fileInfo.UID()) == os.Getuid() {
    30  			return true
    31  		}
    32  	}
    33  	return false
    34  }
    35  
    36  // setDefaultUmask sets the umask to 0022 to avoid problems
    37  // caused by custom umask
    38  func setDefaultUmask() error {
    39  	desiredUmask := 0022
    40  	syscall.Umask(desiredUmask)
    41  	if umask := syscall.Umask(desiredUmask); umask != desiredUmask {
    42  		return fmt.Errorf("failed to set umask: expected %#o, got %#o", desiredUmask, umask)
    43  	}
    44  
    45  	return nil
    46  }
    47  
    48  func getDaemonConfDir() string {
    49  	return "/etc/docker"
    50  }