jail: call chdir(/) after pivot_root()
authorEtienne CHAMPETIER <champetier.etienne@gmail.com>
Sun, 29 May 2016 23:39:12 +0000 (23:39 +0000)
committerJohn Crispin <john@phrozen.org>
Wed, 1 Jun 2016 08:27:34 +0000 (10:27 +0200)
pivot_root(2) man page recommend calling chdir(/), so do it

Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
jail/jail.c

index 541363aab4632daed080188b8b461a2de072ba75..8157a8ff6f0ccc77434c26e45dded40549a8ff14 100644 (file)
@@ -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);