From ed7be1d0829047eb08aca997abc0fbdfde0e36c3 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 21 Jan 2016 11:08:32 -0800 Subject: [PATCH] Only set cwd when not empty For existing consumers of libconatiner to not require cwd inside the libcontainer code. This can be done at the runc level and is already evaluated there. Signed-off-by: Michael Crosby --- libcontainer/init_linux.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go index 2d252bbf..57e53782 100644 --- a/libcontainer/init_linux.go +++ b/libcontainer/init_linux.go @@ -134,8 +134,10 @@ func finalizeNamespace(config *initConfig) error { if err := w.drop(); err != nil { return err } - if err := syscall.Chdir(config.Cwd); err != nil { - return err + if config.Cwd != "" { + if err := syscall.Chdir(config.Cwd); err != nil { + return err + } } return nil }