Merge pull request #4953 from rhatdan/selinux
These two patches should fix problems we see with running docker in the wild.
This commit is contained in:
commit
534990bda9
4 changed files with 15 additions and 4 deletions
|
@ -21,3 +21,6 @@ func SetFileLabel(path string, fileLabel string) error {
|
||||||
func GetPidCon(pid int) (string, error) {
|
func GetPidCon(pid int) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
}
|
||||||
|
|
|
@ -67,3 +67,7 @@ func SetFileLabel(path string, fileLabel string) error {
|
||||||
func GetPidCon(pid int) (string, error) {
|
func GetPidCon(pid int) (string, error) {
|
||||||
return selinux.Getpidcon(pid)
|
return selinux.Getpidcon(pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
selinux.SelinuxEnabled()
|
||||||
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ func (ns *linuxNs) Init(container *libcontainer.Container, uncleanRootfs, consol
|
||||||
if err := setupNetwork(container, context); err != nil {
|
if err := setupNetwork(container, context); err != nil {
|
||||||
return fmt.Errorf("setup networking %s", err)
|
return fmt.Errorf("setup networking %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label.Init()
|
||||||
ns.logger.Println("setup mount namespace")
|
ns.logger.Println("setup mount namespace")
|
||||||
if err := setupNewMountNamespace(rootfs, container.Mounts, console, container.ReadonlyFs, container.NoPivotRoot, container.Context["mount_label"]); err != nil {
|
if err := setupNewMountNamespace(rootfs, container.Mounts, console, container.ReadonlyFs, container.NoPivotRoot, container.Context["mount_label"]); err != nil {
|
||||||
return fmt.Errorf("setup mount namespace %s", err)
|
return fmt.Errorf("setup mount namespace %s", err)
|
||||||
|
|
|
@ -313,12 +313,9 @@ func GetLxcContexts() (processLabel string, fileLabel string) {
|
||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
lxcPath := fmt.Sprintf("%s/content/lxc_contexts", GetSELinuxPolicyRoot())
|
lxcPath := fmt.Sprintf("%s/content/lxc_contexts", GetSELinuxPolicyRoot())
|
||||||
fileLabel = "system_u:object_r:svirt_sandbox_file_t:s0"
|
|
||||||
processLabel = "system_u:system_r:svirt_lxc_net_t:s0"
|
|
||||||
|
|
||||||
in, err := os.Open(lxcPath)
|
in, err := os.Open(lxcPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
goto exit
|
return "", ""
|
||||||
}
|
}
|
||||||
defer in.Close()
|
defer in.Close()
|
||||||
|
|
||||||
|
@ -352,6 +349,11 @@ func GetLxcContexts() (processLabel string, fileLabel string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if processLabel == "" || fileLabel == "" {
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mcs := IntToMcs(os.Getpid(), 1024)
|
mcs := IntToMcs(os.Getpid(), 1024)
|
||||||
scon := NewContext(processLabel)
|
scon := NewContext(processLabel)
|
||||||
|
|
Loading…
Reference in a new issue