summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@courtesan.com>1996-08-09 22:07:51 +0000
committerTodd C. Miller <Todd.Miller@courtesan.com>1996-08-09 22:07:51 +0000
commit218c9b5cc7d5e4810969b64b319a3302f0de64c0 (patch)
tree08f532a73fda9cabc2048704e08db4eb797113a8 /parse.c
parentd795f5cfef7db5bb39e7a5b2de2cd5d5f39bb1e0 (diff)
downloadsudo-218c9b5cc7d5e4810969b64b319a3302f0de64c0.tar.gz
added support for new `sudo -l' stuff
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/parse.c b/parse.c
index f9030e13e..a2c0febc9 100644
--- a/parse.c
+++ b/parse.c
@@ -90,6 +90,8 @@ 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
@@ -97,7 +99,7 @@ extern FILE *yyin, *yyout;
static int has_meta __P((char *));
/*
- * this routine is called from the sudo.c module and tries to validate
+ * This routine is called from the sudo.c module and tries to validate
* the user, host and command triplet.
*/
int validate(check_cmnd)
@@ -118,13 +120,28 @@ int validate(check_cmnd)
yyout = stdout;
/*
- * need to be root while stat'ing things in the parser.
+ * Allocate space for matches if printmatches is set.
+ */
+ 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;
+ }
+
+ /*
+ * Need to be root while stat'ing things in the parser.
*/
set_perms(PERM_ROOT);
return_code = yyparse();
/*
- * don't need to keep this open...
+ * Don't need to keep this open...
*/
(void) fclose(sudoers_fp);