Parcourir la source

Change default label of container volumes to shared SELinux Label

Since these will be shared between containers we want to label
them as svirt_sandbox_file_t:s0.  That will allow multiple containers
to write to them.

Currently we are allowing container domains to read/write all content in
/var/lib/docker because of container volumes.  This is a big security hole
in our SELinux story.

This patch will allow us to tighten up the security of docker containers.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Dan Walsh il y a 11 ans
Parent
commit
73617e5e18
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      daemon/graphdriver/vfs/driver.go

+ 7 - 1
daemon/graphdriver/vfs/driver.go

@@ -3,10 +3,12 @@ package vfs
 import (
 import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
-	"github.com/docker/docker/daemon/graphdriver"
 	"os"
 	"os"
 	"os/exec"
 	"os/exec"
 	"path"
 	"path"
+
+	"github.com/docker/docker/daemon/graphdriver"
+	"github.com/docker/libcontainer/label"
 )
 )
 
 
 func init() {
 func init() {
@@ -67,6 +69,10 @@ func (d *Driver) Create(id, parent string) error {
 	if err := os.Mkdir(dir, 0755); err != nil {
 	if err := os.Mkdir(dir, 0755); err != nil {
 		return err
 		return err
 	}
 	}
+	opts := []string{"level:s0"}
+	if _, mountLabel, err := label.InitLabels(opts); err == nil {
+		label.Relabel(dir, mountLabel, "")
+	}
 	if parent == "" {
 	if parent == "" {
 		return nil
 		return nil
 	}
 	}