Last change
on this file since 3839 was 3232, checked in by Bruno Cornec, 11 years ago |
- Update mindi-busybox to 1.21.1
|
File size:
1.2 KB
|
Line | |
---|
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 | *
|
---|
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
---|
11 |
|
---|
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 |
|
---|
25 | #include "libbb.h"
|
---|
26 |
|
---|
27 | int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
28 | int chroot_main(int argc UNUSED_PARAM, char **argv)
|
---|
29 | {
|
---|
30 | ++argv;
|
---|
31 | if (!*argv)
|
---|
32 | bb_show_usage();
|
---|
33 | xchroot(*argv);
|
---|
34 |
|
---|
35 | ++argv;
|
---|
36 | if (!*argv) { /* no 2nd param (PROG), use shell */
|
---|
37 | argv -= 2;
|
---|
38 | argv[0] = (char *) get_shell_name();
|
---|
39 | argv[1] = (char *) "-i"; /* GNU coreutils 8.4 compat */
|
---|
40 | /*argv[2] = NULL; - already is */
|
---|
41 | }
|
---|
42 |
|
---|
43 | BB_EXECVP_or_die(argv);
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.