2 /*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/
5 __attribute__ ((unused))
6 #endif /* __GNUC__ >= 2 */
7 = "$OpenBSD: skeleton.c,v 1.24 2005/06/10 16:40:45 pvalchev Exp $";
15 #define yyclearin (yychar=(YYEMPTY))
16 #define yyerrok (yyerrflag=0)
17 #define YYRECOVERING() (yyerrflag!=0)
21 * Copyright (c) 1996, 1998-2004 Todd C. Miller <Todd.Miller@courtesan.com>
23 * Permission to use, copy, modify, and distribute this software for any
24 * purpose with or without fee is hereby granted, provided that the above
25 * copyright notice and this permission notice appear in all copies.
27 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
28 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
29 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
30 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
31 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
32 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
33 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * Sponsored in part by the Defense Advanced Research Projects
38 * Agency (DARPA) and Air Force Research Laboratory, Air Force
39 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
43 * XXX - the whole opFOO naming thing is somewhat bogus.
45 * XXX - the way things are stored for printmatches is stupid,
46 * they should be stored as elements in an array and then
47 * list_matches() can format things the way it wants.
52 #include <sys/types.h>
53 #include <sys/param.h>
62 #endif /* STDC_HEADERS */
66 # ifdef HAVE_STRINGS_H
69 #endif /* HAVE_STRING_H */
72 #endif /* HAVE_UNISTD_H */
74 #if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
76 #endif /* HAVE_MALLOC_H && !STDC_HEADERS */
77 #if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
79 #endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */
82 #endif /* HAVE_LSEARCH */
88 #include "emul/search.h"
89 #endif /* HAVE_LSEARCH */
92 static const char rcsid[] = "$Sudo: parse.yacc,v 1.204 2004/08/11 18:29:10 millert Exp $";
98 extern int sudolineno, parse_error;
100 int clearaliases = TRUE;
101 int printmatches = FALSE;
102 int pedantic = FALSE;
105 int used_runas = FALSE;
113 #define RUNAS_ALIAS 4
115 #define SETMATCH(_var, _val) do { \
116 if ((_var) == UNSPEC || (_val) != NOMATCH) \
120 #define SETNMATCH(_var, _val) do { \
121 if ((_val) != NOMATCH) \
123 else if ((_var) == UNSPEC) \
128 * The matching stack, initial space allocated in init_parser().
130 struct matchstack *match;
131 int top = 0, stacksize = 0;
135 if (top >= stacksize) { \
136 while ((stacksize += STACKINCREMENT) < top); \
137 match = (struct matchstack *) erealloc3(match, stacksize, sizeof(struct matchstack)); \
139 match[top].user = UNSPEC; \
140 match[top].cmnd = UNSPEC; \
141 match[top].host = UNSPEC; \
142 match[top].runas = UNSPEC; \
143 match[top].nopass = def_authenticate ? UNSPEC : TRUE; \
144 match[top].noexec = def_noexec ? TRUE : UNSPEC; \
150 if (top >= stacksize) { \
151 while ((stacksize += STACKINCREMENT) < top); \
152 match = (struct matchstack *) erealloc3(match, stacksize, sizeof(struct matchstack)); \
154 match[top].user = match[top-1].user; \
155 match[top].cmnd = match[top-1].cmnd; \
156 match[top].host = match[top-1].host; \
157 match[top].runas = match[top-1].runas; \
158 match[top].nopass = match[top-1].nopass; \
159 match[top].noexec = match[top-1].noexec; \
166 yyerror("matching stack underflow"); \
173 * For testing if foo_matches variable was set to TRUE or FALSE
175 #define MATCHED(_v) ((_v) >= 0)
178 * Shortcuts for append()
180 #define append_cmnd(s, p) append(s, &cm_list[cm_list_len].cmnd, \
181 &cm_list[cm_list_len].cmnd_len, &cm_list[cm_list_len].cmnd_size, p)
183 #define append_runas(s, p) append(s, &cm_list[cm_list_len].runas, \
184 &cm_list[cm_list_len].runas_len, &cm_list[cm_list_len].runas_size, p)
186 #define append_entries(s, p) append(s, &ga_list[ga_list_len-1].entries, \
187 &ga_list[ga_list_len-1].entries_len, \
188 &ga_list[ga_list_len-1].entries_size, p)
191 * The stack for printmatches. A list of allowed commands for the user.
193 static struct command_match *cm_list = NULL;
194 static size_t cm_list_len = 0, cm_list_size = 0;
197 * List of Cmnd_Aliases and expansions for `sudo -l'
199 static int in_alias = FALSE;
200 static size_t ga_list_len = 0, ga_list_size = 0;
201 static struct generic_alias *ga_list = NULL;
204 * Does this Defaults list pertain to this user?
206 static int defaults_matches = FALSE;
211 static int add_alias __P((char *, int, int));
212 static void append __P((char *, char **, size_t *, size_t *, char *));
213 static void expand_ga_list __P((void));
214 static void expand_match_list __P((void));
215 static aliasinfo *find_alias __P((char *, int));
216 static int more_aliases __P((void));
217 void init_parser __P((void));
218 void yyerror __P((char *));
224 /* Save the line the first error occurred on. */
225 if (errorlineno == -1)
226 errorlineno = sudolineno ? sudolineno - 1 : 0;
229 (void) fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s,
230 sudolineno ? sudolineno - 1 : 0);
232 (void) fprintf(stderr, "<*> ");
237 #line 221 "parse.yacc"
238 #ifndef YYSTYPE_DEFINED
239 #define YYSTYPE_DEFINED
243 struct sudo_command command;
246 #endif /* YYSTYPE_DEFINED */
247 #line 248 "sudo.tab.c"
253 #define USERGROUP 262
256 #define DEFAULTS_HOST 265
257 #define DEFAULTS_USER 266
258 #define DEFAULTS_RUNAS 267
266 #define HOSTALIAS 275
267 #define CMNDALIAS 276
268 #define USERALIAS 277
269 #define RUNASALIAS 278
271 #define YYERRCODE 256
272 #if defined(__cplusplus) || defined(__STDC__)
273 const short yylhs[] =
278 0, 0, 7, 7, 9, 7, 7, 7, 7, 7,
279 7, 15, 16, 18, 16, 19, 16, 21, 16, 17,
280 17, 22, 22, 22, 22, 22, 10, 10, 23, 25,
281 25, 2, 2, 2, 2, 2, 24, 24, 26, 29,
282 30, 29, 27, 27, 5, 5, 4, 31, 4, 3,
283 3, 3, 3, 3, 28, 28, 28, 28, 28, 1,
284 1, 1, 12, 12, 33, 32, 20, 20, 13, 13,
285 35, 34, 36, 36, 14, 14, 38, 37, 11, 11,
286 40, 39, 8, 8, 41, 41, 6, 6, 6, 6,
289 #if defined(__cplusplus) || defined(__STDC__)
290 const short yylen[] =
295 1, 2, 1, 2, 0, 3, 2, 2, 2, 2,
296 1, 2, 1, 0, 3, 0, 3, 0, 3, 1,
297 3, 1, 2, 3, 3, 3, 1, 3, 3, 1,
298 2, 1, 1, 1, 1, 1, 1, 3, 3, 1,
299 0, 3, 0, 2, 1, 3, 1, 0, 3, 1,
300 1, 1, 1, 1, 0, 2, 2, 2, 2, 1,
301 1, 1, 1, 3, 0, 4, 1, 3, 1, 3,
302 0, 4, 1, 3, 1, 3, 0, 4, 1, 3,
303 0, 4, 1, 3, 1, 2, 1, 1, 1, 1,
306 #if defined(__cplusplus) || defined(__STDC__)
307 const short yydefred[] =
312 0, 13, 18, 14, 16, 3, 0, 0, 0, 0,
313 0, 1, 0, 11, 0, 4, 0, 0, 0, 65,
314 0, 63, 71, 0, 69, 81, 0, 79, 77, 0,
315 75, 2, 90, 89, 88, 87, 91, 0, 85, 0,
316 83, 0, 0, 12, 0, 36, 33, 34, 35, 32,
317 0, 30, 0, 67, 0, 53, 52, 51, 50, 54,
318 48, 47, 45, 0, 0, 0, 0, 0, 0, 0,
319 0, 0, 86, 0, 0, 0, 27, 0, 0, 0,
320 23, 0, 31, 0, 0, 0, 0, 64, 0, 70,
321 0, 80, 0, 76, 84, 0, 0, 24, 25, 26,
322 21, 68, 49, 46, 0, 62, 61, 60, 41, 40,
323 73, 0, 0, 0, 28, 0, 0, 37, 55, 0,
324 0, 0, 0, 0, 42, 74, 38, 56, 57, 58,
327 #if defined(__cplusplus) || defined(__STDC__)
328 const short yydgoto[] =
333 110, 52, 62, 63, 64, 39, 12, 40, 13, 75,
334 27, 21, 24, 30, 14, 15, 44, 18, 19, 76,
335 17, 45, 77, 117, 54, 118, 119, 124, 111, 120,
336 85, 22, 65, 25, 67, 112, 31, 71, 28, 69,
339 #if defined(__cplusplus) || defined(__STDC__)
340 const short yysindex[] =
345 -264, 0, 0, 0, 0, 0, -247, -240, -236, -235,
346 -239, 0, 307, 0, -31, 0, 328, 307, 320, 0,
347 -9, 0, 0, -8, 0, 0, -4, 0, 0, 2,
348 0, 0, 0, 0, 0, 0, 0, -242, 0, 294,
349 0, -3, -226, 0, 11, 0, 0, 0, 0, 0,
350 -217, 0, 17, 0, 20, 0, 0, 0, 0, 0,
351 0, 0, 0, 21, 5, -247, 6, -240, 7, -236,
352 8, -235, 0, 307, 13, -32, 0, -191, -190, -189,
353 0, -31, 0, 328, -210, 320, 328, 0, -33, 0,
354 307, 0, 320, 0, 0, 328, -192, 0, 0, 0,
355 0, 0, 0, 0, 17, 0, 0, 0, 0, 0,
356 0, 34, 20, 21, 0, 320, 35, 0, 0, -243,
357 -33, 21, -192, -27, 0, 0, 0, 0, 0, 0,
359 #if defined(__cplusplus) || defined(__STDC__)
360 const short yyrindex[] =
365 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
366 342, 0, 0, 0, 0, 0, 0, 0, 0, 0,
367 139, 0, 0, 162, 0, 0, 185, 0, 0, 208,
368 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
369 0, 1, 0, 0, 236, 0, 0, 0, 0, 0,
370 0, 0, -30, 0, -26, 0, 0, 0, 0, 0,
371 0, 0, 0, -25, 0, 0, 0, 0, 0, 0,
372 0, 0, 0, 0, 260, 0, 0, 0, 0, 0,
373 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, -20, 0, 0, 0,
375 0, 0, 0, 0, 24, 0, 0, 0, 0, 0,
376 0, 47, 70, 93, 0, 0, 116, 0, 0, 0,
377 0, 271, -20, 0, 0, 0, 0, 0, 0, 0,
379 #if defined(__cplusplus) || defined(__STDC__)
380 const short yygindex[] =
385 -39, 32, -1, 3, -84, 48, 74, -14, 0, 0,
386 0, 0, 0, 0, 0, 0, 9, 0, 0, -12,
387 0, 0, -6, 0, 4, -36, 0, 0, -62, 0,
388 0, 26, 0, 27, 0, 0, 22, 0, 28, 0,
391 #define YYTABLESIZE 615
392 #if defined(__cplusplus) || defined(__STDC__)
393 const short yytable[] =
398 22, 43, 19, 55, 53, 109, 15, 17, 114, 16,
399 20, 84, 43, 106, 107, 33, 1, 23, 34, 35,
400 36, 26, 29, 66, 2, 3, 4, 5, 97, 108,
401 37, 122, 81, 22, 6, 7, 8, 9, 10, 79,
402 46, 80, 47, 48, 22, 49, 72, 56, 66, 68,
403 57, 58, 59, 70, 82, 50, 66, 78, 126, 72,
404 84, 132, 60, 74, 86, 87, 89, 91, 93, 82,
405 96, 98, 99, 100, 105, 116, 113, 121, 123, 72,
406 125, 66, 83, 103, 32, 73, 127, 102, 104, 115,
407 101, 88, 78, 94, 90, 0, 95, 92, 0, 0,
408 0, 0, 82, 0, 72, 0, 0, 0, 0, 0,
409 0, 0, 0, 0, 0, 29, 0, 0, 0, 0,
410 0, 0, 0, 0, 0, 78, 0, 82, 0, 0,
411 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,
412 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
413 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
414 0, 9, 0, 0, 0, 0, 0, 0, 0, 0,
415 0, 8, 0, 29, 0, 0, 0, 0, 0, 0,
416 0, 0, 0, 0, 7, 0, 0, 0, 0, 0,
417 0, 0, 0, 0, 9, 0, 0, 0, 0, 0,
418 0, 0, 0, 0, 0, 0, 0, 10, 0, 0,
419 0, 0, 0, 0, 0, 0, 0, 7, 0, 0,
420 0, 0, 0, 106, 107, 0, 0, 42, 19, 106,
421 107, 0, 15, 17, 0, 20, 43, 43, 0, 108,
422 10, 128, 129, 130, 131, 108, 0, 0, 43, 43,
423 43, 43, 43, 0, 0, 0, 22, 0, 22, 6,
424 0, 22, 22, 22, 22, 22, 22, 22, 20, 0,
425 0, 0, 0, 22, 22, 22, 22, 22, 22, 66,
426 0, 66, 0, 0, 66, 66, 66, 66, 66, 66,
427 66, 0, 6, 0, 0, 0, 66, 66, 66, 66,
428 66, 66, 72, 44, 72, 0, 0, 72, 72, 72,
429 72, 72, 72, 72, 0, 0, 0, 0, 0, 72,
430 72, 72, 72, 72, 72, 82, 51, 82, 0, 0,
431 82, 82, 82, 82, 82, 82, 82, 74, 0, 38,
432 0, 0, 82, 82, 82, 82, 82, 82, 78, 0,
433 78, 0, 61, 78, 78, 78, 78, 78, 78, 78,
434 51, 0, 0, 0, 0, 78, 78, 78, 78, 78,
435 78, 29, 0, 29, 5, 0, 29, 29, 29, 29,
436 29, 29, 29, 0, 0, 0, 0, 0, 29, 29,
437 29, 29, 29, 29, 8, 0, 8, 0, 0, 8,
438 8, 8, 8, 8, 8, 8, 0, 0, 0, 0,
439 0, 8, 8, 8, 8, 8, 8, 9, 0, 9,
440 0, 0, 9, 9, 9, 9, 9, 9, 9, 0,
441 0, 0, 0, 0, 9, 9, 9, 9, 9, 9,
442 7, 0, 7, 0, 0, 7, 7, 7, 7, 7,
443 7, 7, 0, 0, 0, 0, 0, 7, 7, 7,
444 7, 7, 7, 10, 0, 10, 0, 0, 10, 10,
445 10, 10, 10, 10, 10, 0, 0, 0, 0, 0,
446 10, 10, 10, 10, 10, 10, 0, 0, 0, 0,
447 0, 20, 0, 20, 0, 0, 20, 20, 20, 20,
448 20, 20, 20, 0, 0, 0, 0, 0, 20, 20,
449 20, 20, 20, 20, 0, 6, 0, 6, 0, 0,
450 6, 6, 6, 6, 6, 6, 6, 44, 44, 0,
451 0, 0, 6, 6, 6, 6, 6, 6, 0, 44,
452 44, 44, 44, 44, 0, 0, 0, 0, 0, 0,
453 0, 46, 0, 47, 48, 0, 49, 0, 0, 0,
454 0, 0, 0, 0, 33, 0, 50, 34, 35, 36,
455 0, 0, 0, 0, 0, 0, 0, 56, 0, 37,
456 57, 58, 59, 0, 0, 46, 0, 47, 48, 0,
457 49, 0, 60, 0, 0, 0, 0, 0, 0, 5,
458 50, 0, 5, 5, 5, 0, 0, 0, 0, 0,
461 #if defined(__cplusplus) || defined(__STDC__)
462 const short yycheck[] =
467 0, 33, 33, 18, 17, 33, 33, 33, 93, 274,
468 258, 44, 33, 257, 258, 258, 256, 258, 261, 262,
469 263, 258, 258, 0, 264, 265, 266, 267, 61, 273,
470 273, 116, 259, 33, 274, 275, 276, 277, 278, 43,
471 258, 45, 260, 261, 44, 263, 0, 258, 58, 58,
472 261, 262, 263, 58, 44, 273, 33, 61, 121, 58,
473 44, 124, 273, 44, 44, 61, 61, 61, 61, 0,
474 58, 263, 263, 263, 87, 268, 91, 44, 44, 33,
475 120, 58, 51, 85, 11, 38, 123, 84, 86, 96,
476 82, 66, 0, 72, 68, -1, 74, 70, -1, -1,
477 -1, -1, 33, -1, 58, -1, -1, -1, -1, -1,
478 -1, -1, -1, -1, -1, 0, -1, -1, -1, -1,
479 -1, -1, -1, -1, -1, 33, -1, 58, -1, -1,
480 -1, -1, -1, -1, -1, -1, -1, -1, 0, -1,
481 -1, -1, -1, -1, -1, -1, -1, -1, 33, -1,
482 58, -1, -1, -1, -1, -1, -1, -1, -1, -1,
483 -1, 0, -1, -1, -1, -1, -1, -1, -1, -1,
484 -1, 33, -1, 58, -1, -1, -1, -1, -1, -1,
485 -1, -1, -1, -1, 0, -1, -1, -1, -1, -1,
486 -1, -1, -1, -1, 33, -1, -1, -1, -1, -1,
487 -1, -1, -1, -1, -1, -1, -1, 0, -1, -1,
488 -1, -1, -1, -1, -1, -1, -1, 33, -1, -1,
489 -1, -1, -1, 257, 258, -1, -1, 259, 259, 257,
490 258, -1, 259, 259, -1, 0, 257, 258, -1, 273,
491 33, 269, 270, 271, 272, 273, -1, -1, 269, 270,
492 271, 272, 273, -1, -1, -1, 256, -1, 258, 0,
493 -1, 261, 262, 263, 264, 265, 266, 267, 33, -1,
494 -1, -1, -1, 273, 274, 275, 276, 277, 278, 256,
495 -1, 258, -1, -1, 261, 262, 263, 264, 265, 266,
496 267, -1, 33, -1, -1, -1, 273, 274, 275, 276,
497 277, 278, 256, 33, 258, -1, -1, 261, 262, 263,
498 264, 265, 266, 267, -1, -1, -1, -1, -1, 273,
499 274, 275, 276, 277, 278, 256, 33, 258, -1, -1,
500 261, 262, 263, 264, 265, 266, 267, 44, -1, 33,
501 -1, -1, 273, 274, 275, 276, 277, 278, 256, -1,
502 258, -1, 33, 261, 262, 263, 264, 265, 266, 267,
503 33, -1, -1, -1, -1, 273, 274, 275, 276, 277,
504 278, 256, -1, 258, 33, -1, 261, 262, 263, 264,
505 265, 266, 267, -1, -1, -1, -1, -1, 273, 274,
506 275, 276, 277, 278, 256, -1, 258, -1, -1, 261,
507 262, 263, 264, 265, 266, 267, -1, -1, -1, -1,
508 -1, 273, 274, 275, 276, 277, 278, 256, -1, 258,
509 -1, -1, 261, 262, 263, 264, 265, 266, 267, -1,
510 -1, -1, -1, -1, 273, 274, 275, 276, 277, 278,
511 256, -1, 258, -1, -1, 261, 262, 263, 264, 265,
512 266, 267, -1, -1, -1, -1, -1, 273, 274, 275,
513 276, 277, 278, 256, -1, 258, -1, -1, 261, 262,
514 263, 264, 265, 266, 267, -1, -1, -1, -1, -1,
515 273, 274, 275, 276, 277, 278, -1, -1, -1, -1,
516 -1, 256, -1, 258, -1, -1, 261, 262, 263, 264,
517 265, 266, 267, -1, -1, -1, -1, -1, 273, 274,
518 275, 276, 277, 278, -1, 256, -1, 258, -1, -1,
519 261, 262, 263, 264, 265, 266, 267, 257, 258, -1,
520 -1, -1, 273, 274, 275, 276, 277, 278, -1, 269,
521 270, 271, 272, 273, -1, -1, -1, -1, -1, -1,
522 -1, 258, -1, 260, 261, -1, 263, -1, -1, -1,
523 -1, -1, -1, -1, 258, -1, 273, 261, 262, 263,
524 -1, -1, -1, -1, -1, -1, -1, 258, -1, 273,
525 261, 262, 263, -1, -1, 258, -1, 260, 261, -1,
526 263, -1, 273, -1, -1, -1, -1, -1, -1, 258,
527 273, -1, 261, 262, 263, -1, -1, -1, -1, -1,
534 #define YYMAXTOKEN 279
536 #if defined(__cplusplus) || defined(__STDC__)
537 const char * const yyname[] =
542 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
543 "'!'",0,0,0,0,0,0,0,0,0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,
544 "'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
545 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
546 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
547 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
548 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
549 "COMMAND","ALIAS","DEFVAR","NTWKADDR","NETGROUP","USERGROUP","WORD","DEFAULTS",
550 "DEFAULTS_HOST","DEFAULTS_USER","DEFAULTS_RUNAS","RUNAS","NOPASSWD","PASSWD",
551 "NOEXEC","EXEC","ALL","COMMENT","HOSTALIAS","CMNDALIAS","USERALIAS",
552 "RUNASALIAS","ERROR",
554 #if defined(__cplusplus) || defined(__STDC__)
555 const char * const yyrule[] =
563 "entry : error COMMENT",
565 "entry : $$1 userlist privileges",
566 "entry : USERALIAS useraliases",
567 "entry : HOSTALIAS hostaliases",
568 "entry : CMNDALIAS cmndaliases",
569 "entry : RUNASALIAS runasaliases",
570 "entry : defaults_line",
571 "defaults_line : defaults_type defaults_list",
572 "defaults_type : DEFAULTS",
574 "defaults_type : DEFAULTS_USER $$2 userlist",
576 "defaults_type : DEFAULTS_RUNAS $$3 runaslist",
578 "defaults_type : DEFAULTS_HOST $$4 hostlist",
579 "defaults_list : defaults_entry",
580 "defaults_list : defaults_entry ',' defaults_list",
581 "defaults_entry : DEFVAR",
582 "defaults_entry : '!' DEFVAR",
583 "defaults_entry : DEFVAR '=' WORD",
584 "defaults_entry : DEFVAR '+' WORD",
585 "defaults_entry : DEFVAR '-' WORD",
586 "privileges : privilege",
587 "privileges : privileges ':' privilege",
588 "privilege : hostlist '=' cmndspeclist",
596 "cmndspeclist : cmndspec",
597 "cmndspeclist : cmndspeclist ',' cmndspec",
598 "cmndspec : runasspec cmndtag opcmnd",
601 "opcmnd : '!' $$5 cmnd",
603 "runasspec : RUNAS runaslist",
604 "runaslist : oprunasuser",
605 "runaslist : runaslist ',' oprunasuser",
606 "oprunasuser : runasuser",
608 "oprunasuser : '!' $$6 runasuser",
610 "runasuser : USERGROUP",
611 "runasuser : NETGROUP",
615 "cmndtag : cmndtag NOPASSWD",
616 "cmndtag : cmndtag PASSWD",
617 "cmndtag : cmndtag NOEXEC",
618 "cmndtag : cmndtag EXEC",
622 "hostaliases : hostalias",
623 "hostaliases : hostaliases ':' hostalias",
625 "hostalias : ALIAS $$7 '=' hostlist",
627 "hostlist : hostlist ',' ophost",
628 "cmndaliases : cmndalias",
629 "cmndaliases : cmndaliases ':' cmndalias",
631 "cmndalias : ALIAS $$8 '=' cmndlist",
633 "cmndlist : cmndlist ',' opcmnd",
634 "runasaliases : runasalias",
635 "runasaliases : runasaliases ':' runasalias",
637 "runasalias : ALIAS $$9 '=' runaslist",
638 "useraliases : useralias",
639 "useraliases : useraliases ':' useralias",
641 "useralias : ALIAS $$10 '=' userlist",
643 "userlist : userlist ',' opuser",
655 #define YYMAXDEPTH YYSTACKSIZE
658 #define YYSTACKSIZE YYMAXDEPTH
660 #define YYSTACKSIZE 10000
661 #define YYMAXDEPTH 10000
664 #define YYINITSTACKSIZE 200
677 #line 886 "parse.yacc"
679 #define MOREALIASES (32)
680 aliasinfo *aliases = NULL;
686 * Compare two aliasinfo structures, strcmp() style.
687 * Note that we do *not* compare their values.
694 aliasinfo *ai1, *ai2;
696 ai1 = (aliasinfo *) a1;
697 ai2 = (aliasinfo *) a2;
698 if ((r = strcmp(ai1->name, ai2->name)) == 0)
699 r = ai1->type - ai2->type;
705 * Compare two generic_alias structures, strcmp() style.
708 genaliascmp(entry, key)
709 const VOID *entry, *key;
712 struct generic_alias *ga1, *ga2;
714 ga1 = (struct generic_alias *) key;
715 ga2 = (struct generic_alias *) entry;
716 if ((r = strcmp(ga1->alias, ga2->alias)) == 0)
717 r = ga1->type - ga2->type;
724 * Adds the named alias of the specified type to the aliases list.
727 add_alias(alias, type, val)
736 if (naliases >= nslots && !more_aliases()) {
737 (void) snprintf(s, sizeof(s), "Out of memory defining alias `%s'",
745 ai.name = estrdup(alias);
746 onaliases = naliases;
748 aip = (aliasinfo *) lsearch((VOID *)&ai, (VOID *)aliases, &naliases,
749 sizeof(ai), aliascmp);
751 (void) snprintf(s, sizeof(s), "Aliases corrupted defining alias `%s'",
756 if (onaliases == naliases) {
757 (void) snprintf(s, sizeof(s), "Alias `%s' already defined", alias);
766 * Searches for the named alias of the specified type.
769 find_alias(alias, type)
778 return((aliasinfo *) lfind((VOID *)&ai, (VOID *)aliases, &naliases,
779 sizeof(ai), aliascmp));
783 * Allocates more space for the aliases list.
789 nslots += MOREALIASES;
790 if (nslots == MOREALIASES)
791 aliases = (aliasinfo *) malloc(nslots * sizeof(aliasinfo));
793 aliases = (aliasinfo *) realloc(aliases, nslots * sizeof(aliasinfo));
795 return(aliases != NULL);
799 * Lists the contents of the aliases list.
806 for (n = 0; n < naliases; n++) {
807 if (aliases[n].val == -1)
810 switch (aliases[n].type) {
812 (void) puts("HOST_ALIAS");
816 (void) puts("CMND_ALIAS");
820 (void) puts("USER_ALIAS");
824 (void) puts("RUNAS_ALIAS");
827 (void) printf("\t%s: %d\n", aliases[n].name, aliases[n].val);
832 * Lists the contents of cm_list and ga_list for `sudo -l'.
839 struct generic_alias *ga, key;
841 (void) printf("User %s may run the following commands on this host:\n",
843 for (count = 0; count < cm_list_len; count++) {
845 /* Print the runas list. */
846 (void) fputs(" ", stdout);
847 if (cm_list[count].runas) {
849 p = strtok(cm_list[count].runas, ", ");
851 if (p != cm_list[count].runas)
852 (void) fputs(", ", stdout);
855 key.type = RUNAS_ALIAS;
856 if ((ga = (struct generic_alias *) lfind((VOID *) &key,
857 (VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp)))
858 (void) fputs(ga->entries, stdout);
860 (void) fputs(p, stdout);
861 } while ((p = strtok(NULL, ", ")));
862 (void) fputs(") ", stdout);
864 (void) printf("(%s) ", def_runas_default);
867 /* Is execve(2) disabled? */
868 if (cm_list[count].noexecve == TRUE && !def_noexec)
869 (void) fputs("NOEXEC: ", stdout);
870 else if (cm_list[count].noexecve == FALSE && def_noexec)
871 (void) fputs("EXEC: ", stdout);
873 /* Is a password required? */
874 if (cm_list[count].nopasswd == TRUE && def_authenticate)
875 (void) fputs("NOPASSWD: ", stdout);
876 else if (cm_list[count].nopasswd == FALSE && !def_authenticate)
877 (void) fputs("PASSWD: ", stdout);
879 /* Print the actual command or expanded Cmnd_Alias. */
880 key.alias = cm_list[count].cmnd;
881 key.type = CMND_ALIAS;
882 if ((ga = (struct generic_alias *) lfind((VOID *) &key,
883 (VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp)))
884 (void) puts(ga->entries);
886 (void) puts(cm_list[count].cmnd);
889 /* Be nice and free up space now that we are done. */
890 for (count = 0; count < ga_list_len; count++) {
891 free(ga_list[count].alias);
892 free(ga_list[count].entries);
897 for (count = 0; count < cm_list_len; count++) {
898 free(cm_list[count].runas);
899 free(cm_list[count].cmnd);
908 * Appends a source string to the destination, optionally prefixing a separator.
911 append(src, dstp, dst_len, dst_size, separator)
913 size_t *dst_len, *dst_size;
916 size_t src_len = strlen(src);
920 * Only add the separator if there is something to separate from.
921 * If the last char is a '!', don't apply the separator (XXX).
923 if (separator && dst && dst[*dst_len - 1] != '!')
924 src_len += strlen(separator);
928 /* Assumes dst will be NULL if not set. */
930 dst = (char *) emalloc(BUFSIZ);
937 /* Allocate more space if necessary. */
938 if (*dst_size <= *dst_len + src_len) {
939 while (*dst_size <= *dst_len + src_len)
942 dst = (char *) erealloc(dst, *dst_size);
946 /* Copy src -> dst adding a separator if appropriate and adjust len. */
948 (void) strlcat(dst, separator, *dst_size);
949 (void) strlcat(dst, src, *dst_size);
954 * Frees up space used by the aliases list and resets the associated counters.
962 for (n = 0; n < naliases; n++)
963 free(aliases[n].name);
967 naliases = nslots = 0;
971 * Increments ga_list_len, allocating more space as necessary.
977 if (++ga_list_len >= ga_list_size) {
978 while ((ga_list_size += STACKINCREMENT) < ga_list_len)
980 ga_list = (struct generic_alias *)
981 erealloc3(ga_list, ga_list_size, sizeof(struct generic_alias));
984 ga_list[ga_list_len - 1].entries = NULL;
988 * Increments cm_list_len, allocating more space as necessary.
994 if (++cm_list_len >= cm_list_size) {
995 while ((cm_list_size += STACKINCREMENT) < cm_list_len)
998 cm_list_len = 0; /* start at 0 since it is a subscript */
999 cm_list = (struct command_match *)
1000 erealloc3(cm_list, cm_list_size, sizeof(struct command_match));
1003 cm_list[cm_list_len].runas = cm_list[cm_list_len].cmnd = NULL;
1004 cm_list[cm_list_len].nopasswd = FALSE;
1005 cm_list[cm_list_len].noexecve = FALSE;
1009 * Frees up spaced used by a previous parser run and allocates new space
1010 * for various data structures.
1016 /* Free up old data structures if we run the parser more than once. */
1021 parse_error = FALSE;
1027 /* Allocate space for the matching stack. */
1028 stacksize = STACKINCREMENT;
1029 match = (struct matchstack *) emalloc2(stacksize, sizeof(struct matchstack));
1031 /* Allocate space for the match list (for `sudo -l'). */
1032 if (printmatches == TRUE)
1033 expand_match_list();
1035 #line 984 "sudo.tab.c"
1036 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1037 #if defined(__cplusplus) || defined(__STDC__)
1038 static int yygrowstack(void)
1040 static int yygrowstack()
1047 if ((newsize = yystacksize) == 0)
1048 newsize = YYINITSTACKSIZE;
1049 else if (newsize >= YYMAXDEPTH)
1051 else if ((newsize *= 2) > YYMAXDEPTH)
1052 newsize = YYMAXDEPTH;
1054 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
1055 (short *)malloc(newsize * sizeof *newss);
1060 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
1061 (YYSTYPE *)malloc(newsize * sizeof *newvs);
1066 yystacksize = newsize;
1067 yysslim = yyss + newsize - 1;
1074 yyss = yyssp = NULL;
1075 yyvs = yyvsp = NULL;
1080 #define YYABORT goto yyabort
1081 #define YYREJECT goto yyabort
1082 #define YYACCEPT goto yyaccept
1083 #define YYERROR goto yyerrlab
1085 #if defined(__cplusplus) || defined(__STDC__)
1091 int yym, yyn, yystate;
1093 #if defined(__cplusplus) || defined(__STDC__)
1095 #else /* !(defined(__cplusplus) || defined(__STDC__)) */
1097 #endif /* !(defined(__cplusplus) || defined(__STDC__)) */
1099 if ((yys = getenv("YYDEBUG")))
1102 if (yyn >= '0' && yyn <= '9')
1103 yydebug = yyn - '0';
1105 #endif /* YYDEBUG */
1111 if (yyss == NULL && yygrowstack()) goto yyoverflow;
1114 *yyssp = yystate = 0;
1117 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1120 if ((yychar = yylex()) < 0) yychar = 0;
1125 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1126 if (!yys) yys = "illegal-symbol";
1127 printf("%sdebug: state %d, reading %d (%s)\n",
1128 YYPREFIX, yystate, yychar, yys);
1132 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1133 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1137 printf("%sdebug: state %d, shifting to state %d\n",
1138 YYPREFIX, yystate, yytable[yyn]);
1140 if (yyssp >= yysslim && yygrowstack())
1144 *++yyssp = yystate = yytable[yyn];
1147 if (yyerrflag > 0) --yyerrflag;
1150 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1151 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1156 if (yyerrflag) goto yyinrecovery;
1157 #if defined(lint) || defined(__GNUC__)
1161 yyerror("syntax error");
1162 #if defined(lint) || defined(__GNUC__)
1173 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1174 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1178 printf("%sdebug: state %d, error recovery shifting\
1179 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1181 if (yyssp >= yysslim && yygrowstack())
1185 *++yyssp = yystate = yytable[yyn];
1193 printf("%sdebug: error recovery discarding state %d\n",
1196 if (yyssp <= yyss) goto yyabort;
1204 if (yychar == 0) goto yyabort;
1209 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1210 if (!yys) yys = "illegal-symbol";
1211 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1212 YYPREFIX, yystate, yychar, yys);
1221 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1222 YYPREFIX, yystate, yyn, yyrule[yyn]);
1225 yyval = yyvsp[1-yym];
1229 #line 275 "parse.yacc"
1233 #line 277 "parse.yacc"
1237 #line 278 "parse.yacc"
1241 #line 278 "parse.yacc"
1243 while (top && user_matches != TRUE)
1248 #line 283 "parse.yacc"
1252 #line 285 "parse.yacc"
1256 #line 287 "parse.yacc"
1260 #line 289 "parse.yacc"
1264 #line 291 "parse.yacc"
1268 #line 297 "parse.yacc"
1270 defaults_matches = TRUE;
1274 #line 300 "parse.yacc"
1278 #line 300 "parse.yacc"
1280 defaults_matches = user_matches;
1285 #line 304 "parse.yacc"
1289 #line 304 "parse.yacc"
1291 defaults_matches = yyvsp[0].BOOLEAN == TRUE;
1296 #line 308 "parse.yacc"
1300 #line 308 "parse.yacc"
1302 defaults_matches = host_matches;
1307 #line 318 "parse.yacc"
1309 if (defaults_matches == TRUE &&
1310 !set_default(yyvsp[0].string, NULL, TRUE)) {
1314 free(yyvsp[0].string);
1318 #line 326 "parse.yacc"
1320 if (defaults_matches == TRUE &&
1321 !set_default(yyvsp[0].string, NULL, FALSE)) {
1325 free(yyvsp[0].string);
1329 #line 334 "parse.yacc"
1331 if (defaults_matches == TRUE &&
1332 !set_default(yyvsp[-2].string, yyvsp[0].string, TRUE)) {
1336 free(yyvsp[-2].string);
1337 free(yyvsp[0].string);
1341 #line 343 "parse.yacc"
1343 if (defaults_matches == TRUE &&
1344 !set_default(yyvsp[-2].string, yyvsp[0].string, '+')) {
1348 free(yyvsp[-2].string);
1349 free(yyvsp[0].string);
1353 #line 352 "parse.yacc"
1355 if (defaults_matches == TRUE &&
1356 !set_default(yyvsp[-2].string, yyvsp[0].string, '-')) {
1360 free(yyvsp[-2].string);
1361 free(yyvsp[0].string);
1365 #line 367 "parse.yacc"
1368 * We already did a push if necessary in
1369 * cmndspec so just reset some values so
1370 * the next 'privilege' gets a clean slate.
1372 host_matches = UNSPEC;
1373 runas_matches = UNSPEC;
1374 no_passwd = def_authenticate ? UNSPEC : TRUE;
1375 no_execve = def_noexec ? TRUE : UNSPEC;
1379 #line 380 "parse.yacc"
1381 SETMATCH(host_matches, yyvsp[0].BOOLEAN);
1385 #line 383 "parse.yacc"
1387 SETNMATCH(host_matches, yyvsp[0].BOOLEAN);
1391 #line 388 "parse.yacc"
1393 yyval.BOOLEAN = TRUE;
1397 #line 391 "parse.yacc"
1399 if (addr_matches(yyvsp[0].string))
1400 yyval.BOOLEAN = TRUE;
1402 yyval.BOOLEAN = NOMATCH;
1403 free(yyvsp[0].string);
1407 #line 398 "parse.yacc"
1409 if (netgr_matches(yyvsp[0].string, user_host, user_shost, NULL))
1410 yyval.BOOLEAN = TRUE;
1412 yyval.BOOLEAN = NOMATCH;
1413 free(yyvsp[0].string);
1417 #line 405 "parse.yacc"
1419 if (hostname_matches(user_shost, user_host, yyvsp[0].string) == 0)
1420 yyval.BOOLEAN = TRUE;
1422 yyval.BOOLEAN = NOMATCH;
1423 free(yyvsp[0].string);
1427 #line 412 "parse.yacc"
1429 aliasinfo *aip = find_alias(yyvsp[0].string, HOST_ALIAS);
1431 /* could be an all-caps hostname */
1433 yyval.BOOLEAN = aip->val;
1434 else if (strcasecmp(user_shost, yyvsp[0].string) == 0)
1435 yyval.BOOLEAN = TRUE;
1438 (void) fprintf(stderr,
1439 "%s: undeclared Host_Alias `%s' referenced near line %d\n",
1440 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1446 yyval.BOOLEAN = NOMATCH;
1448 free(yyvsp[0].string);
1452 #line 440 "parse.yacc"
1455 * Push the entry onto the stack if it is worth
1456 * saving and reset cmnd_matches for next cmnd.
1458 * We need to save at least one entry on
1459 * the stack so sudoers_lookup() can tell that
1460 * the user was listed in sudoers. Also, we
1461 * need to be able to tell whether or not a
1462 * user was listed for this specific host.
1464 * If keepall is set and the user matches then
1465 * we need to keep entries around too...
1467 if (MATCHED(user_matches) &&
1468 MATCHED(host_matches) &&
1469 MATCHED(cmnd_matches) &&
1470 MATCHED(runas_matches))
1472 else if (MATCHED(user_matches) && (top == 1 ||
1473 (top == 2 && MATCHED(host_matches) &&
1474 !MATCHED(match[0].host))))
1476 else if (user_matches == TRUE && keepall)
1478 cmnd_matches = UNSPEC;
1482 #line 469 "parse.yacc"
1484 SETMATCH(cmnd_matches, yyvsp[0].BOOLEAN);
1488 #line 472 "parse.yacc"
1490 if (printmatches == TRUE) {
1491 if (in_alias == TRUE)
1492 append_entries("!", ", ");
1493 else if (host_matches == TRUE &&
1494 user_matches == TRUE)
1495 append_cmnd("!", NULL);
1500 #line 480 "parse.yacc"
1502 SETNMATCH(cmnd_matches, yyvsp[0].BOOLEAN);
1506 #line 485 "parse.yacc"
1508 if (printmatches == TRUE && host_matches == TRUE &&
1509 user_matches == TRUE) {
1510 if (runas_matches == UNSPEC) {
1511 cm_list[cm_list_len].runas_len = 0;
1513 /* Inherit runas data. */
1514 cm_list[cm_list_len].runas =
1515 estrdup(cm_list[cm_list_len-1].runas);
1516 cm_list[cm_list_len].runas_len =
1517 cm_list[cm_list_len-1].runas_len;
1518 cm_list[cm_list_len].runas_size =
1519 cm_list[cm_list_len-1].runas_size;
1523 * If this is the first entry in a command list
1524 * then check against default runas user.
1526 if (runas_matches == UNSPEC) {
1528 userpw_matches(def_runas_default,
1529 *user_runas, runas_pw);
1534 #line 510 "parse.yacc"
1536 runas_matches = yyvsp[0].BOOLEAN;
1540 #line 515 "parse.yacc"
1544 #line 516 "parse.yacc"
1546 /* Later entries override earlier ones. */
1547 if (yyvsp[0].BOOLEAN != NOMATCH)
1548 yyval.BOOLEAN = yyvsp[0].BOOLEAN;
1550 yyval.BOOLEAN = yyvsp[-2].BOOLEAN;
1554 #line 525 "parse.yacc"
1558 #line 526 "parse.yacc"
1560 if (printmatches == TRUE) {
1561 if (in_alias == TRUE)
1562 append_entries("!", ", ");
1563 else if (host_matches == TRUE &&
1564 user_matches == TRUE)
1565 append_runas("!", ", ");
1570 #line 534 "parse.yacc"
1572 /* Set $$ to the negation of runasuser */
1573 yyval.BOOLEAN = (yyvsp[0].BOOLEAN == NOMATCH ? NOMATCH : ! yyvsp[0].BOOLEAN);
1577 #line 540 "parse.yacc"
1579 if (printmatches == TRUE) {
1580 if (in_alias == TRUE)
1581 append_entries(yyvsp[0].string, ", ");
1582 else if (host_matches == TRUE &&
1583 user_matches == TRUE)
1584 append_runas(yyvsp[0].string, ", ");
1586 if (userpw_matches(yyvsp[0].string, *user_runas, runas_pw))
1587 yyval.BOOLEAN = TRUE;
1589 yyval.BOOLEAN = NOMATCH;
1590 free(yyvsp[0].string);
1595 #line 555 "parse.yacc"
1597 if (printmatches == TRUE) {
1598 if (in_alias == TRUE)
1599 append_entries(yyvsp[0].string, ", ");
1600 else if (host_matches == TRUE &&
1601 user_matches == TRUE)
1602 append_runas(yyvsp[0].string, ", ");
1604 if (usergr_matches(yyvsp[0].string, *user_runas, runas_pw))
1605 yyval.BOOLEAN = TRUE;
1607 yyval.BOOLEAN = NOMATCH;
1608 free(yyvsp[0].string);
1613 #line 570 "parse.yacc"
1615 if (printmatches == TRUE) {
1616 if (in_alias == TRUE)
1617 append_entries(yyvsp[0].string, ", ");
1618 else if (host_matches == TRUE &&
1619 user_matches == TRUE)
1620 append_runas(yyvsp[0].string, ", ");
1622 if (netgr_matches(yyvsp[0].string, NULL, NULL, *user_runas))
1623 yyval.BOOLEAN = TRUE;
1625 yyval.BOOLEAN = NOMATCH;
1626 free(yyvsp[0].string);
1631 #line 585 "parse.yacc"
1633 aliasinfo *aip = find_alias(yyvsp[0].string, RUNAS_ALIAS);
1635 if (printmatches == TRUE) {
1636 if (in_alias == TRUE)
1637 append_entries(yyvsp[0].string, ", ");
1638 else if (host_matches == TRUE &&
1639 user_matches == TRUE)
1640 append_runas(yyvsp[0].string, ", ");
1642 /* could be an all-caps username */
1644 yyval.BOOLEAN = aip->val;
1645 else if (strcmp(yyvsp[0].string, *user_runas) == 0)
1646 yyval.BOOLEAN = TRUE;
1649 (void) fprintf(stderr,
1650 "%s: undeclared Runas_Alias `%s' referenced near line %d\n",
1651 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1657 yyval.BOOLEAN = NOMATCH;
1659 free(yyvsp[0].string);
1664 #line 615 "parse.yacc"
1666 if (printmatches == TRUE) {
1667 if (in_alias == TRUE)
1668 append_entries("ALL", ", ");
1669 else if (host_matches == TRUE &&
1670 user_matches == TRUE)
1671 append_runas("ALL", ", ");
1673 yyval.BOOLEAN = TRUE;
1677 #line 627 "parse.yacc"
1679 /* Inherit {NOPASSWD,PASSWD,NOEXEC,EXEC} status. */
1680 if (printmatches == TRUE && host_matches == TRUE &&
1681 user_matches == TRUE) {
1682 if (no_passwd == TRUE)
1683 cm_list[cm_list_len].nopasswd = TRUE;
1685 cm_list[cm_list_len].nopasswd = FALSE;
1686 if (no_execve == TRUE)
1687 cm_list[cm_list_len].noexecve = TRUE;
1689 cm_list[cm_list_len].noexecve = FALSE;
1694 #line 641 "parse.yacc"
1697 if (printmatches == TRUE && host_matches == TRUE &&
1698 user_matches == TRUE)
1699 cm_list[cm_list_len].nopasswd = TRUE;
1703 #line 647 "parse.yacc"
1706 if (printmatches == TRUE && host_matches == TRUE &&
1707 user_matches == TRUE)
1708 cm_list[cm_list_len].nopasswd = FALSE;
1712 #line 653 "parse.yacc"
1715 if (printmatches == TRUE && host_matches == TRUE &&
1716 user_matches == TRUE)
1717 cm_list[cm_list_len].noexecve = TRUE;
1721 #line 659 "parse.yacc"
1724 if (printmatches == TRUE && host_matches == TRUE &&
1725 user_matches == TRUE)
1726 cm_list[cm_list_len].noexecve = FALSE;
1730 #line 667 "parse.yacc"
1732 if (printmatches == TRUE) {
1733 if (in_alias == TRUE)
1734 append_entries("ALL", ", ");
1735 else if (host_matches == TRUE &&
1736 user_matches == TRUE) {
1737 append_cmnd("ALL", NULL);
1738 expand_match_list();
1742 yyval.BOOLEAN = TRUE;
1746 #line 680 "parse.yacc"
1750 if (printmatches == TRUE) {
1751 if (in_alias == TRUE)
1752 append_entries(yyvsp[0].string, ", ");
1753 else if (host_matches == TRUE &&
1754 user_matches == TRUE) {
1755 append_cmnd(yyvsp[0].string, NULL);
1756 expand_match_list();
1760 if ((aip = find_alias(yyvsp[0].string, CMND_ALIAS)))
1761 yyval.BOOLEAN = aip->val;
1764 (void) fprintf(stderr,
1765 "%s: undeclared Cmnd_Alias `%s' referenced near line %d\n",
1766 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1772 yyval.BOOLEAN = NOMATCH;
1774 free(yyvsp[0].string);
1778 #line 709 "parse.yacc"
1780 if (printmatches == TRUE) {
1781 if (in_alias == TRUE) {
1782 append_entries(yyvsp[0].command.cmnd, ", ");
1783 if (yyvsp[0].command.args)
1784 append_entries(yyvsp[0].command.args, " ");
1786 if (host_matches == TRUE &&
1787 user_matches == TRUE) {
1788 append_cmnd(yyvsp[0].command.cmnd, NULL);
1789 if (yyvsp[0].command.args)
1790 append_cmnd(yyvsp[0].command.args, " ");
1791 expand_match_list();
1795 if (command_matches(yyvsp[0].command.cmnd, yyvsp[0].command.args))
1796 yyval.BOOLEAN = TRUE;
1798 yyval.BOOLEAN = NOMATCH;
1800 free(yyvsp[0].command.cmnd);
1801 if (yyvsp[0].command.args)
1802 free(yyvsp[0].command.args);
1806 #line 740 "parse.yacc"
1810 #line 740 "parse.yacc"
1812 if ((MATCHED(host_matches) || pedantic) &&
1813 !add_alias(yyvsp[-3].string, HOST_ALIAS, host_matches)) {
1821 #line 758 "parse.yacc"
1824 if (printmatches == TRUE) {
1826 /* Allocate space for ga_list if necessary. */
1828 ga_list[ga_list_len-1].type = CMND_ALIAS;
1829 ga_list[ga_list_len-1].alias = estrdup(yyvsp[0].string);
1834 #line 767 "parse.yacc"
1836 if ((MATCHED(cmnd_matches) || pedantic) &&
1837 !add_alias(yyvsp[-3].string, CMND_ALIAS, cmnd_matches)) {
1842 free(yyvsp[-3].string);
1844 if (printmatches == TRUE)
1849 #line 781 "parse.yacc"
1853 #line 789 "parse.yacc"
1855 if (printmatches == TRUE) {
1857 /* Allocate space for ga_list if necessary. */
1859 ga_list[ga_list_len-1].type = RUNAS_ALIAS;
1860 ga_list[ga_list_len-1].alias = estrdup(yyvsp[0].string);
1865 #line 797 "parse.yacc"
1867 if ((yyvsp[0].BOOLEAN != NOMATCH || pedantic) &&
1868 !add_alias(yyvsp[-3].string, RUNAS_ALIAS, yyvsp[0].BOOLEAN)) {
1872 free(yyvsp[-3].string);
1874 if (printmatches == TRUE)
1879 #line 814 "parse.yacc"
1883 #line 814 "parse.yacc"
1885 if ((MATCHED(user_matches) || pedantic) &&
1886 !add_alias(yyvsp[-3].string, USER_ALIAS, user_matches)) {
1891 free(yyvsp[-3].string);
1895 #line 829 "parse.yacc"
1897 SETMATCH(user_matches, yyvsp[0].BOOLEAN);
1901 #line 832 "parse.yacc"
1903 SETNMATCH(user_matches, yyvsp[0].BOOLEAN);
1907 #line 837 "parse.yacc"
1909 if (userpw_matches(yyvsp[0].string, user_name, sudo_user.pw))
1910 yyval.BOOLEAN = TRUE;
1912 yyval.BOOLEAN = NOMATCH;
1913 free(yyvsp[0].string);
1917 #line 844 "parse.yacc"
1919 if (usergr_matches(yyvsp[0].string, user_name, sudo_user.pw))
1920 yyval.BOOLEAN = TRUE;
1922 yyval.BOOLEAN = NOMATCH;
1923 free(yyvsp[0].string);
1927 #line 851 "parse.yacc"
1929 if (netgr_matches(yyvsp[0].string, NULL, NULL, user_name))
1930 yyval.BOOLEAN = TRUE;
1932 yyval.BOOLEAN = NOMATCH;
1933 free(yyvsp[0].string);
1937 #line 858 "parse.yacc"
1939 aliasinfo *aip = find_alias(yyvsp[0].string, USER_ALIAS);
1941 /* could be an all-caps username */
1943 yyval.BOOLEAN = aip->val;
1944 else if (strcmp(yyvsp[0].string, user_name) == 0)
1945 yyval.BOOLEAN = TRUE;
1948 (void) fprintf(stderr,
1949 "%s: undeclared User_Alias `%s' referenced near line %d\n",
1950 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1956 yyval.BOOLEAN = NOMATCH;
1958 free(yyvsp[0].string);
1962 #line 880 "parse.yacc"
1964 yyval.BOOLEAN = TRUE;
1967 #line 1916 "sudo.tab.c"
1973 if (yystate == 0 && yym == 0)
1977 printf("%sdebug: after reduction, shifting from state 0 to\
1978 state %d\n", YYPREFIX, YYFINAL);
1985 if ((yychar = yylex()) < 0) yychar = 0;
1990 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1991 if (!yys) yys = "illegal-symbol";
1992 printf("%sdebug: state %d, reading %d (%s)\n",
1993 YYPREFIX, YYFINAL, yychar, yys);
1997 if (yychar == 0) goto yyaccept;
2000 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
2001 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
2002 yystate = yytable[yyn];
2004 yystate = yydgoto[yym];
2007 printf("%sdebug: after reduction, shifting from state %d \
2008 to state %d\n", YYPREFIX, *yyssp, yystate);
2010 if (yyssp >= yysslim && yygrowstack())
2018 yyerror("yacc stack overflow");
2024 yyss = yyssp = NULL;
2025 yyvs = yyvsp = NULL;
2033 yyss = yyssp = NULL;
2034 yyvs = yyvsp = NULL;