From 2499d43325a647148c183a0fc22055a9dff0a0c7 Mon Sep 17 00:00:00 2001 From: Rohit Jnagal Date: Mon, 5 May 2014 18:12:25 +0000 Subject: [PATCH] Check supplied hostname before using it. Docker-DCO-1.1-Signed-off-by: Rohit Jnagal (github: rjnagal) --- nsinit/init.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nsinit/init.go b/nsinit/init.go index faec12af..99974c6c 100644 --- a/nsinit/init.go +++ b/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)