diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-05 20:24:54 +0400 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-05 20:24:54 +0400 |
commit | cc8ed39b240180b58810784f844e253263594ac3 (patch) | |
tree | 15feebbb4be9a9168209609f48f0b100f9364420 /chroot.c |
Initial revision0_29alpha2
Diffstat (limited to 'chroot.c')
-rw-r--r-- | chroot.c | 32 |
1 files changed, 32 insertions, 0 deletions
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 <stdio.h> +#include <unistd.h> + + +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; +} |