summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@courtesan.com>1996-08-17 22:30:48 +0000
committerTodd C. Miller <Todd.Miller@courtesan.com>1996-08-17 22:30:48 +0000
commit50e27751d43af1040091ca2d7117853f8ca90e65 (patch)
tree4b2026b2a202d105d301cd66faa4ce124c6764eb /parse.c
parent7ce2ade67ed237477e00fdbc427391aceb3b29ad (diff)
downloadsudo-50e27751d43af1040091ca2d7117853f8ca90e65.tar.gz
now uses init_parser()
if not in sudoers and tries "list" or "validate" scold but don't be nasty.
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/parse.c b/parse.c
index 8245fa840..c4af0cdc8 100644
--- a/parse.c
+++ b/parse.c
@@ -90,13 +90,13 @@ static char rcsid[] = "$Id$";
*/
int parse_error = FALSE;
extern FILE *yyin, *yyout;
-extern struct sudo_match *matches;
extern int printmatches;
/*
- * Prototypes for static (local) functions
+ * Prototypes
*/
static int has_meta __P((char *));
+ void init_parser __P((void));
/*
* This routine is called from the sudo.c module and tries to validate
@@ -120,19 +120,9 @@ int validate(check_cmnd)
yyout = stdout;
/*
- * Allocate space for matches if printmatches is set.
+ * Allocate space for data structures in the parser.
*/
- if (printmatches) {
- if ((matches = (struct sudo_match *)
- malloc(sizeof(struct sudo_match) * MATCHSTACKSIZE)) == NULL) {
- perror("malloc");
- (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
- exit(1);
- }
- /* XXX - maybe just set sizes to 0??? */
- matches[0].runas = matches[0].cmnd = NULL;
- matches[0].nopasswd = FALSE;
- }
+ init_parser();
/*
* Need to be root while stat'ing things in the parser.
@@ -153,9 +143,14 @@ int validate(check_cmnd)
/*
* Nothing on the top of the stack => user doesn't appear in sudoers.
+ * Allow anyone to try the psuedo commands "list" and "validate".
*/
- if (top == 0)
- return(VALIDATE_NO_USER);
+ if (top == 0) {
+ if (check_cmnd == TRUE)
+ return(VALIDATE_NO_USER);
+ else
+ return(VALIDATE_NOT_OK);
+ }
/*
* Only check the actual command if the check_cmnd