Explorar o código

Check supplied hostname before using it.

Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
Rohit Jnagal %!s(int64=11) %!d(string=hai) anos
pai
achega
412324cfbe
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      pkg/libcontainer/nsinit/init.go

+ 4 - 2
pkg/libcontainer/nsinit/init.go

@@ -65,8 +65,10 @@ func Init(container *libcontainer.Container, uncleanRootfs, consolePath string,
 	if err := mount.InitializeMountNamespace(rootfs, consolePath, container); err != nil {
 		return fmt.Errorf("setup mount namespace %s", err)
 	}
-	if err := system.Sethostname(container.Hostname); err != nil {
-		return fmt.Errorf("sethostname %s", err)
+	if container.Hostname != "" {
+		if err := system.Sethostname(container.Hostname); err != nil {
+			return fmt.Errorf("sethostname %s", err)
+		}
 	}
 	if err := FinalizeNamespace(container); err != nil {
 		return fmt.Errorf("finalize namespace %s", err)