Last change
on this file since 3801 was 3232, checked in by Bruno Cornec, 11 years ago |
- Update mindi-busybox to 1.21.1
|
File size:
1.2 KB
|
Rev | Line | |
---|
[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
| 3 | * Mini chroot implementation for busybox
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
---|
| 6 | *
|
---|
[2725] | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
[821] | 8 | */
|
---|
| 9 |
|
---|
| 10 | /* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
---|
| 11 |
|
---|
[3232] | 12 | //usage:#define chroot_trivial_usage
|
---|
| 13 | //usage: "NEWROOT [PROG ARGS]"
|
---|
| 14 | //usage:#define chroot_full_usage "\n\n"
|
---|
| 15 | //usage: "Run PROG with root directory set to NEWROOT"
|
---|
| 16 | //usage:
|
---|
| 17 | //usage:#define chroot_example_usage
|
---|
| 18 | //usage: "$ ls -l /bin/ls\n"
|
---|
| 19 | //usage: "lrwxrwxrwx 1 root root 12 Apr 13 00:46 /bin/ls -> /BusyBox\n"
|
---|
| 20 | //usage: "# mount /dev/hdc1 /mnt -t minix\n"
|
---|
| 21 | //usage: "# chroot /mnt\n"
|
---|
| 22 | //usage: "# ls -l /bin/ls\n"
|
---|
| 23 | //usage: "-rwxr-xr-x 1 root root 40816 Feb 5 07:45 /bin/ls*\n"
|
---|
| 24 |
|
---|
[1765] | 25 | #include "libbb.h"
|
---|
[821] | 26 |
|
---|
[2725] | 27 | int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 28 | int chroot_main(int argc UNUSED_PARAM, char **argv)
|
---|
[821] | 29 | {
|
---|
[2725] | 30 | ++argv;
|
---|
| 31 | if (!*argv)
|
---|
[821] | 32 | bb_show_usage();
|
---|
[2725] | 33 | xchroot(*argv);
|
---|
[821] | 34 |
|
---|
| 35 | ++argv;
|
---|
[2725] | 36 | if (!*argv) { /* no 2nd param (PROG), use shell */
|
---|
[821] | 37 | argv -= 2;
|
---|
[3232] | 38 | argv[0] = (char *) get_shell_name();
|
---|
| 39 | argv[1] = (char *) "-i"; /* GNU coreutils 8.4 compat */
|
---|
| 40 | /*argv[2] = NULL; - already is */
|
---|
[821] | 41 | }
|
---|
| 42 |
|
---|
[2725] | 43 | BB_EXECVP_or_die(argv);
|
---|
[821] | 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.