| ... | ... |
@@ -4,6 +4,16 @@ import ( |
| 4 | 4 |
"encoding/json" |
| 5 | 5 |
"errors" |
| 6 | 6 |
"fmt" |
| 7 |
+ "io" |
|
| 8 |
+ "io/ioutil" |
|
| 9 |
+ "log" |
|
| 10 |
+ "os" |
|
| 11 |
+ "path" |
|
| 12 |
+ "strings" |
|
| 13 |
+ "sync" |
|
| 14 |
+ "syscall" |
|
| 15 |
+ "time" |
|
| 16 |
+ |
|
| 7 | 17 |
"github.com/dotcloud/docker/archive" |
| 8 | 18 |
"github.com/dotcloud/docker/daemon/execdriver" |
| 9 | 19 |
"github.com/dotcloud/docker/daemon/graphdriver" |
| ... | ... |
@@ -14,15 +24,6 @@ import ( |
| 14 | 14 |
"github.com/dotcloud/docker/pkg/label" |
| 15 | 15 |
"github.com/dotcloud/docker/runconfig" |
| 16 | 16 |
"github.com/dotcloud/docker/utils" |
| 17 |
- "io" |
|
| 18 |
- "io/ioutil" |
|
| 19 |
- "log" |
|
| 20 |
- "os" |
|
| 21 |
- "path" |
|
| 22 |
- "strings" |
|
| 23 |
- "sync" |
|
| 24 |
- "syscall" |
|
| 25 |
- "time" |
|
| 26 | 17 |
) |
| 27 | 18 |
|
| 28 | 19 |
const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| ... | ... |
@@ -124,7 +125,10 @@ func (container *Container) FromDisk() error {
|
| 124 | 124 |
if err := json.Unmarshal(data, container); err != nil && !strings.Contains(err.Error(), "docker.PortMapping") {
|
| 125 | 125 |
return err |
| 126 | 126 |
} |
| 127 |
- label.ReserveLabel(container.ProcessLabel) |
|
| 127 |
+ |
|
| 128 |
+ if err := label.ReserveLabel(container.ProcessLabel); err != nil {
|
|
| 129 |
+ return err |
|
| 130 |
+ } |
|
| 128 | 131 |
return container.readHostConfig() |
| 129 | 132 |
} |
| 130 | 133 |
|
| ... | ... |
@@ -389,14 +393,6 @@ func (container *Container) Start() (err error) {
|
| 389 | 389 |
return err |
| 390 | 390 |
} |
| 391 | 391 |
|
| 392 |
- process, mount, err := label.GenLabels("")
|
|
| 393 |
- if err != nil {
|
|
| 394 |
- return err |
|
| 395 |
- } |
|
| 396 |
- |
|
| 397 |
- container.MountLabel = mount |
|
| 398 |
- container.ProcessLabel = process |
|
| 399 |
- |
|
| 400 | 392 |
if err := container.Mount(); err != nil {
|
| 401 | 393 |
return err |
| 402 | 394 |
} |
| ... | ... |
@@ -3,6 +3,16 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"container/list" |
| 5 | 5 |
"fmt" |
| 6 |
+ "io" |
|
| 7 |
+ "io/ioutil" |
|
| 8 |
+ "log" |
|
| 9 |
+ "os" |
|
| 10 |
+ "path" |
|
| 11 |
+ "regexp" |
|
| 12 |
+ "strings" |
|
| 13 |
+ "sync" |
|
| 14 |
+ "time" |
|
| 15 |
+ |
|
| 6 | 16 |
"github.com/dotcloud/docker/archive" |
| 7 | 17 |
"github.com/dotcloud/docker/daemon/execdriver" |
| 8 | 18 |
"github.com/dotcloud/docker/daemon/execdriver/execdrivers" |
| ... | ... |
@@ -17,20 +27,12 @@ import ( |
| 17 | 17 |
"github.com/dotcloud/docker/graph" |
| 18 | 18 |
"github.com/dotcloud/docker/image" |
| 19 | 19 |
"github.com/dotcloud/docker/pkg/graphdb" |
| 20 |
+ "github.com/dotcloud/docker/pkg/label" |
|
| 20 | 21 |
"github.com/dotcloud/docker/pkg/mount" |
| 21 | 22 |
"github.com/dotcloud/docker/pkg/selinux" |
| 22 | 23 |
"github.com/dotcloud/docker/pkg/sysinfo" |
| 23 | 24 |
"github.com/dotcloud/docker/runconfig" |
| 24 | 25 |
"github.com/dotcloud/docker/utils" |
| 25 |
- "io" |
|
| 26 |
- "io/ioutil" |
|
| 27 |
- "log" |
|
| 28 |
- "os" |
|
| 29 |
- "path" |
|
| 30 |
- "regexp" |
|
| 31 |
- "strings" |
|
| 32 |
- "sync" |
|
| 33 |
- "time" |
|
| 34 | 26 |
) |
| 35 | 27 |
|
| 36 | 28 |
// Set the max depth to the aufs default that most |
| ... | ... |
@@ -535,6 +537,11 @@ func (daemon *Daemon) newContainer(name string, config *runconfig.Config, img *i |
| 535 | 535 |
ExecDriver: daemon.execDriver.Name(), |
| 536 | 536 |
} |
| 537 | 537 |
container.root = daemon.containerRoot(container.ID) |
| 538 |
+ |
|
| 539 |
+ if container.MountLabel, container.ProcessLabel, err = label.GenLabels(""); err != nil {
|
|
| 540 |
+ return nil, err |
|
| 541 |
+ } |
|
| 542 |
+ |
|
| 538 | 543 |
return container, nil |
| 539 | 544 |
} |
| 540 | 545 |
|
| ... | ... |
@@ -6,8 +6,6 @@ import ( |
| 6 | 6 |
"encoding/json" |
| 7 | 7 |
"errors" |
| 8 | 8 |
"fmt" |
| 9 |
- "github.com/dotcloud/docker/pkg/label" |
|
| 10 |
- "github.com/dotcloud/docker/utils" |
|
| 11 | 9 |
"io" |
| 12 | 10 |
"io/ioutil" |
| 13 | 11 |
"path" |
| ... | ... |
@@ -17,6 +15,9 @@ import ( |
| 17 | 17 |
"sync" |
| 18 | 18 |
"syscall" |
| 19 | 19 |
"time" |
| 20 |
+ |
|
| 21 |
+ "github.com/dotcloud/docker/pkg/label" |
|
| 22 |
+ "github.com/dotcloud/docker/utils" |
|
| 20 | 23 |
) |
| 21 | 24 |
|
| 22 | 25 |
var ( |
| ... | ... |
@@ -858,7 +859,6 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
|
| 858 | 858 |
defer devices.Unlock() |
| 859 | 859 |
|
| 860 | 860 |
if info.mountCount > 0 {
|
| 861 |
- fmt.Printf("---> already mounted\n")
|
|
| 862 | 861 |
if path != info.mountPath {
|
| 863 | 862 |
return fmt.Errorf("Trying to mount devmapper device in multple places (%s, %s)", info.mountPath, path)
|
| 864 | 863 |
} |
| ... | ... |
@@ -874,12 +874,9 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
|
| 874 | 874 |
var flags uintptr = sysMsMgcVal |
| 875 | 875 |
|
| 876 | 876 |
mountOptions := label.FormatMountLabel("discard", mountLabel)
|
| 877 |
- fmt.Printf("-----> setting mount label %s\n", mountOptions)
|
|
| 878 |
- |
|
| 879 | 877 |
err = sysMount(info.DevName(), path, "ext4", flags, mountOptions) |
| 880 | 878 |
if err != nil && err == sysEInval {
|
| 881 | 879 |
mountOptions = label.FormatMountLabel("", mountLabel)
|
| 882 |
- fmt.Printf("-----> setting mount label after error %s\n", mountOptions)
|
|
| 883 | 880 |
err = sysMount(info.DevName(), path, "ext4", flags, mountOptions) |
| 884 | 881 |
} |
| 885 | 882 |
if err != nil {
|
| ... | ... |
@@ -4,8 +4,9 @@ package label |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 | 6 |
"fmt" |
| 7 |
- "github.com/dotcloud/docker/pkg/selinux" |
|
| 8 | 7 |
"strings" |
| 8 |
+ |
|
| 9 |
+ "github.com/dotcloud/docker/pkg/selinux" |
|
| 9 | 10 |
) |
| 10 | 11 |
|
| 11 | 12 |
func GenLabels(options string) (string, string, error) {
|
| ... | ... |
@@ -76,6 +77,7 @@ func Init() {
|
| 76 | 76 |
selinux.SelinuxEnabled() |
| 77 | 77 |
} |
| 78 | 78 |
|
| 79 |
-func ReserveLabel(label string) {
|
|
| 79 |
+func ReserveLabel(label string) error {
|
|
| 80 | 80 |
selinux.ReserveLabel(label) |
| 81 |
+ return nil |
|
| 81 | 82 |
} |