[BusyBox] chroot fix
Erik Andersen
andersen at lineo.com
Fri Jun 2 17:57:49 UTC 2000
On Fri Jun 02, 2000 at 12:35:55PM -0400, Pavel Roskin wrote:
> Hello!
>
> This is a fix for chroot
> - Fixed error message when the command is not specified (possibly crash on
> libc5 systems!)
> - Debugging output removed
> - Using fatalError() whenever appropriate
>
> Regards,
> Pavel Roskin
>
> =============================
> diff -u -r1.3 chroot.c
> --- chroot.c 2000/05/17 20:57:41 1.3
> +++ chroot.c 2000/06/02 16:26:38
> @@ -38,6 +38,8 @@
>
> int chroot_main(int argc, char **argv)
> {
> + char *prog;
> +
> if ((argc < 2) || (**(argv + 1) == '-')) {
> usage(chroot_usage);
> }
> @@ -45,27 +47,24 @@
> argv++;
>
> if (chroot(*argv) || (chdir("/"))) {
> - fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
> + fatalError("chroot: cannot change root directory to %s: %s\n",
> *argv, strerror(errno));
> - exit(FALSE);
> }
>
> argc--;
> argv++;
> if (argc >= 1) {
> - fprintf(stderr, "command: %s\n", *argv);
> + prog = *argv;
> execvp(*argv, argv);
> } else {
> - char *prog;
>
> prog = getenv("SHELL");
> if (!prog)
> prog = "/bin/sh";
> execlp(prog, prog, NULL);
> }
> - fprintf(stderr, "chroot: cannot execute %s: %s\n",
> - *argv, strerror(errno));
> - exit(FALSE);
> + fatalError("chroot: cannot execute %s: %s\n",
> + prog, strerror(errno));
> }
>
Applied. Good spotting.
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list