mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 09:57:41 +00:00
added -v flag and usage()
This commit is contained in:
parent
51ae4df137
commit
6e7d42f3e1
37
visudo.c
37
visudo.c
@ -55,6 +55,7 @@ static char rcsid[] = "$Id$";
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|
||||||
#include "sudo.h"
|
#include "sudo.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#ifndef STDC_HEADERS
|
#ifndef STDC_HEADERS
|
||||||
extern char *getenv();
|
extern char *getenv();
|
||||||
@ -66,6 +67,7 @@ extern int errno, yylineno;
|
|||||||
/*
|
/*
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
|
char **Argv;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
char *sudoers = _PATH_SUDO_SUDOERS;
|
char *sudoers = _PATH_SUDO_SUDOERS;
|
||||||
char *sudoers_tmp_file = _PATH_SUDO_STMP;
|
char *sudoers_tmp_file = _PATH_SUDO_STMP;
|
||||||
@ -74,6 +76,12 @@ int status = 0,
|
|||||||
FILE *sudoers_tmp_fp=NULL,
|
FILE *sudoers_tmp_fp=NULL,
|
||||||
*sudoers_fp=NULL;
|
*sudoers_fp=NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* local functions not visible outside visudo.c
|
||||||
|
*/
|
||||||
|
static void usage();
|
||||||
|
|
||||||
|
|
||||||
static RETSIGTYPE Exit(sig)
|
static RETSIGTYPE Exit(sig)
|
||||||
int sig;
|
int sig;
|
||||||
{
|
{
|
||||||
@ -95,6 +103,21 @@ main(argc, argv)
|
|||||||
char * Editor;
|
char * Editor;
|
||||||
#endif /* ENV_EDITOR */
|
#endif /* ENV_EDITOR */
|
||||||
|
|
||||||
|
Argv = argv;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
/*
|
||||||
|
* print version string and exit if we got -v
|
||||||
|
*/
|
||||||
|
if (!strcmp(argv[1], "-v")) {
|
||||||
|
(void) printf("visudo version %s\n", version);
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* handle the signals
|
* handle the signals
|
||||||
*/
|
*/
|
||||||
@ -239,3 +262,17 @@ main(argc, argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
*
|
||||||
|
* usage()
|
||||||
|
*
|
||||||
|
* this function just gives you instructions and exits
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void usage()
|
||||||
|
{
|
||||||
|
(void) fprintf(stderr, "usage: %s [-v]\n", *Argv);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user