Check supplied hostname before using it.
| ... | ... |
@@ -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() |