[hackers] [sbase] We can't use eprintf etc. without using the arg.h macros. || sin

From: <git_AT_suckless.org>
Date: Thu, 13 Feb 2014 14:08:59 +0100

commit 79a913f4e6c4bb79bb3843a1417cf95db03e708c
Author: sin <sin_AT_2f30.org>
Date: Thu Feb 13 12:57:16 2014 +0000

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

diff --git a/chroot.c b/chroot.c
index 99f56b9..92263c1 100644
--- a/chroot.c
+++ b/chroot.c
_AT_@ -8,27 +8,32 @@ static void usage(void);
 int
 main(int argc, char **argv)
 {
- char *shell[] = {"/bin/sh", "-i", NULL}, *aux;
+ char *shell[] = { "/bin/sh", "-i", NULL }, *aux;
 
- if((aux = getenv("SHELL")))
- shell[0] = aux;
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND;
 
- if(argc < 2)
+ if(argc < 1)
                 usage();
 
- if(chroot(argv[1]) == -1)
- eprintf("chroot: '%s':", argv[1]);
+ if((aux = getenv("SHELL")))
+ shell[0] = aux;
+
+ if(chroot(argv[0]) == -1)
+ eprintf("chroot: '%s':", argv[0]);
 
         if(chdir("/") == -1)
                 eprintf("chroot:");
 
- if(argc == 2) {
+ if(argc == 1) {
                 execvp(*shell, shell);
         } else {
- execvp(argv[2], argv+2);
+ execvp(argv[1], argv+1);
         }
 
- eprintf("chroot: '%s':", argv[2]);
+ eprintf("chroot: '%s':", argv[1]);
         return EXIT_FAILURE;
 }
 
Received on Thu Feb 13 2014 - 14:08:59 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 13 2014 - 14:12:16 CET