From 8e4fd3397dcdf79c0e0af9e12dc2bcf22d83d645 Mon Sep 17 00:00:00 2001 From: Etienne CHAMPETIER Date: Sun, 29 May 2016 23:39:12 +0000 Subject: [PATCH] jail: call chdir(/) after pivot_root() pivot_root(2) man page recommend calling chdir(/), so do it Signed-off-by: Etienne CHAMPETIER --- jail/jail.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jail/jail.c b/jail/jail.c index 541363a..8157a8f 100644 --- a/jail/jail.c +++ b/jail/jail.c @@ -162,6 +162,10 @@ static int build_jail_fs(void) ERROR("pivot_root failed: %s\n", strerror(errno)); return -1; } + if (chdir("/")) { + ERROR("chdir(/) failed: %s\n", strerror(errno)); + return -1; + } snprintf(dirbuf, sizeof(dirbuf), "/old%s", jail_root); rmdir(dirbuf); -- 2.25.1