github.com/damirazo/docker@v1.9.0/daemon/utils_linux.go (about)

     1  // +build linux
     2  
     3  package daemon
     4  
     5  import (
     6  	"errors"
     7  	"fmt"
     8  	"strings"
     9  
    10  	"github.com/docker/docker/runconfig"
    11  	"github.com/opencontainers/runc/libcontainer/selinux"
    12  )
    13  
    14  func selinuxSetDisabled() {
    15  	selinux.SetDisabled()
    16  }
    17  
    18  func selinuxFreeLxcContexts(label string) {
    19  	selinux.FreeLxcContexts(label)
    20  }
    21  
    22  func selinuxEnabled() bool {
    23  	return selinux.SelinuxEnabled()
    24  }
    25  
    26  func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) {
    27  	if hostConfig == nil {
    28  		return nil, nil
    29  	}
    30  
    31  	out := []string{}
    32  
    33  	// merge in the lxc conf options into the generic config map
    34  	if lxcConf := hostConfig.LxcConf; lxcConf != nil {
    35  		lxSlice := lxcConf.Slice()
    36  		for _, pair := range lxSlice {
    37  			// because lxc conf gets the driver name lxc.XXXX we need to trim it off
    38  			// and let the lxc driver add it back later if needed
    39  			if !strings.Contains(pair.Key, ".") {
    40  				return nil, errors.New("Illegal Key passed into LXC Configurations")
    41  			}
    42  			parts := strings.SplitN(pair.Key, ".", 2)
    43  			out = append(out, fmt.Sprintf("%s=%s", parts[1], pair.Value))
    44  		}
    45  	}
    46  
    47  	return out, nil
    48  }