From 50e27751d43af1040091ca2d7117853f8ca90e65 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 17 Aug 1996 22:30:48 +0000 Subject: now uses init_parser() if not in sudoers and tries "list" or "validate" scold but don't be nasty. --- parse.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'parse.c') 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 -- cgit v1.2.1