Mercurial > hg > toybox
annotate toys/chroot.c @ 233:d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
toys/*.c. Move relevant info into comment at the top of each toys/*.c. Also
convert more of Makefile into a thin wrapper around shell scripts that actually
do the work. (Makefile is only still there for the user interface.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 19 Jan 2008 17:08:39 -0600 |
parents | 0efba0e70c43 |
children | 163498bf547b |
rev | line source |
---|---|
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
1 /* vi: set sw=4 ts=4: |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
2 * |
191 | 3 * chroot.c - Run command in new root directory. |
193
0efba0e70c43
Other chroots fall back to "/bin/sh -i", so add the -i.
Rob Landley <rob@landley.net>
parents:
191
diff
changeset
|
4 * |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
5 * Copyright 2007 Rob Landley <rob@landley.net> |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
6 * |
193
0efba0e70c43
Other chroots fall back to "/bin/sh -i", so add the -i.
Rob Landley <rob@landley.net>
parents:
191
diff
changeset
|
7 * Not in SUSv3. |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
8 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
9 config CHROOT |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
10 bool "chroot" |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
11 default y |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
12 help |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
13 usage: chroot NEWPATH [commandline...] |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
14 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
15 Run command within a new root directory. If no command, run /bin/sh. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
193
diff
changeset
|
16 */ |
191 | 17 |
18 #include "toys.h" | |
19 | |
20 void chroot_main(void) | |
21 { | |
193
0efba0e70c43
Other chroots fall back to "/bin/sh -i", so add the -i.
Rob Landley <rob@landley.net>
parents:
191
diff
changeset
|
22 char *binsh[] = {"/bin/sh", "-i", 0}; |
191 | 23 if (chdir(*toys.optargs) || chroot(".")) |
24 perror_exit("%s", *toys.optargs); | |
25 xexec(toys.optargs[1] ? toys.optargs+1 : binsh); | |
26 } |