Browse code

Merge pull request #5630 from rjnagal/libcontainer-fixes

Check supplied hostname before using it.

Michael Crosby authored on 2014/05/07 01:49:52
Showing 1 changed files
... ...
@@ -66,8 +66,10 @@ func Init(container *libcontainer.Container, uncleanRootfs, consolePath string,
66 66
 	if err := mount.InitializeMountNamespace(rootfs, consolePath, container); err != nil {
67 67
 		return fmt.Errorf("setup mount namespace %s", err)
68 68
 	}
69
-	if err := system.Sethostname(container.Hostname); err != nil {
70
-		return fmt.Errorf("sethostname %s", err)
69
+	if container.Hostname != "" {
70
+		if err := system.Sethostname(container.Hostname); err != nil {
71
+			return fmt.Errorf("sethostname %s", err)
72
+		}
71 73
 	}
72 74
 
73 75
 	runtime.LockOSThread()