aboutsummaryrefslogtreecommitdiff
path: root/coreutils/chroot.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-12 15:42:48 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-12 15:42:48 +0000
commit41c2646fd13728f4fa105fea568d451ab26b4012 (patch)
tree34245558cd448f01969679fc420de4dfd246dc13 /coreutils/chroot.c
parent1e20903d90990dd5b48040a6ad69501e64414bfc (diff)
downloadbusybox-w32-41c2646fd13728f4fa105fea568d451ab26b4012.tar.gz
busybox-w32-41c2646fd13728f4fa105fea568d451ab26b4012.tar.bz2
busybox-w32-41c2646fd13728f4fa105fea568d451ab26b4012.zip
Latest and greatest.
-Erik git-svn-id: svn://busybox.net/trunk/busybox@18 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils/chroot.c')
-rw-r--r--coreutils/chroot.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index d39549496..3b6fdae3b 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -20,8 +20,9 @@
20 */ 20 */
21 21
22#include "internal.h" 22#include "internal.h"
23#include <stdlib.h>
23#include <stdio.h> 24#include <stdio.h>
24#include <unistd.h> 25#include <errno.h>
25 26
26 27
27static const char chroot_usage[] = "NEWROOT [COMMAND...]\n" 28static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
@@ -31,18 +32,17 @@ static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
31 32
32int chroot_main(int argc, char **argv) 33int chroot_main(int argc, char **argv)
33{ 34{
34 if (argc < 2) { 35 if ( (argc < 2) || (**(argv+1) == '-') ) {
35 fprintf(stderr, "Usage: %s %s", *argv, chroot_usage); 36 fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
36 return( FALSE); 37 exit( FALSE);
37 } 38 }
38 argc--; 39 argc--;
39 argv++; 40 argv++;
40 41
41 fprintf(stderr, "new root: %s\n", *argv);
42
43 if (chroot (*argv) || (chdir ("/"))) { 42 if (chroot (*argv) || (chdir ("/"))) {
44 perror("cannot chroot"); 43 fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
45 return( FALSE); 44 *argv, strerror(errno));
45 exit( FALSE);
46 } 46 }
47 47
48 argc--; 48 argc--;
@@ -56,10 +56,10 @@ int chroot_main(int argc, char **argv)
56 prog = getenv ("SHELL"); 56 prog = getenv ("SHELL");
57 if (!prog) 57 if (!prog)
58 prog = "/bin/sh"; 58 prog = "/bin/sh";
59 fprintf(stderr, "no command. running: %s\n", prog);
60 execlp (prog, prog, NULL); 59 execlp (prog, prog, NULL);
61 } 60 }
62 perror("cannot exec"); 61 fprintf(stderr, "chroot: cannot execute %s: %s\n",
63 return(FALSE); 62 *argv, strerror(errno));
63 exit( FALSE);
64} 64}
65 65