libbb: make xchroot do a chdir("/") after chroot
[oweals/busybox.git] / libbb / xfuncs_printf.c
index 56ee459e45ffa4549692642646f7207ac19de5ce..d8a42ba0bccb00a49fd250606965402cd7830c21 100644 (file)
@@ -362,6 +362,7 @@ void FAST_FUNC xchroot(const char *path)
 {
        if (chroot(path))
                bb_perror_msg_and_die("can't change root directory to %s", path);
+       xchdir("/");
 }
 
 // Print a warning message if opendir() fails, but don't die.