Parcourir la source

Ensure that SELinux Options are set when seccomp is already set

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Mrunal Patel il y a 8 ans
Parent
commit
4c10c2ded3
2 fichiers modifiés avec 8 ajouts et 7 suppressions
  1. 4 5
      daemon/daemon_unix.go
  2. 4 2
      daemon/start.go

+ 4 - 5
daemon/daemon_unix.go

@@ -248,12 +248,11 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf
 		hostConfig.ShmSize = container.DefaultSHMSize
 		hostConfig.ShmSize = container.DefaultSHMSize
 	}
 	}
 	var err error
 	var err error
-	if hostConfig.SecurityOpt == nil {
-		hostConfig.SecurityOpt, err = daemon.generateSecurityOpt(hostConfig.IpcMode, hostConfig.PidMode, hostConfig.Privileged)
-		if err != nil {
-			return err
-		}
+	opts, err := daemon.generateSecurityOpt(hostConfig.IpcMode, hostConfig.PidMode, hostConfig.Privileged)
+	if err != nil {
+		return err
 	}
 	}
+	hostConfig.SecurityOpt = append(hostConfig.SecurityOpt, opts...)
 	if hostConfig.MemorySwappiness == nil {
 	if hostConfig.MemorySwappiness == nil {
 		defaultSwappiness := int64(-1)
 		defaultSwappiness := int64(-1)
 		hostConfig.MemorySwappiness = &defaultSwappiness
 		hostConfig.MemorySwappiness = &defaultSwappiness

+ 4 - 2
daemon/start.go

@@ -78,8 +78,10 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos
 	}
 	}
 	// Adapt for old containers in case we have updates in this function and
 	// Adapt for old containers in case we have updates in this function and
 	// old containers never have chance to call the new function in create stage.
 	// old containers never have chance to call the new function in create stage.
-	if err := daemon.adaptContainerSettings(container.HostConfig, false); err != nil {
-		return err
+	if hostConfig != nil {
+		if err := daemon.adaptContainerSettings(container.HostConfig, false); err != nil {
+			return err
+		}
 	}
 	}
 
 
 	return daemon.containerStart(container, checkpoint, checkpointDir, true)
 	return daemon.containerStart(container, checkpoint, checkpointDir, true)