[LEDE-DEV] [PATCH procd 1/7] jail: call chdir(/) after pivot_root()

Etienne CHAMPETIER champetier.etienne at gmail.com
Sun May 29 16:39:12 PDT 2016


pivot_root(2) man page recommend calling chdir(/), so do it

Signed-off-by: Etienne CHAMPETIER <champetier.etienne at gmail.com>
---
 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);
-- 
1.9.1




More information about the Lede-dev mailing list