*
*/
-#include "internal.h"
+#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
-
-static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nRun COMMAND with root directory set to NEWROOT.\n"
-#endif
- ;
-
-
-
int chroot_main(int argc, char **argv)
{
char *prog;
argv++;
if (chroot(*argv) || (chdir("/"))) {
- fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
+ perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
prog = *argv;
execvp(*argv, argv);
} else {
+#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
+#else
+ shell_main(argc, argv);
+ return EXIT_SUCCESS;
+#endif
}
- fatalError("cannot execute %s: %s\n", prog, strerror(errno));
+ perror_msg_and_die("cannot execute %s", prog);
}