We can't use eprintf etc. without using the arg.h macros.

This commit is contained in:
sin 2014-02-13 12:57:16 +00:00
parent a79472bb1a
commit 79a913f4e6

View File

@ -10,25 +10,30 @@ main(int argc, char **argv)
{ {
char *shell[] = { "/bin/sh", "-i", NULL }, *aux; char *shell[] = { "/bin/sh", "-i", NULL }, *aux;
ARGBEGIN {
default:
usage();
} ARGEND;
if(argc < 1)
usage();
if((aux = getenv("SHELL"))) if((aux = getenv("SHELL")))
shell[0] = aux; shell[0] = aux;
if(argc < 2) if(chroot(argv[0]) == -1)
usage(); eprintf("chroot: '%s':", argv[0]);
if(chroot(argv[1]) == -1)
eprintf("chroot: '%s':", argv[1]);
if(chdir("/") == -1) if(chdir("/") == -1)
eprintf("chroot:"); eprintf("chroot:");
if(argc == 2) { if(argc == 1) {
execvp(*shell, shell); execvp(*shell, shell);
} else { } else {
execvp(argv[2], argv+2); execvp(argv[1], argv+1);
} }
eprintf("chroot: '%s':", argv[2]); eprintf("chroot: '%s':", argv[1]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }