From cc8ed39b240180b58810784f844e253263594ac3 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 5 Oct 1999 16:24:54 +0000 Subject: Initial revision --- chroot.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 chroot.c (limited to 'chroot.c') diff --git a/chroot.c b/chroot.c new file mode 100644 index 000000000..ca0bfcf3f --- /dev/null +++ b/chroot.c @@ -0,0 +1,32 @@ +#include "internal.h" +#include +#include + + +const char chroot_usage[] = "chroot directory [command]\n" + "Run a command with special root directory.\n"; + +extern int +chroot_main (struct FileInfo *i, int argc, char **argv) +{ + char *prog; + + if (chroot (argv[1])) + { + name_and_error ("cannot chroot to that directory"); + return 1; + } + if (argc > 2) + { + execvp (argv[2], argv + 2); + } + else + { + prog = getenv ("SHELL"); + if (!prog) + prog = "/bin/sh"; + execlp (prog, prog, NULL); + } + name_and_error ("cannot exec"); + return 1; +} -- cgit v1.2.3