summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne CHAMPETIER2016-05-29 23:39:12 +0000
committerJohn Crispin2016-06-01 08:27:34 +0000
commit8e4fd3397dcdf79c0e0af9e12dc2bcf22d83d645 (patch)
treec9ab3b469ef0209fd6d67d6b59989a025680276f
parent9a6f83d3c168523ac7b898ae481c2fd8c501d6a6 (diff)
downloadprocd-8e4fd3397dcdf79c0e0af9e12dc2bcf22d83d645.tar.gz
jail: call chdir(/) after pivot_root()
pivot_root(2) man page recommend calling chdir(/), so do it Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
-rw-r--r--jail/jail.c4
1 files changed, 4 insertions, 0 deletions
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);