From: Etienne CHAMPETIER Date: Sun, 29 May 2016 23:39:12 +0000 (+0000) Subject: jail: call chdir(/) after pivot_root() X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fprocd.git;a=commitdiff_plain;h=8e4fd3397dcdf79c0e0af9e12dc2bcf22d83d645;hp=9a6f83d3c168523ac7b898ae481c2fd8c501d6a6;ds=sidebyside jail: call chdir(/) after pivot_root() pivot_root(2) man page recommend calling chdir(/), so do it Signed-off-by: Etienne CHAMPETIER --- 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);