From: Todd C. Miller Date: Wed, 25 May 1994 03:08:10 +0000 (+0000) Subject: cast Argv to a const for exec X-Git-Tag: SUDO_1_3_1~236 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48f3cb673403bdc7bc77211cdcb475730ea5fbcf;p=sudo cast Argv to a const for exec added -v flag --- diff --git a/sudo.c b/sudo.c index 42dfee7f6..d83c507be 100644 --- a/sudo.c +++ b/sudo.c @@ -80,7 +80,9 @@ static char rcsid[] = "$Id$"; #ifdef _AIX #include #endif /* _AIX */ + #include "sudo.h" +#include "version.h" #ifndef STDC_HEADERS extern char *malloc(); @@ -133,6 +135,18 @@ main(argc, argv) if (argc < 2) usage(); + /* + * print version string and exit if we got -v + * when we add other options getopt(3) will be used + */ + if (*argv[1] == '-') + if (!strcmp(argv[1], "-v")) { + (void) printf("CU Sudo version %s\n", version); + exit(0); + } else { + usage(); + } + /* * close all file descriptors to make sure we have a nice * clean slate from which to work. @@ -157,9 +171,9 @@ main(argc, argv) log_error(ALL_SYSTEMS_GO); be_root(); #ifdef USE_EXECV - execv(cmnd, &Argv[1]); + execv(cmnd, (const char **) &Argv[1]); #else /* USE_EXECV */ - execvp(cmnd, &Argv[1]); + execvp(cmnd, (const char **) &Argv[1]); #endif /* USE_EXECV */ perror(cmnd); /* exec failed! */ exit(-1); @@ -292,7 +306,7 @@ static void load_globals() static void usage() { - (void) fprintf(stderr, "usage: %s command\n", *Argv); + (void) fprintf(stderr, "usage: %s [-v] [command]\n", *Argv); exit(1); }