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.26 2006/04/20 16:51:32 deraadt Exp $";
15 #define yyclearin (yychar=(YYEMPTY))
16 #define yyerrok (yyerrflag=0)
17 #define YYRECOVERING() (yyerrflag!=0)
21 * Copyright (c) 1996, 1998-2004, 2007
22 * Todd C. Miller <Todd.Miller@courtesan.com>
24 * Permission to use, copy, modify, and distribute this software for any
25 * purpose with or without fee is hereby granted, provided that the above
26 * copyright notice and this permission notice appear in all copies.
28 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
29 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
30 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
31 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
32 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
33 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
34 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * Sponsored in part by the Defense Advanced Research Projects
39 * Agency (DARPA) and Air Force Research Laboratory, Air Force
40 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
44 * XXX - the whole opFOO naming thing is somewhat bogus.
46 * XXX - the way things are stored for printmatches is stupid,
47 * they should be stored as elements in an array and then
48 * list_matches() can format things the way it wants.
53 #include <sys/types.h>
54 #include <sys/param.h>
63 #endif /* STDC_HEADERS */
67 # ifdef HAVE_STRINGS_H
70 #endif /* HAVE_STRING_H */
73 #endif /* HAVE_UNISTD_H */
75 #if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
77 #endif /* HAVE_MALLOC_H && !STDC_HEADERS */
78 #if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
80 #endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */
83 #endif /* HAVE_LSEARCH */
89 #include "emul/search.h"
90 #endif /* HAVE_LSEARCH */
93 __unused static const char rcsid[] = "$Sudo: sudo.tab.c,v 1.76.2.6 2007/08/13 16:30:47 millert Exp $";
99 extern int sudolineno, parse_error;
100 int errorlineno = -1;
101 int clearaliases = TRUE;
102 int printmatches = FALSE;
103 int pedantic = FALSE;
106 int used_runas = FALSE;
114 #define RUNAS_ALIAS 4
116 #define SETMATCH(_var, _val) do { \
117 if ((_var) == UNSPEC || (_val) != NOMATCH) \
121 #define SETNMATCH(_var, _val) do { \
122 if ((_val) != NOMATCH) \
124 else if ((_var) == UNSPEC) \
129 * The matching stack, initial space allocated in init_parser().
131 struct matchstack *match;
132 int top = 0, stacksize = 0;
136 if (top >= stacksize) { \
137 while ((stacksize += STACKINCREMENT) < top); \
138 match = (struct matchstack *) erealloc3(match, stacksize, sizeof(struct matchstack)); \
140 match[top].user = UNSPEC; \
141 match[top].cmnd = UNSPEC; \
142 match[top].host = UNSPEC; \
143 match[top].runas = UNSPEC; \
144 match[top].nopass = def_authenticate ? UNSPEC : TRUE; \
145 match[top].noexec = def_noexec ? TRUE : UNSPEC; \
146 match[top].setenv = def_setenv ? TRUE : UNSPEC; \
152 if (top >= stacksize) { \
153 while ((stacksize += STACKINCREMENT) < top); \
154 match = (struct matchstack *) erealloc3(match, stacksize, sizeof(struct matchstack)); \
156 match[top].user = match[top-1].user; \
157 match[top].cmnd = match[top-1].cmnd; \
158 match[top].host = match[top-1].host; \
159 match[top].runas = match[top-1].runas; \
160 match[top].nopass = match[top-1].nopass; \
161 match[top].noexec = match[top-1].noexec; \
162 match[top].setenv = match[top-1].setenv; \
169 yyerror("matching stack underflow"); \
176 * For testing if foo_matches variable was set to TRUE or FALSE
178 #define MATCHED(_v) ((_v) >= 0)
181 * Shortcuts for append()
183 #define append_cmnd(s, p) append(s, &cm_list[cm_list_len].cmnd, \
184 &cm_list[cm_list_len].cmnd_len, &cm_list[cm_list_len].cmnd_size, p)
186 #define append_runas(s, p) append(s, &cm_list[cm_list_len].runas, \
187 &cm_list[cm_list_len].runas_len, &cm_list[cm_list_len].runas_size, p)
189 #define append_entries(s, p) append(s, &ga_list[ga_list_len-1].entries, \
190 &ga_list[ga_list_len-1].entries_len, \
191 &ga_list[ga_list_len-1].entries_size, p)
194 * The stack for printmatches. A list of allowed commands for the user.
196 static struct command_match *cm_list = NULL;
197 static size_t cm_list_len = 0, cm_list_size = 0;
200 * List of Cmnd_Aliases and expansions for `sudo -l'
202 static int in_alias = FALSE;
203 static size_t ga_list_len = 0, ga_list_size = 0;
204 static struct generic_alias *ga_list = NULL;
207 * Does this Defaults list pertain to this user?
209 static int defaults_matches = FALSE;
214 static int add_alias __P((char *, int, int));
215 static void append __P((char *, char **, size_t *, size_t *, char *));
216 static void expand_ga_list __P((void));
217 static void expand_match_list __P((void));
218 static aliasinfo *find_alias __P((char *, int));
219 static int more_aliases __P((void));
220 void init_parser __P((void));
221 void yyerror __P((char *));
227 /* Save the line the first error occurred on. */
228 if (errorlineno == -1)
229 errorlineno = sudolineno ? sudolineno - 1 : 0;
232 (void) fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s,
233 sudolineno ? sudolineno - 1 : 0);
235 (void) fprintf(stderr, "<*> ");
240 #line 224 "parse.yacc"
241 #ifndef YYSTYPE_DEFINED
242 #define YYSTYPE_DEFINED
246 struct sudo_command command;
249 #endif /* YYSTYPE_DEFINED */
250 #line 251 "sudo.tab.c"
256 #define USERGROUP 262
259 #define DEFAULTS_HOST 265
260 #define DEFAULTS_USER 266
261 #define DEFAULTS_RUNAS 267
271 #define HOSTALIAS 277
272 #define CMNDALIAS 278
273 #define USERALIAS 279
274 #define RUNASALIAS 280
276 #define YYERRCODE 256
277 #if defined(__cplusplus) || defined(__STDC__)
278 const short yylhs[] =
283 0, 0, 7, 7, 9, 7, 7, 7, 7, 7,
284 7, 15, 16, 18, 16, 19, 16, 21, 16, 17,
285 17, 22, 22, 22, 22, 22, 10, 10, 23, 25,
286 25, 2, 2, 2, 2, 2, 24, 24, 26, 29,
287 30, 29, 27, 27, 5, 5, 4, 31, 4, 3,
288 3, 3, 3, 3, 28, 28, 28, 28, 28, 28,
289 28, 1, 1, 1, 12, 12, 33, 32, 20, 20,
290 13, 13, 35, 34, 36, 36, 14, 14, 38, 37,
291 11, 11, 40, 39, 8, 8, 41, 41, 6, 6,
294 #if defined(__cplusplus) || defined(__STDC__)
295 const short yylen[] =
300 1, 2, 1, 2, 0, 3, 2, 2, 2, 2,
301 1, 2, 1, 0, 3, 0, 3, 0, 3, 1,
302 3, 1, 2, 3, 3, 3, 1, 3, 3, 1,
303 2, 1, 1, 1, 1, 1, 1, 3, 3, 1,
304 0, 3, 0, 2, 1, 3, 1, 0, 3, 1,
305 1, 1, 1, 1, 0, 2, 2, 2, 2, 2,
306 2, 1, 1, 1, 1, 3, 0, 4, 1, 3,
307 1, 3, 0, 4, 1, 3, 1, 3, 0, 4,
308 1, 3, 0, 4, 1, 3, 1, 2, 1, 1,
311 #if defined(__cplusplus) || defined(__STDC__)
312 const short yydefred[] =
317 0, 13, 18, 14, 16, 3, 0, 0, 0, 0,
318 0, 1, 0, 11, 0, 4, 0, 0, 0, 67,
319 0, 65, 73, 0, 71, 83, 0, 81, 79, 0,
320 77, 2, 92, 91, 90, 89, 93, 0, 87, 0,
321 85, 0, 0, 12, 0, 36, 33, 34, 35, 32,
322 0, 30, 0, 69, 0, 53, 52, 51, 50, 54,
323 48, 47, 45, 0, 0, 0, 0, 0, 0, 0,
324 0, 0, 88, 0, 0, 0, 27, 0, 0, 0,
325 23, 0, 31, 0, 0, 0, 0, 66, 0, 72,
326 0, 82, 0, 78, 86, 0, 0, 24, 25, 26,
327 21, 70, 49, 46, 0, 64, 63, 62, 41, 40,
328 75, 0, 0, 0, 28, 0, 0, 37, 55, 0,
329 0, 0, 0, 0, 42, 76, 38, 56, 57, 58,
332 #if defined(__cplusplus) || defined(__STDC__)
333 const short yydgoto[] =
338 110, 52, 62, 63, 64, 39, 12, 40, 13, 75,
339 27, 21, 24, 30, 14, 15, 44, 18, 19, 76,
340 17, 45, 77, 117, 54, 118, 119, 124, 111, 120,
341 85, 22, 65, 25, 67, 112, 31, 71, 28, 69,
344 #if defined(__cplusplus) || defined(__STDC__)
345 const short yysindex[] =
350 -256, 0, 0, 0, 0, 0, -237, -234, -226, -225,
351 -229, 0, 62, 0, -33, 0, 88, 62, 114, 0,
352 -15, 0, 0, -12, 0, 0, -5, 0, 0, -4,
353 0, 0, 0, 0, 0, 0, 0, -244, 0, -28,
354 0, -36, -204, 0, 14, 0, 0, 0, 0, 0,
355 -219, 0, 19, 0, 20, 0, 0, 0, 0, 0,
356 0, 0, 0, 21, 5, -237, 6, -234, 7, -226,
357 8, -225, 0, 62, 12, -21, 0, -192, -191, -187,
358 0, -33, 0, 88, -201, 114, 88, 0, 276, 0,
359 62, 0, 114, 0, 0, 88, -189, 0, 0, 0,
360 0, 0, 0, 0, 19, 0, 0, 0, 0, 0,
361 0, 33, 20, 21, 0, 114, 36, 0, 0, -247,
362 276, 21, -189, -29, 0, 0, 0, 0, 0, 0,
364 #if defined(__cplusplus) || defined(__STDC__)
365 const short yyrindex[] =
370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
371 140, 0, 0, 0, 0, 0, 0, 0, 0, 0,
372 156, 0, 0, 181, 0, 0, 206, 0, 0, 236,
373 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
374 0, 1, 0, 0, 261, 0, 0, 0, 0, 0,
375 0, 0, -25, 0, -11, 0, 0, 0, 0, 0,
376 0, 0, 0, -3, 0, 0, 0, 0, 0, 0,
377 0, 0, 0, 0, 300, 0, 0, 0, 0, 0,
378 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
379 0, 0, 0, 0, 0, 0, -20, 0, 0, 0,
380 0, 0, 0, 0, 26, 0, 0, 0, 0, 0,
381 0, 52, 78, 104, 0, 0, 130, 0, 0, 0,
382 0, 274, -20, 0, 0, 0, 0, 0, 0, 0,
384 #if defined(__cplusplus) || defined(__STDC__)
385 const short yygindex[] =
390 -39, 31, -2, 2, -87, 48, 76, -16, 0, 0,
391 0, 0, 0, 0, 0, 0, 9, 0, 0, -14,
392 0, 0, -7, 0, 10, -31, 0, 0, -109, 0,
393 0, 24, 0, 25, 0, 0, 27, 0, 28, 0,
396 #define YYTABLESIZE 580
397 #if defined(__cplusplus) || defined(__STDC__)
398 const short yytable[] =
403 22, 55, 53, 109, 51, 114, 79, 19, 80, 106,
404 107, 126, 43, 33, 134, 74, 34, 35, 36, 16,
405 20, 15, 84, 23, 78, 68, 1, 108, 122, 17,
406 37, 26, 29, 22, 2, 3, 4, 5, 46, 97,
407 47, 48, 66, 49, 22, 68, 6, 7, 8, 9,
408 10, 74, 70, 72, 81, 50, 56, 82, 68, 57,
409 58, 59, 84, 74, 86, 87, 89, 91, 93, 96,
410 98, 99, 105, 60, 113, 100, 121, 84, 116, 123,
411 125, 83, 103, 68, 74, 73, 32, 104, 115, 88,
412 101, 127, 90, 102, 38, 95, 0, 92, 94, 0,
413 0, 0, 0, 80, 0, 0, 0, 0, 0, 74,
414 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
415 51, 0, 0, 0, 0, 0, 0, 0, 0, 29,
416 0, 0, 0, 0, 0, 84, 80, 0, 0, 0,
417 0, 0, 0, 0, 0, 0, 61, 0, 0, 0,
418 0, 0, 0, 0, 0, 8, 0, 0, 0, 0,
419 0, 80, 29, 0, 0, 0, 0, 0, 0, 0,
420 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
421 9, 0, 0, 0, 0, 0, 0, 29, 8, 0,
422 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
423 0, 0, 0, 0, 0, 7, 0, 0, 0, 0,
424 0, 0, 0, 9, 0, 0, 0, 0, 0, 0,
425 0, 0, 0, 0, 0, 42, 0, 106, 107, 46,
426 0, 47, 48, 19, 49, 10, 43, 43, 7, 128,
427 129, 130, 131, 132, 133, 108, 50, 15, 43, 43,
428 43, 43, 43, 43, 43, 17, 22, 0, 22, 0,
429 20, 22, 22, 22, 22, 22, 22, 22, 10, 0,
430 0, 0, 0, 0, 0, 22, 22, 22, 22, 22,
431 22, 68, 0, 68, 0, 0, 68, 68, 68, 68,
432 68, 68, 68, 20, 0, 0, 0, 0, 0, 6,
433 68, 68, 68, 68, 68, 68, 44, 74, 109, 74,
434 0, 0, 74, 74, 74, 74, 74, 74, 74, 33,
435 0, 0, 34, 35, 36, 0, 74, 74, 74, 74,
436 74, 74, 6, 84, 0, 84, 37, 0, 84, 84,
437 84, 84, 84, 84, 84, 46, 0, 47, 48, 0,
438 49, 0, 84, 84, 84, 84, 84, 84, 0, 80,
439 0, 80, 50, 0, 80, 80, 80, 80, 80, 80,
440 80, 56, 0, 0, 57, 58, 59, 0, 80, 80,
441 80, 80, 80, 80, 0, 29, 0, 29, 60, 0,
442 29, 29, 29, 29, 29, 29, 29, 5, 0, 0,
443 5, 5, 5, 0, 29, 29, 29, 29, 29, 29,
444 0, 8, 0, 8, 5, 0, 8, 8, 8, 8,
445 8, 8, 8, 0, 0, 0, 0, 0, 0, 0,
446 8, 8, 8, 8, 8, 8, 9, 0, 9, 0,
447 0, 9, 9, 9, 9, 9, 9, 9, 0, 0,
448 0, 0, 0, 0, 0, 9, 9, 9, 9, 9,
449 9, 7, 0, 7, 0, 0, 7, 7, 7, 7,
450 7, 7, 7, 0, 0, 0, 0, 0, 0, 0,
451 7, 7, 7, 7, 7, 7, 0, 0, 0, 0,
452 0, 10, 0, 10, 0, 0, 10, 10, 10, 10,
453 10, 10, 10, 0, 0, 0, 0, 0, 0, 0,
454 10, 10, 10, 10, 10, 10, 20, 0, 20, 0,
455 0, 20, 20, 20, 20, 20, 20, 20, 0, 0,
456 44, 44, 106, 107, 0, 20, 20, 20, 20, 20,
457 20, 0, 44, 44, 44, 44, 44, 44, 44, 0,
458 108, 0, 0, 0, 0, 6, 0, 6, 0, 0,
459 6, 6, 6, 6, 6, 6, 6, 0, 0, 0,
460 0, 0, 0, 0, 6, 6, 6, 6, 6, 6,
462 #if defined(__cplusplus) || defined(__STDC__)
463 const short yycheck[] =
468 0, 18, 17, 33, 33, 93, 43, 33, 45, 257,
469 258, 121, 33, 258, 124, 44, 261, 262, 263, 276,
470 258, 33, 44, 258, 61, 0, 256, 275, 116, 33,
471 275, 258, 258, 33, 264, 265, 266, 267, 258, 61,
472 260, 261, 58, 263, 44, 58, 276, 277, 278, 279,
473 280, 0, 58, 58, 259, 275, 258, 44, 33, 261,
474 262, 263, 44, 44, 44, 61, 61, 61, 61, 58,
475 263, 263, 87, 275, 91, 263, 44, 0, 268, 44,
476 120, 51, 85, 58, 33, 38, 11, 86, 96, 66,
477 82, 123, 68, 84, 33, 74, -1, 70, 72, -1,
478 -1, -1, -1, 0, -1, -1, -1, -1, -1, 58,
479 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
480 33, -1, -1, -1, -1, -1, -1, -1, -1, 0,
481 -1, -1, -1, -1, -1, 58, 33, -1, -1, -1,
482 -1, -1, -1, -1, -1, -1, 33, -1, -1, -1,
483 -1, -1, -1, -1, -1, 0, -1, -1, -1, -1,
484 -1, 58, 33, -1, -1, -1, -1, -1, -1, -1,
485 -1, -1, 33, -1, -1, -1, -1, -1, -1, -1,
486 0, -1, -1, -1, -1, -1, -1, 58, 33, -1,
487 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
488 -1, -1, -1, -1, -1, 0, -1, -1, -1, -1,
489 -1, -1, -1, 33, -1, -1, -1, -1, -1, -1,
490 -1, -1, -1, -1, -1, 259, -1, 257, 258, 258,
491 -1, 260, 261, 259, 263, 0, 257, 258, 33, 269,
492 270, 271, 272, 273, 274, 275, 275, 259, 269, 270,
493 271, 272, 273, 274, 275, 259, 256, -1, 258, -1,
494 0, 261, 262, 263, 264, 265, 266, 267, 33, -1,
495 -1, -1, -1, -1, -1, 275, 276, 277, 278, 279,
496 280, 256, -1, 258, -1, -1, 261, 262, 263, 264,
497 265, 266, 267, 33, -1, -1, -1, -1, -1, 0,
498 275, 276, 277, 278, 279, 280, 33, 256, 33, 258,
499 -1, -1, 261, 262, 263, 264, 265, 266, 267, 258,
500 -1, -1, 261, 262, 263, -1, 275, 276, 277, 278,
501 279, 280, 33, 256, -1, 258, 275, -1, 261, 262,
502 263, 264, 265, 266, 267, 258, -1, 260, 261, -1,
503 263, -1, 275, 276, 277, 278, 279, 280, -1, 256,
504 -1, 258, 275, -1, 261, 262, 263, 264, 265, 266,
505 267, 258, -1, -1, 261, 262, 263, -1, 275, 276,
506 277, 278, 279, 280, -1, 256, -1, 258, 275, -1,
507 261, 262, 263, 264, 265, 266, 267, 258, -1, -1,
508 261, 262, 263, -1, 275, 276, 277, 278, 279, 280,
509 -1, 256, -1, 258, 275, -1, 261, 262, 263, 264,
510 265, 266, 267, -1, -1, -1, -1, -1, -1, -1,
511 275, 276, 277, 278, 279, 280, 256, -1, 258, -1,
512 -1, 261, 262, 263, 264, 265, 266, 267, -1, -1,
513 -1, -1, -1, -1, -1, 275, 276, 277, 278, 279,
514 280, 256, -1, 258, -1, -1, 261, 262, 263, 264,
515 265, 266, 267, -1, -1, -1, -1, -1, -1, -1,
516 275, 276, 277, 278, 279, 280, -1, -1, -1, -1,
517 -1, 256, -1, 258, -1, -1, 261, 262, 263, 264,
518 265, 266, 267, -1, -1, -1, -1, -1, -1, -1,
519 275, 276, 277, 278, 279, 280, 256, -1, 258, -1,
520 -1, 261, 262, 263, 264, 265, 266, 267, -1, -1,
521 257, 258, 257, 258, -1, 275, 276, 277, 278, 279,
522 280, -1, 269, 270, 271, 272, 273, 274, 275, -1,
523 275, -1, -1, -1, -1, 256, -1, 258, -1, -1,
524 261, 262, 263, 264, 265, 266, 267, -1, -1, -1,
525 -1, -1, -1, -1, 275, 276, 277, 278, 279, 280,
531 #define YYMAXTOKEN 281
533 #if defined(__cplusplus) || defined(__STDC__)
534 const char * const yyname[] =
539 "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,
540 "'!'",0,0,0,0,0,0,0,0,0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,
541 "'='",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,
542 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,
543 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,
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,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,
546 "COMMAND","ALIAS","DEFVAR","NTWKADDR","NETGROUP","USERGROUP","WORD","DEFAULTS",
547 "DEFAULTS_HOST","DEFAULTS_USER","DEFAULTS_RUNAS","RUNAS","NOPASSWD","PASSWD",
548 "NOEXEC","EXEC","SETENV","NOSETENV","ALL","COMMENT","HOSTALIAS","CMNDALIAS",
549 "USERALIAS","RUNASALIAS","ERROR",
551 #if defined(__cplusplus) || defined(__STDC__)
552 const char * const yyrule[] =
560 "entry : error COMMENT",
562 "entry : $$1 userlist privileges",
563 "entry : USERALIAS useraliases",
564 "entry : HOSTALIAS hostaliases",
565 "entry : CMNDALIAS cmndaliases",
566 "entry : RUNASALIAS runasaliases",
567 "entry : defaults_line",
568 "defaults_line : defaults_type defaults_list",
569 "defaults_type : DEFAULTS",
571 "defaults_type : DEFAULTS_USER $$2 userlist",
573 "defaults_type : DEFAULTS_RUNAS $$3 runaslist",
575 "defaults_type : DEFAULTS_HOST $$4 hostlist",
576 "defaults_list : defaults_entry",
577 "defaults_list : defaults_entry ',' defaults_list",
578 "defaults_entry : DEFVAR",
579 "defaults_entry : '!' DEFVAR",
580 "defaults_entry : DEFVAR '=' WORD",
581 "defaults_entry : DEFVAR '+' WORD",
582 "defaults_entry : DEFVAR '-' WORD",
583 "privileges : privilege",
584 "privileges : privileges ':' privilege",
585 "privilege : hostlist '=' cmndspeclist",
593 "cmndspeclist : cmndspec",
594 "cmndspeclist : cmndspeclist ',' cmndspec",
595 "cmndspec : runasspec cmndtag opcmnd",
598 "opcmnd : '!' $$5 cmnd",
600 "runasspec : RUNAS runaslist",
601 "runaslist : oprunasuser",
602 "runaslist : runaslist ',' oprunasuser",
603 "oprunasuser : runasuser",
605 "oprunasuser : '!' $$6 runasuser",
607 "runasuser : USERGROUP",
608 "runasuser : NETGROUP",
612 "cmndtag : cmndtag NOPASSWD",
613 "cmndtag : cmndtag PASSWD",
614 "cmndtag : cmndtag NOEXEC",
615 "cmndtag : cmndtag EXEC",
616 "cmndtag : cmndtag SETENV",
617 "cmndtag : cmndtag NOSETENV",
621 "hostaliases : hostalias",
622 "hostaliases : hostaliases ':' hostalias",
624 "hostalias : ALIAS $$7 '=' hostlist",
626 "hostlist : hostlist ',' ophost",
627 "cmndaliases : cmndalias",
628 "cmndaliases : cmndaliases ':' cmndalias",
630 "cmndalias : ALIAS $$8 '=' cmndlist",
632 "cmndlist : cmndlist ',' opcmnd",
633 "runasaliases : runasalias",
634 "runasaliases : runasaliases ':' runasalias",
636 "runasalias : ALIAS $$9 '=' runaslist",
637 "useraliases : useralias",
638 "useraliases : useraliases ':' useralias",
640 "useralias : ALIAS $$10 '=' userlist",
642 "userlist : userlist ',' opuser",
654 #define YYMAXDEPTH YYSTACKSIZE
657 #define YYSTACKSIZE YYMAXDEPTH
659 #define YYSTACKSIZE 10000
660 #define YYMAXDEPTH 10000
663 #define YYINITSTACKSIZE 200
677 #line 909 "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 /* Is setenv enabled? */
880 if (cm_list[count].setenv == TRUE && !def_setenv)
881 (void) fputs("SETENV: ", stdout);
882 else if (cm_list[count].setenv == FALSE && def_setenv)
883 (void) fputs("NOSETENV: ", stdout);
885 /* Print the actual command or expanded Cmnd_Alias. */
886 key.alias = cm_list[count].cmnd;
887 key.type = CMND_ALIAS;
888 if ((ga = (struct generic_alias *) lfind((VOID *) &key,
889 (VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp)))
890 (void) puts(ga->entries);
892 (void) puts(cm_list[count].cmnd);
895 /* Be nice and free up space now that we are done. */
896 for (count = 0; count < ga_list_len; count++) {
897 efree(ga_list[count].alias);
898 efree(ga_list[count].entries);
903 for (count = 0; count < cm_list_len; count++) {
904 efree(cm_list[count].runas);
905 efree(cm_list[count].cmnd);
914 * Appends a source string to the destination, optionally prefixing a separator.
917 append(src, dstp, dst_len, dst_size, separator)
919 size_t *dst_len, *dst_size;
922 size_t src_len = strlen(src);
926 * Only add the separator if there is something to separate from.
927 * If the last char is a '!', don't apply the separator (XXX).
929 if (separator && dst && dst[*dst_len - 1] != '!')
930 src_len += strlen(separator);
934 /* Assumes dst will be NULL if not set. */
936 dst = (char *) emalloc(BUFSIZ);
943 /* Allocate more space if necessary. */
944 if (*dst_size <= *dst_len + src_len) {
945 while (*dst_size <= *dst_len + src_len)
948 dst = (char *) erealloc(dst, *dst_size);
952 /* Copy src -> dst adding a separator if appropriate and adjust len. */
954 (void) strlcat(dst, separator, *dst_size);
955 (void) strlcat(dst, src, *dst_size);
960 * Frees up space used by the aliases list and resets the associated counters.
968 for (n = 0; n < naliases; n++)
969 efree(aliases[n].name);
973 naliases = nslots = 0;
977 * Increments ga_list_len, allocating more space as necessary.
983 if (++ga_list_len >= ga_list_size) {
984 while ((ga_list_size += STACKINCREMENT) < ga_list_len)
986 ga_list = (struct generic_alias *)
987 erealloc3(ga_list, ga_list_size, sizeof(struct generic_alias));
990 ga_list[ga_list_len - 1].entries = NULL;
994 * Increments cm_list_len, allocating more space as necessary.
1000 if (++cm_list_len >= cm_list_size) {
1001 while ((cm_list_size += STACKINCREMENT) < cm_list_len)
1003 if (cm_list == NULL)
1004 cm_list_len = 0; /* start at 0 since it is a subscript */
1005 cm_list = (struct command_match *)
1006 erealloc3(cm_list, cm_list_size, sizeof(struct command_match));
1009 cm_list[cm_list_len].runas = cm_list[cm_list_len].cmnd = NULL;
1010 cm_list[cm_list_len].nopasswd = FALSE;
1011 cm_list[cm_list_len].noexecve = FALSE;
1012 cm_list[cm_list_len].setenv = FALSE;
1016 * Frees up spaced used by a previous parser run and allocates new space
1017 * for various data structures.
1023 /* Free up old data structures if we run the parser more than once. */
1028 parse_error = FALSE;
1034 /* Allocate space for the matching stack. */
1035 stacksize = STACKINCREMENT;
1036 match = (struct matchstack *) emalloc2(stacksize, sizeof(struct matchstack));
1038 /* Allocate space for the match list (for `sudo -l'). */
1039 if (printmatches == TRUE)
1040 expand_match_list();
1042 #line 991 "sudo.tab.c"
1043 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1044 #if defined(__cplusplus) || defined(__STDC__)
1045 static int yygrowstack(void)
1047 static int yygrowstack()
1054 if ((newsize = yystacksize) == 0)
1055 newsize = YYINITSTACKSIZE;
1056 else if (newsize >= YYMAXDEPTH)
1058 else if ((newsize *= 2) > YYMAXDEPTH)
1059 newsize = YYMAXDEPTH;
1061 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
1062 (short *)malloc(newsize * sizeof *newss);
1067 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
1068 (YYSTYPE *)malloc(newsize * sizeof *newvs);
1073 yystacksize = newsize;
1074 yysslim = yyss + newsize - 1;
1081 yyss = yyssp = NULL;
1082 yyvs = yyvsp = NULL;
1087 #define YYABORT goto yyabort
1088 #define YYREJECT goto yyabort
1089 #define YYACCEPT goto yyaccept
1090 #define YYERROR goto yyerrlab
1092 #if defined(__cplusplus) || defined(__STDC__)
1098 int yym, yyn, yystate;
1100 #if defined(__cplusplus) || defined(__STDC__)
1102 #else /* !(defined(__cplusplus) || defined(__STDC__)) */
1104 #endif /* !(defined(__cplusplus) || defined(__STDC__)) */
1106 if ((yys = getenv("YYDEBUG")))
1109 if (yyn >= '0' && yyn <= '9')
1110 yydebug = yyn - '0';
1112 #endif /* YYDEBUG */
1118 if (yyss == NULL && yygrowstack()) goto yyoverflow;
1121 *yyssp = yystate = 0;
1124 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1127 if ((yychar = yylex()) < 0) yychar = 0;
1132 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1133 if (!yys) yys = "illegal-symbol";
1134 printf("%sdebug: state %d, reading %d (%s)\n",
1135 YYPREFIX, yystate, yychar, yys);
1139 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1140 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1144 printf("%sdebug: state %d, shifting to state %d\n",
1145 YYPREFIX, yystate, yytable[yyn]);
1147 if (yyssp >= yysslim && yygrowstack())
1151 *++yyssp = yystate = yytable[yyn];
1154 if (yyerrflag > 0) --yyerrflag;
1157 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1158 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1163 if (yyerrflag) goto yyinrecovery;
1164 #if defined(lint) || defined(__GNUC__)
1168 yyerror("syntax error");
1169 #if defined(lint) || defined(__GNUC__)
1180 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1181 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1185 printf("%sdebug: state %d, error recovery shifting\
1186 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1188 if (yyssp >= yysslim && yygrowstack())
1192 *++yyssp = yystate = yytable[yyn];
1200 printf("%sdebug: error recovery discarding state %d\n",
1203 if (yyssp <= yyss) goto yyabort;
1211 if (yychar == 0) goto yyabort;
1216 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1217 if (!yys) yys = "illegal-symbol";
1218 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1219 YYPREFIX, yystate, yychar, yys);
1228 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1229 YYPREFIX, yystate, yyn, yyrule[yyn]);
1232 yyval = yyvsp[1-yym];
1236 #line 280 "parse.yacc"
1240 #line 282 "parse.yacc"
1244 #line 283 "parse.yacc"
1248 #line 283 "parse.yacc"
1250 while (top && user_matches != TRUE)
1255 #line 288 "parse.yacc"
1259 #line 290 "parse.yacc"
1263 #line 292 "parse.yacc"
1267 #line 294 "parse.yacc"
1271 #line 296 "parse.yacc"
1275 #line 302 "parse.yacc"
1277 defaults_matches = TRUE;
1281 #line 305 "parse.yacc"
1285 #line 305 "parse.yacc"
1287 defaults_matches = user_matches;
1292 #line 309 "parse.yacc"
1296 #line 309 "parse.yacc"
1298 defaults_matches = yyvsp[0].BOOLEAN == TRUE;
1303 #line 313 "parse.yacc"
1307 #line 313 "parse.yacc"
1309 defaults_matches = host_matches;
1314 #line 323 "parse.yacc"
1316 if (defaults_matches == TRUE &&
1317 !set_default(yyvsp[0].string, NULL, TRUE)) {
1321 efree(yyvsp[0].string);
1325 #line 331 "parse.yacc"
1327 if (defaults_matches == TRUE &&
1328 !set_default(yyvsp[0].string, NULL, FALSE)) {
1332 efree(yyvsp[0].string);
1336 #line 339 "parse.yacc"
1338 if (defaults_matches == TRUE &&
1339 !set_default(yyvsp[-2].string, yyvsp[0].string, TRUE)) {
1343 efree(yyvsp[-2].string);
1344 efree(yyvsp[0].string);
1348 #line 348 "parse.yacc"
1350 if (defaults_matches == TRUE &&
1351 !set_default(yyvsp[-2].string, yyvsp[0].string, '+')) {
1355 efree(yyvsp[-2].string);
1356 efree(yyvsp[0].string);
1360 #line 357 "parse.yacc"
1362 if (defaults_matches == TRUE &&
1363 !set_default(yyvsp[-2].string, yyvsp[0].string, '-')) {
1367 efree(yyvsp[-2].string);
1368 efree(yyvsp[0].string);
1372 #line 372 "parse.yacc"
1375 * We already did a push if necessary in
1376 * cmndspec so just reset some values so
1377 * the next 'privilege' gets a clean slate.
1379 host_matches = UNSPEC;
1380 runas_matches = UNSPEC;
1381 no_passwd = def_authenticate ? UNSPEC : TRUE;
1382 no_execve = def_noexec ? TRUE : UNSPEC;
1383 setenv_ok = def_setenv ? TRUE : UNSPEC;
1387 #line 386 "parse.yacc"
1389 SETMATCH(host_matches, yyvsp[0].BOOLEAN);
1393 #line 389 "parse.yacc"
1395 SETNMATCH(host_matches, yyvsp[0].BOOLEAN);
1399 #line 394 "parse.yacc"
1401 yyval.BOOLEAN = TRUE;
1405 #line 397 "parse.yacc"
1407 if (addr_matches(yyvsp[0].string))
1408 yyval.BOOLEAN = TRUE;
1410 yyval.BOOLEAN = NOMATCH;
1411 efree(yyvsp[0].string);
1415 #line 404 "parse.yacc"
1417 if (netgr_matches(yyvsp[0].string, user_host, user_shost, NULL))
1418 yyval.BOOLEAN = TRUE;
1420 yyval.BOOLEAN = NOMATCH;
1421 efree(yyvsp[0].string);
1425 #line 411 "parse.yacc"
1427 if (hostname_matches(user_shost, user_host, yyvsp[0].string) == 0)
1428 yyval.BOOLEAN = TRUE;
1430 yyval.BOOLEAN = NOMATCH;
1431 efree(yyvsp[0].string);
1435 #line 418 "parse.yacc"
1437 aliasinfo *aip = find_alias(yyvsp[0].string, HOST_ALIAS);
1439 /* could be an all-caps hostname */
1441 yyval.BOOLEAN = aip->val;
1442 else if (strcasecmp(user_shost, yyvsp[0].string) == 0)
1443 yyval.BOOLEAN = TRUE;
1446 (void) fprintf(stderr,
1447 "%s: undeclared Host_Alias `%s' referenced near line %d\n",
1448 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1454 yyval.BOOLEAN = NOMATCH;
1456 efree(yyvsp[0].string);
1460 #line 446 "parse.yacc"
1463 * Push the entry onto the stack if it is worth
1464 * saving and reset cmnd_matches for next cmnd.
1466 * We need to save at least one entry on
1467 * the stack so sudoers_lookup() can tell that
1468 * the user was listed in sudoers. Also, we
1469 * need to be able to tell whether or not a
1470 * user was listed for this specific host.
1472 * If keepall is set and the user matches then
1473 * we need to keep entries around too...
1475 if (MATCHED(user_matches) &&
1476 MATCHED(host_matches) &&
1477 MATCHED(cmnd_matches) &&
1478 MATCHED(runas_matches))
1480 else if (MATCHED(user_matches) && (top == 1 ||
1481 (top == 2 && MATCHED(host_matches) &&
1482 !MATCHED(match[0].host))))
1484 else if (user_matches == TRUE && keepall)
1486 cmnd_matches = UNSPEC;
1490 #line 475 "parse.yacc"
1492 SETMATCH(cmnd_matches, yyvsp[0].BOOLEAN);
1496 #line 478 "parse.yacc"
1498 if (printmatches == TRUE) {
1499 if (in_alias == TRUE)
1500 append_entries("!", ", ");
1501 else if (host_matches == TRUE &&
1502 user_matches == TRUE)
1503 append_cmnd("!", NULL);
1508 #line 486 "parse.yacc"
1510 SETNMATCH(cmnd_matches, yyvsp[0].BOOLEAN);
1514 #line 491 "parse.yacc"
1516 if (printmatches == TRUE && host_matches == TRUE &&
1517 user_matches == TRUE) {
1518 if (runas_matches == UNSPEC) {
1519 cm_list[cm_list_len].runas_len = 0;
1521 /* Inherit runas data. */
1522 cm_list[cm_list_len].runas =
1523 estrdup(cm_list[cm_list_len-1].runas);
1524 cm_list[cm_list_len].runas_len =
1525 cm_list[cm_list_len-1].runas_len;
1526 cm_list[cm_list_len].runas_size =
1527 cm_list[cm_list_len-1].runas_size;
1531 * If this is the first entry in a command list
1532 * then check against default runas user.
1534 if (runas_matches == UNSPEC) {
1536 userpw_matches(def_runas_default,
1537 *user_runas, runas_pw);
1542 #line 516 "parse.yacc"
1544 runas_matches = yyvsp[0].BOOLEAN;
1548 #line 521 "parse.yacc"
1552 #line 522 "parse.yacc"
1554 /* Later entries override earlier ones. */
1555 if (yyvsp[0].BOOLEAN != NOMATCH)
1556 yyval.BOOLEAN = yyvsp[0].BOOLEAN;
1558 yyval.BOOLEAN = yyvsp[-2].BOOLEAN;
1562 #line 531 "parse.yacc"
1566 #line 532 "parse.yacc"
1568 if (printmatches == TRUE) {
1569 if (in_alias == TRUE)
1570 append_entries("!", ", ");
1571 else if (host_matches == TRUE &&
1572 user_matches == TRUE)
1573 append_runas("!", ", ");
1578 #line 540 "parse.yacc"
1580 /* Set $$ to the negation of runasuser */
1581 yyval.BOOLEAN = (yyvsp[0].BOOLEAN == NOMATCH ? NOMATCH : ! yyvsp[0].BOOLEAN);
1585 #line 546 "parse.yacc"
1587 if (printmatches == TRUE) {
1588 if (in_alias == TRUE)
1589 append_entries(yyvsp[0].string, ", ");
1590 else if (host_matches == TRUE &&
1591 user_matches == TRUE)
1592 append_runas(yyvsp[0].string, ", ");
1594 if (userpw_matches(yyvsp[0].string, *user_runas, runas_pw))
1595 yyval.BOOLEAN = TRUE;
1597 yyval.BOOLEAN = NOMATCH;
1598 efree(yyvsp[0].string);
1603 #line 561 "parse.yacc"
1605 if (printmatches == TRUE) {
1606 if (in_alias == TRUE)
1607 append_entries(yyvsp[0].string, ", ");
1608 else if (host_matches == TRUE &&
1609 user_matches == TRUE)
1610 append_runas(yyvsp[0].string, ", ");
1612 if (usergr_matches(yyvsp[0].string, *user_runas, runas_pw))
1613 yyval.BOOLEAN = TRUE;
1615 yyval.BOOLEAN = NOMATCH;
1616 efree(yyvsp[0].string);
1621 #line 576 "parse.yacc"
1623 if (printmatches == TRUE) {
1624 if (in_alias == TRUE)
1625 append_entries(yyvsp[0].string, ", ");
1626 else if (host_matches == TRUE &&
1627 user_matches == TRUE)
1628 append_runas(yyvsp[0].string, ", ");
1630 if (netgr_matches(yyvsp[0].string, NULL, NULL, *user_runas))
1631 yyval.BOOLEAN = TRUE;
1633 yyval.BOOLEAN = NOMATCH;
1634 efree(yyvsp[0].string);
1639 #line 591 "parse.yacc"
1641 aliasinfo *aip = find_alias(yyvsp[0].string, RUNAS_ALIAS);
1643 if (printmatches == TRUE) {
1644 if (in_alias == TRUE)
1645 append_entries(yyvsp[0].string, ", ");
1646 else if (host_matches == TRUE &&
1647 user_matches == TRUE)
1648 append_runas(yyvsp[0].string, ", ");
1650 /* could be an all-caps username */
1652 yyval.BOOLEAN = aip->val;
1653 else if (strcmp(yyvsp[0].string, *user_runas) == 0)
1654 yyval.BOOLEAN = TRUE;
1657 (void) fprintf(stderr,
1658 "%s: undeclared Runas_Alias `%s' referenced near line %d\n",
1659 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1665 yyval.BOOLEAN = NOMATCH;
1667 efree(yyvsp[0].string);
1672 #line 621 "parse.yacc"
1674 if (printmatches == TRUE) {
1675 if (in_alias == TRUE)
1676 append_entries("ALL", ", ");
1677 else if (host_matches == TRUE &&
1678 user_matches == TRUE)
1679 append_runas("ALL", ", ");
1681 yyval.BOOLEAN = TRUE;
1685 #line 633 "parse.yacc"
1687 /* Inherit {NO,}{PASSWD,EXEC,SETENV} status. */
1688 if (printmatches == TRUE && host_matches == TRUE &&
1689 user_matches == TRUE) {
1690 if (no_passwd == TRUE)
1691 cm_list[cm_list_len].nopasswd = TRUE;
1693 cm_list[cm_list_len].nopasswd = FALSE;
1694 if (no_execve == TRUE)
1695 cm_list[cm_list_len].noexecve = TRUE;
1697 cm_list[cm_list_len].noexecve = FALSE;
1698 if (setenv_ok == TRUE)
1699 cm_list[cm_list_len].setenv = TRUE;
1701 cm_list[cm_list_len].setenv = FALSE;
1706 #line 651 "parse.yacc"
1709 if (printmatches == TRUE && host_matches == TRUE &&
1710 user_matches == TRUE)
1711 cm_list[cm_list_len].nopasswd = TRUE;
1715 #line 657 "parse.yacc"
1718 if (printmatches == TRUE && host_matches == TRUE &&
1719 user_matches == TRUE)
1720 cm_list[cm_list_len].nopasswd = FALSE;
1724 #line 663 "parse.yacc"
1727 if (printmatches == TRUE && host_matches == TRUE &&
1728 user_matches == TRUE)
1729 cm_list[cm_list_len].noexecve = TRUE;
1733 #line 669 "parse.yacc"
1736 if (printmatches == TRUE && host_matches == TRUE &&
1737 user_matches == TRUE)
1738 cm_list[cm_list_len].noexecve = FALSE;
1742 #line 675 "parse.yacc"
1745 if (printmatches == TRUE && host_matches == TRUE &&
1746 user_matches == TRUE)
1747 cm_list[cm_list_len].setenv = TRUE;
1751 #line 681 "parse.yacc"
1754 if (printmatches == TRUE && host_matches == TRUE &&
1755 user_matches == TRUE)
1756 cm_list[cm_list_len].setenv = FALSE;
1760 #line 689 "parse.yacc"
1762 if (printmatches == TRUE) {
1763 if (in_alias == TRUE)
1764 append_entries("ALL", ", ");
1765 else if (host_matches == TRUE &&
1766 user_matches == TRUE) {
1767 append_cmnd("ALL", NULL);
1768 expand_match_list();
1774 yyval.BOOLEAN = TRUE;
1778 #line 704 "parse.yacc"
1782 if (printmatches == TRUE) {
1783 if (in_alias == TRUE)
1784 append_entries(yyvsp[0].string, ", ");
1785 else if (host_matches == TRUE &&
1786 user_matches == TRUE) {
1787 append_cmnd(yyvsp[0].string, NULL);
1788 expand_match_list();
1792 if ((aip = find_alias(yyvsp[0].string, CMND_ALIAS)))
1793 yyval.BOOLEAN = aip->val;
1796 (void) fprintf(stderr,
1797 "%s: undeclared Cmnd_Alias `%s' referenced near line %d\n",
1798 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1804 yyval.BOOLEAN = NOMATCH;
1806 efree(yyvsp[0].string);
1810 #line 733 "parse.yacc"
1812 if (printmatches == TRUE) {
1813 if (in_alias == TRUE) {
1814 append_entries(yyvsp[0].command.cmnd, ", ");
1815 if (yyvsp[0].command.args)
1816 append_entries(yyvsp[0].command.args, " ");
1818 if (host_matches == TRUE &&
1819 user_matches == TRUE) {
1820 append_cmnd(yyvsp[0].command.cmnd, NULL);
1821 if (yyvsp[0].command.args)
1822 append_cmnd(yyvsp[0].command.args, " ");
1823 expand_match_list();
1827 if (command_matches(yyvsp[0].command.cmnd, yyvsp[0].command.args))
1828 yyval.BOOLEAN = TRUE;
1830 yyval.BOOLEAN = NOMATCH;
1832 efree(yyvsp[0].command.cmnd);
1833 efree(yyvsp[0].command.args);
1837 #line 763 "parse.yacc"
1841 #line 763 "parse.yacc"
1843 if ((MATCHED(host_matches) || pedantic) &&
1844 !add_alias(yyvsp[-3].string, HOST_ALIAS, host_matches)) {
1852 #line 781 "parse.yacc"
1855 if (printmatches == TRUE) {
1857 /* Allocate space for ga_list if necessary. */
1859 ga_list[ga_list_len-1].type = CMND_ALIAS;
1860 ga_list[ga_list_len-1].alias = estrdup(yyvsp[0].string);
1865 #line 790 "parse.yacc"
1867 if ((MATCHED(cmnd_matches) || pedantic) &&
1868 !add_alias(yyvsp[-3].string, CMND_ALIAS, cmnd_matches)) {
1873 efree(yyvsp[-3].string);
1875 if (printmatches == TRUE)
1880 #line 804 "parse.yacc"
1884 #line 812 "parse.yacc"
1886 if (printmatches == TRUE) {
1888 /* Allocate space for ga_list if necessary. */
1890 ga_list[ga_list_len-1].type = RUNAS_ALIAS;
1891 ga_list[ga_list_len-1].alias = estrdup(yyvsp[0].string);
1896 #line 820 "parse.yacc"
1898 if ((yyvsp[0].BOOLEAN != NOMATCH || pedantic) &&
1899 !add_alias(yyvsp[-3].string, RUNAS_ALIAS, yyvsp[0].BOOLEAN)) {
1903 efree(yyvsp[-3].string);
1905 if (printmatches == TRUE)
1910 #line 837 "parse.yacc"
1914 #line 837 "parse.yacc"
1916 if ((MATCHED(user_matches) || pedantic) &&
1917 !add_alias(yyvsp[-3].string, USER_ALIAS, user_matches)) {
1922 efree(yyvsp[-3].string);
1926 #line 852 "parse.yacc"
1928 SETMATCH(user_matches, yyvsp[0].BOOLEAN);
1932 #line 855 "parse.yacc"
1934 SETNMATCH(user_matches, yyvsp[0].BOOLEAN);
1938 #line 860 "parse.yacc"
1940 if (userpw_matches(yyvsp[0].string, user_name, sudo_user.pw))
1941 yyval.BOOLEAN = TRUE;
1943 yyval.BOOLEAN = NOMATCH;
1944 efree(yyvsp[0].string);
1948 #line 867 "parse.yacc"
1950 if (usergr_matches(yyvsp[0].string, user_name, sudo_user.pw))
1951 yyval.BOOLEAN = TRUE;
1953 yyval.BOOLEAN = NOMATCH;
1954 efree(yyvsp[0].string);
1958 #line 874 "parse.yacc"
1960 if (netgr_matches(yyvsp[0].string, NULL, NULL, user_name))
1961 yyval.BOOLEAN = TRUE;
1963 yyval.BOOLEAN = NOMATCH;
1964 efree(yyvsp[0].string);
1968 #line 881 "parse.yacc"
1970 aliasinfo *aip = find_alias(yyvsp[0].string, USER_ALIAS);
1972 /* could be an all-caps username */
1974 yyval.BOOLEAN = aip->val;
1975 else if (strcmp(yyvsp[0].string, user_name) == 0)
1976 yyval.BOOLEAN = TRUE;
1979 (void) fprintf(stderr,
1980 "%s: undeclared User_Alias `%s' referenced near line %d\n",
1981 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1987 yyval.BOOLEAN = NOMATCH;
1989 efree(yyvsp[0].string);
1993 #line 903 "parse.yacc"
1995 yyval.BOOLEAN = TRUE;
1998 #line 1947 "sudo.tab.c"
2004 if (yystate == 0 && yym == 0)
2008 printf("%sdebug: after reduction, shifting from state 0 to\
2009 state %d\n", YYPREFIX, YYFINAL);
2016 if ((yychar = yylex()) < 0) yychar = 0;
2021 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
2022 if (!yys) yys = "illegal-symbol";
2023 printf("%sdebug: state %d, reading %d (%s)\n",
2024 YYPREFIX, YYFINAL, yychar, yys);
2028 if (yychar == 0) goto yyaccept;
2031 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
2032 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
2033 yystate = yytable[yyn];
2035 yystate = yydgoto[yym];
2038 printf("%sdebug: after reduction, shifting from state %d \
2039 to state %d\n", YYPREFIX, *yyssp, yystate);
2041 if (yyssp >= yysslim && yygrowstack())
2049 yyerror("yacc stack overflow");
2055 yyss = yyssp = NULL;
2056 yyvs = yyvsp = NULL;
2064 yyss = yyssp = NULL;
2065 yyvs = yyvsp = NULL;