2015-07-09 18:47:32 -07:00
|
|
|
// +build linux
|
|
|
|
|
2014-04-17 14:43:01 -07:00
|
|
|
package daemon
|
2014-03-07 18:42:29 -08:00
|
|
|
|
|
|
|
import (
|
2014-12-09 00:45:42 +00:00
|
|
|
"errors"
|
2014-03-13 17:03:09 +01:00
|
|
|
"fmt"
|
2014-05-23 17:51:16 -07:00
|
|
|
"strings"
|
|
|
|
|
2014-07-24 22:19:50 +00:00
|
|
|
"github.com/docker/docker/runconfig"
|
2015-07-16 16:00:55 -07:00
|
|
|
"github.com/opencontainers/runc/libcontainer/selinux"
|
2014-03-07 18:42:29 -08:00
|
|
|
)
|
|
|
|
|
2015-07-09 18:47:32 -07:00
|
|
|
func selinuxSetDisabled() {
|
|
|
|
selinux.SetDisabled()
|
|
|
|
}
|
|
|
|
|
|
|
|
func selinuxFreeLxcContexts(label string) {
|
|
|
|
selinux.FreeLxcContexts(label)
|
|
|
|
}
|
|
|
|
|
|
|
|
func selinuxEnabled() bool {
|
|
|
|
return selinux.SelinuxEnabled()
|
|
|
|
}
|
|
|
|
|
2014-12-09 00:45:42 +00:00
|
|
|
func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) {
|
2014-03-13 17:03:09 +01:00
|
|
|
if hostConfig == nil {
|
2014-12-09 00:45:42 +00:00
|
|
|
return nil, nil
|
2014-03-13 17:03:09 +01:00
|
|
|
}
|
|
|
|
|
2014-09-29 22:40:26 +00:00
|
|
|
out := []string{}
|
|
|
|
|
2014-03-13 17:03:09 +01:00
|
|
|
// merge in the lxc conf options into the generic config map
|
|
|
|
if lxcConf := hostConfig.LxcConf; lxcConf != nil {
|
2015-04-10 17:05:21 -07:00
|
|
|
lxSlice := lxcConf.Slice()
|
|
|
|
for _, pair := range lxSlice {
|
2014-03-13 17:03:09 +01:00
|
|
|
// because lxc conf gets the driver name lxc.XXXX we need to trim it off
|
|
|
|
// and let the lxc driver add it back later if needed
|
2014-12-09 00:45:42 +00:00
|
|
|
if !strings.Contains(pair.Key, ".") {
|
|
|
|
return nil, errors.New("Illegal Key passed into LXC Configurations")
|
|
|
|
}
|
2014-03-13 17:03:09 +01:00
|
|
|
parts := strings.SplitN(pair.Key, ".", 2)
|
2014-09-29 22:40:26 +00:00
|
|
|
out = append(out, fmt.Sprintf("%s=%s", parts[1], pair.Value))
|
2014-03-13 17:03:09 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-29 22:40:26 +00:00
|
|
|
|
2014-12-09 00:45:42 +00:00
|
|
|
return out, nil
|
2014-03-13 17:03:09 +01:00
|
|
|
}
|