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.18 2001/11/19 19:02:18 mpech Exp $";
15 #define yyclearin (yychar=(YYEMPTY))
16 #define yyerrok (yyerrflag=0)
17 #define YYRECOVERING() (yyerrflag!=0)
21 * Copyright (c) 1996, 1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>
22 * All rights reserved.
24 * This code is derived from software contributed by Chris Jepeway.
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
37 * 3. The name of the author may not be used to endorse or promote products
38 * derived from this software without specific prior written permission.
40 * 4. Products derived from this software may not be called "Sudo" nor
41 * may "Sudo" appear in their names without specific prior written
42 * permission from the author.
44 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
45 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
46 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
47 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
48 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
50 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
52 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
53 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 * XXX - the whole opFOO naming thing is somewhat bogus.
59 * XXX - the way things are stored for printmatches is stupid,
60 * they should be stored as elements in an array and then
61 * list_matches() can format things the way it wants.
66 #include <sys/types.h>
67 #include <sys/param.h>
76 #endif /* STDC_HEADERS */
80 # ifdef HAVE_STRINGS_H
83 #endif /* HAVE_STRING_H */
86 #endif /* HAVE_UNISTD_H */
88 #if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
90 #endif /* HAVE_MALLOC_H && !STDC_HEADERS */
91 #if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
93 #endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */
96 #endif /* HAVE_LSEARCH */
102 #include "emul/search.h"
103 #endif /* HAVE_LSEARCH */
106 static const char rcsid[] = "$Sudo: sudo.tab.c,v 1.58 2002/03/16 00:45:48 millert Exp $";
112 extern int sudolineno, parse_error;
113 int errorlineno = -1;
114 int clearaliases = TRUE;
115 int printmatches = FALSE;
116 int pedantic = FALSE;
126 #define RUNAS_ALIAS 4
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 *) erealloc(match, sizeof(struct matchstack) * stacksize); \
140 match[top].user = -1; \
141 match[top].cmnd = -1; \
142 match[top].host = -1; \
143 match[top].runas = -1; \
144 match[top].nopass = def_flag(I_AUTHENTICATE) ? -1 : TRUE; \
150 if (top >= stacksize) { \
151 while ((stacksize += STACKINCREMENT) < top); \
152 match = (struct matchstack *) erealloc(match, sizeof(struct matchstack) * stacksize); \
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; \
165 yyerror("matching stack underflow"); \
171 * Shortcuts for append()
173 #define append_cmnd(s, p) append(s, &cm_list[cm_list_len].cmnd, \
174 &cm_list[cm_list_len].cmnd_len, &cm_list[cm_list_len].cmnd_size, p)
176 #define append_runas(s, p) append(s, &cm_list[cm_list_len].runas, \
177 &cm_list[cm_list_len].runas_len, &cm_list[cm_list_len].runas_size, p)
179 #define append_entries(s, p) append(s, &ga_list[ga_list_len-1].entries, \
180 &ga_list[ga_list_len-1].entries_len, \
181 &ga_list[ga_list_len-1].entries_size, p)
184 * The stack for printmatches. A list of allowed commands for the user.
186 static struct command_match *cm_list = NULL;
187 static size_t cm_list_len = 0, cm_list_size = 0;
190 * List of Cmnd_Aliases and expansions for `sudo -l'
192 static int in_alias = FALSE;
193 static size_t ga_list_len = 0, ga_list_size = 0;
194 static struct generic_alias *ga_list = NULL;
197 * Does this Defaults list pertain to this user?
199 static int defaults_matches = 0;
204 static int add_alias __P((char *, int, int));
205 static void append __P((char *, char **, size_t *, size_t *, char *));
206 static void expand_ga_list __P((void));
207 static void expand_match_list __P((void));
208 static aliasinfo *find_alias __P((char *, int));
209 static int more_aliases __P((void));
210 void init_parser __P((void));
211 void yyerror __P((char *));
217 /* Save the line the first error occurred on. */
218 if (errorlineno == -1)
219 errorlineno = sudolineno ? sudolineno - 1 : 0;
222 (void) fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s,
223 sudolineno ? sudolineno - 1 : 0);
225 (void) fprintf(stderr, "<*> ");
230 #line 214 "parse.yacc"
234 struct sudo_command command;
237 #line 238 "sudo.tab.c"
243 #define USERGROUP 262
246 #define DEFAULTS_HOST 265
247 #define DEFAULTS_USER 266
253 #define HOSTALIAS 272
254 #define CMNDALIAS 273
255 #define USERALIAS 274
256 #define RUNASALIAS 275
258 #define YYERRCODE 256
259 short yylhs[] = { -1,
260 0, 0, 7, 7, 9, 7, 7, 7, 7, 7,
261 7, 15, 16, 18, 16, 20, 16, 17, 17, 21,
262 21, 21, 21, 21, 10, 10, 22, 24, 24, 2,
263 2, 2, 2, 2, 23, 23, 25, 28, 29, 28,
264 26, 26, 5, 5, 4, 30, 4, 3, 3, 3,
265 3, 3, 27, 27, 27, 1, 1, 1, 12, 12,
266 32, 31, 19, 19, 13, 13, 34, 33, 35, 35,
267 14, 14, 37, 36, 11, 11, 39, 38, 8, 8,
268 40, 40, 6, 6, 6, 6, 6,
271 1, 2, 1, 2, 0, 3, 2, 2, 2, 2,
272 1, 2, 1, 0, 3, 0, 3, 1, 3, 1,
273 2, 3, 3, 3, 1, 3, 3, 1, 2, 1,
274 1, 1, 1, 1, 1, 3, 3, 1, 0, 3,
275 0, 2, 1, 3, 1, 0, 3, 1, 1, 1,
276 1, 1, 0, 1, 1, 1, 1, 1, 1, 3,
277 0, 4, 1, 3, 1, 3, 0, 4, 1, 3,
278 1, 3, 0, 4, 1, 3, 0, 4, 1, 3,
281 short yydefred[] = { 0,
282 0, 13, 16, 14, 3, 0, 0, 0, 0, 0,
283 1, 0, 11, 0, 4, 0, 0, 61, 0, 59,
284 67, 0, 65, 77, 0, 75, 73, 0, 71, 2,
285 86, 85, 84, 83, 87, 0, 81, 0, 79, 0,
286 0, 12, 0, 34, 31, 32, 33, 30, 0, 28,
287 0, 63, 0, 0, 0, 0, 0, 0, 0, 0,
288 0, 82, 0, 0, 0, 25, 0, 0, 0, 21,
289 0, 29, 0, 0, 60, 0, 66, 0, 76, 0,
290 72, 80, 0, 0, 22, 23, 24, 19, 64, 0,
291 58, 57, 56, 39, 38, 69, 0, 0, 51, 50,
292 49, 48, 52, 46, 45, 43, 0, 26, 0, 0,
293 35, 0, 0, 0, 0, 0, 0, 0, 54, 55,
294 0, 40, 70, 47, 44, 36, 37,
296 short yydgoto[] = { 10,
297 95, 50, 105, 106, 107, 37, 11, 38, 12, 64,
298 25, 19, 22, 28, 13, 14, 42, 17, 65, 16,
299 43, 66, 110, 52, 111, 112, 121, 96, 113, 115,
300 20, 54, 23, 56, 97, 29, 60, 26, 58, 39,
302 short yysindex[] = { -236,
303 -264, 0, 0, 0, 0, -249, -243, -231, -227, -236,
304 0, -23, 0, -30, 0, -17, -23, 0, -36, 0,
305 0, -26, 0, 0, -14, 0, 0, -7, 0, 0,
306 0, 0, 0, 0, 0, -215, 0, -33, 0, -3,
307 -226, 0, 5, 0, 0, 0, 0, 0, -194, 0,
308 6, 0, 8, -5, -249, -4, -243, -2, -231, -1,
309 -227, 0, -23, 7, -38, 0, -210, -193, -188, 0,
310 -30, 0, -17, -17, 0, -25, 0, -23, 0, 245,
311 0, 0, -17, -189, 0, 0, 0, 0, 0, 6,
312 0, 0, 0, 0, 0, 0, 33, 8, 0, 0,
313 0, 0, 0, 0, 0, 0, 38, 0, 245, 39,
314 0, -251, -244, -25, -190, 245, 38, -189, 0, 0,
315 -25, 0, 0, 0, 0, 0, 0,
317 short yyrindex[] = { 255,
318 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
319 0, 0, 0, 0, 0, 0, 0, 0, 121, 0,
320 0, 141, 0, 0, 161, 0, 0, 181, 0, 0,
321 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
322 0, 0, 201, 0, 0, 0, 0, 0, 0, 0,
323 -28, 0, -8, 0, 0, 0, 0, 0, 0, 0,
324 0, 0, 0, 221, 0, 0, 0, 0, 0, 0,
325 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
326 0, 0, 0, 265, 0, 0, 0, 0, 0, 21,
327 0, 0, 0, 0, 0, 0, 41, 61, 0, 0,
328 0, 0, 0, 0, 0, 0, 81, 0, 0, 101,
329 0, -9, 0, 0, 0, 0, 285, 265, 0, 0,
332 short yygindex[] = { 0,
333 -29, 36, -27, -24, -22, 50, 79, -15, 0, 0,
334 0, 0, 0, 0, 0, 0, 19, 0, -12, 0,
335 0, 10, 0, 18, -21, 0, 0, -102, 0, 0,
336 40, 0, 43, 0, 0, 35, 0, 44, 0, 42,
338 #define YYTABLESIZE 555
339 short yytable[] = { 49,
340 20, 53, 41, 51, 17, 73, 15, 94, 18, 36,
341 63, 123, 91, 92, 21, 49, 119, 120, 127, 1,
342 62, 55, 84, 53, 15, 93, 24, 2, 3, 4,
343 27, 57, 70, 20, 5, 6, 7, 8, 9, 68,
344 68, 69, 31, 59, 20, 32, 33, 34, 71, 73,
345 61, 63, 85, 62, 35, 74, 76, 67, 78, 80,
346 78, 90, 98, 44, 83, 45, 46, 99, 47, 86,
347 100, 101, 102, 68, 87, 48, 114, 109, 62, 103,
348 74, 116, 118, 122, 72, 62, 117, 124, 30, 88,
349 89, 125, 108, 78, 75, 81, 126, 0, 68, 77,
350 27, 0, 79, 0, 82, 0, 0, 0, 0, 0,
351 0, 0, 0, 74, 0, 0, 0, 0, 78, 0,
352 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
353 0, 0, 0, 27, 0, 0, 0, 0, 74, 0,
354 9, 0, 0, 0, 0, 0, 0, 0, 0, 0,
355 0, 0, 0, 8, 0, 0, 0, 0, 27, 0,
356 7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
357 0, 0, 0, 9, 0, 0, 0, 0, 0, 0,
358 10, 0, 0, 0, 0, 0, 0, 0, 0, 0,
359 0, 0, 0, 7, 0, 0, 0, 0, 0, 0,
360 18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
361 0, 0, 0, 10, 0, 0, 0, 0, 0, 0,
362 6, 0, 0, 0, 44, 0, 45, 46, 40, 47,
363 17, 91, 92, 18, 31, 0, 48, 32, 33, 34,
364 44, 0, 45, 46, 93, 47, 35, 53, 53, 0,
365 15, 0, 48, 6, 0, 0, 20, 0, 20, 0,
366 53, 20, 20, 20, 20, 20, 20, 0, 0, 0,
367 20, 20, 20, 20, 20, 20, 62, 104, 62, 0,
368 0, 62, 62, 62, 62, 62, 62, 5, 0, 0,
369 62, 62, 62, 62, 62, 62, 68, 41, 68, 0,
370 0, 68, 68, 68, 68, 68, 68, 0, 0, 0,
371 68, 68, 68, 68, 68, 68, 78, 42, 78, 0,
372 0, 78, 78, 78, 78, 78, 78, 0, 0, 0,
373 78, 78, 78, 78, 78, 78, 74, 0, 74, 0,
374 0, 74, 74, 74, 74, 74, 74, 0, 0, 0,
375 74, 74, 74, 74, 74, 74, 27, 0, 27, 0,
376 0, 27, 27, 27, 27, 27, 27, 0, 0, 0,
377 27, 27, 27, 27, 27, 27, 8, 0, 8, 0,
378 0, 8, 8, 8, 8, 8, 8, 0, 0, 0,
379 8, 8, 8, 8, 8, 8, 9, 0, 9, 0,
380 0, 9, 9, 9, 9, 9, 9, 0, 0, 0,
381 9, 9, 9, 9, 9, 9, 7, 0, 7, 0,
382 0, 7, 7, 7, 7, 7, 7, 0, 0, 0,
383 7, 7, 7, 7, 7, 7, 10, 0, 10, 0,
384 0, 10, 10, 10, 10, 10, 10, 0, 0, 0,
385 10, 10, 10, 10, 10, 10, 18, 0, 18, 0,
386 0, 18, 18, 18, 18, 18, 18, 0, 0, 0,
387 18, 18, 18, 18, 18, 18, 6, 0, 6, 0,
388 0, 6, 6, 6, 6, 6, 6, 0, 0, 0,
389 6, 6, 6, 6, 6, 6, 0, 0, 0, 0,
390 0, 0, 99, 0, 0, 100, 101, 102, 0, 0,
391 0, 0, 5, 0, 103, 5, 5, 5, 0, 0,
392 0, 41, 41, 0, 5, 0, 0, 0, 0, 0,
393 0, 0, 41, 41, 41, 0, 0, 0, 0, 0,
394 0, 42, 42, 0, 0, 0, 0, 0, 0, 0,
397 short yycheck[] = { 33,
398 0, 17, 33, 16, 33, 44, 271, 33, 258, 33,
399 44, 114, 257, 258, 258, 33, 268, 269, 121, 256,
400 0, 58, 61, 33, 33, 270, 258, 264, 265, 266,
401 258, 58, 259, 33, 271, 272, 273, 274, 275, 43,
402 0, 45, 258, 58, 44, 261, 262, 263, 44, 44,
403 58, 44, 263, 33, 270, 61, 61, 61, 61, 61,
404 0, 74, 78, 258, 58, 260, 261, 258, 263, 263,
405 261, 262, 263, 33, 263, 270, 44, 267, 58, 270,
406 0, 44, 44, 113, 49, 36, 109, 115, 10, 71,
407 73, 116, 83, 33, 55, 61, 118, -1, 58, 57,
408 0, -1, 59, -1, 63, -1, -1, -1, -1, -1,
409 -1, -1, -1, 33, -1, -1, -1, -1, 58, -1,
410 0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
411 -1, -1, -1, 33, -1, -1, -1, -1, 58, -1,
412 0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
413 -1, -1, -1, 33, -1, -1, -1, -1, 58, -1,
414 0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
415 -1, -1, -1, 33, -1, -1, -1, -1, -1, -1,
416 0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
417 -1, -1, -1, 33, -1, -1, -1, -1, -1, -1,
418 0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
419 -1, -1, -1, 33, -1, -1, -1, -1, -1, -1,
420 0, -1, -1, -1, 258, -1, 260, 261, 259, 263,
421 259, 257, 258, 33, 258, -1, 270, 261, 262, 263,
422 258, -1, 260, 261, 270, 263, 270, 257, 258, -1,
423 259, -1, 270, 33, -1, -1, 256, -1, 258, -1,
424 270, 261, 262, 263, 264, 265, 266, -1, -1, -1,
425 270, 271, 272, 273, 274, 275, 256, 33, 258, -1,
426 -1, 261, 262, 263, 264, 265, 266, 33, -1, -1,
427 270, 271, 272, 273, 274, 275, 256, 33, 258, -1,
428 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
429 270, 271, 272, 273, 274, 275, 256, 33, 258, -1,
430 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
431 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
432 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
433 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
434 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
435 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
436 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
437 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
438 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
439 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
440 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
441 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
442 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
443 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
444 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
445 270, 271, 272, 273, 274, 275, 256, -1, 258, -1,
446 -1, 261, 262, 263, 264, 265, 266, -1, -1, -1,
447 270, 271, 272, 273, 274, 275, -1, -1, -1, -1,
448 -1, -1, 258, -1, -1, 261, 262, 263, -1, -1,
449 -1, -1, 258, -1, 270, 261, 262, 263, -1, -1,
450 -1, 257, 258, -1, 270, -1, -1, -1, -1, -1,
451 -1, -1, 268, 269, 270, -1, -1, -1, -1, -1,
452 -1, 257, 258, -1, -1, -1, -1, -1, -1, -1,
453 -1, -1, 268, 269, 270,
459 #define YYMAXTOKEN 276
461 #if defined(__cplusplus) || __STDC__
462 const char * const yyname[] =
467 "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,
468 "'!'",0,0,0,0,0,0,0,0,0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,
469 "'='",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,
470 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,
471 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,
472 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,
473 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,
474 "COMMAND","ALIAS","DEFVAR","NTWKADDR","NETGROUP","USERGROUP","WORD","DEFAULTS",
475 "DEFAULTS_HOST","DEFAULTS_USER","RUNAS","NOPASSWD","PASSWD","ALL","COMMENT",
476 "HOSTALIAS","CMNDALIAS","USERALIAS","RUNASALIAS","ERROR",
478 #if defined(__cplusplus) || __STDC__
479 const char * const yyrule[] =
487 "entry : error COMMENT",
489 "entry : $$1 userlist privileges",
490 "entry : USERALIAS useraliases",
491 "entry : HOSTALIAS hostaliases",
492 "entry : CMNDALIAS cmndaliases",
493 "entry : RUNASALIAS runasaliases",
494 "entry : defaults_line",
495 "defaults_line : defaults_type defaults_list",
496 "defaults_type : DEFAULTS",
498 "defaults_type : DEFAULTS_USER $$2 userlist",
500 "defaults_type : DEFAULTS_HOST $$3 hostlist",
501 "defaults_list : defaults_entry",
502 "defaults_list : defaults_entry ',' defaults_list",
503 "defaults_entry : DEFVAR",
504 "defaults_entry : '!' DEFVAR",
505 "defaults_entry : DEFVAR '=' WORD",
506 "defaults_entry : DEFVAR '+' WORD",
507 "defaults_entry : DEFVAR '-' WORD",
508 "privileges : privilege",
509 "privileges : privileges ':' privilege",
510 "privilege : hostlist '=' cmndspeclist",
518 "cmndspeclist : cmndspec",
519 "cmndspeclist : cmndspeclist ',' cmndspec",
520 "cmndspec : runasspec nopasswd opcmnd",
523 "opcmnd : '!' $$4 cmnd",
525 "runasspec : RUNAS runaslist",
526 "runaslist : oprunasuser",
527 "runaslist : runaslist ',' oprunasuser",
528 "oprunasuser : runasuser",
530 "oprunasuser : '!' $$5 runasuser",
532 "runasuser : USERGROUP",
533 "runasuser : NETGROUP",
537 "nopasswd : NOPASSWD",
542 "hostaliases : hostalias",
543 "hostaliases : hostaliases ':' hostalias",
545 "hostalias : ALIAS $$6 '=' hostlist",
547 "hostlist : hostlist ',' ophost",
548 "cmndaliases : cmndalias",
549 "cmndaliases : cmndaliases ':' cmndalias",
551 "cmndalias : ALIAS $$7 '=' cmndlist",
553 "cmndlist : cmndlist ',' opcmnd",
554 "runasaliases : runasalias",
555 "runasaliases : runasaliases ':' runasalias",
557 "runasalias : ALIAS $$8 '=' runaslist",
558 "useraliases : useralias",
559 "useraliases : useraliases ':' useralias",
561 "useralias : ALIAS $$9 '=' userlist",
563 "userlist : userlist ',' opuser",
575 #define YYMAXDEPTH YYSTACKSIZE
578 #define YYSTACKSIZE YYMAXDEPTH
580 #define YYSTACKSIZE 10000
581 #define YYMAXDEPTH 10000
584 #define YYINITSTACKSIZE 200
597 #line 844 "parse.yacc"
599 #define MOREALIASES (32)
600 aliasinfo *aliases = NULL;
606 * Compare two aliasinfo structures, strcmp() style.
607 * Note that we do *not* compare their values.
614 aliasinfo *ai1, *ai2;
616 ai1 = (aliasinfo *) a1;
617 ai2 = (aliasinfo *) a2;
618 if ((r = strcmp(ai1->name, ai2->name)) == 0)
619 r = ai1->type - ai2->type;
625 * Compare two generic_alias structures, strcmp() style.
628 genaliascmp(entry, key)
629 const VOID *entry, *key;
632 struct generic_alias *ga1, *ga2;
634 ga1 = (struct generic_alias *) key;
635 ga2 = (struct generic_alias *) entry;
636 if ((r = strcmp(ga1->alias, ga2->alias)) == 0)
637 r = ga1->type - ga2->type;
644 * Adds the named alias of the specified type to the aliases list.
647 add_alias(alias, type, val)
656 if (naliases >= nslots && !more_aliases()) {
657 (void) snprintf(s, sizeof(s), "Out of memory defining alias `%s'",
665 ai.name = estrdup(alias);
666 onaliases = naliases;
668 aip = (aliasinfo *) lsearch((VOID *)&ai, (VOID *)aliases, &naliases,
669 sizeof(ai), aliascmp);
671 (void) snprintf(s, sizeof(s), "Aliases corrupted defining alias `%s'",
676 if (onaliases == naliases) {
677 (void) snprintf(s, sizeof(s), "Alias `%s' already defined", alias);
686 * Searches for the named alias of the specified type.
689 find_alias(alias, type)
698 return((aliasinfo *) lfind((VOID *)&ai, (VOID *)aliases, &naliases,
699 sizeof(ai), aliascmp));
703 * Allocates more space for the aliases list.
709 nslots += MOREALIASES;
710 if (nslots == MOREALIASES)
711 aliases = (aliasinfo *) malloc(nslots * sizeof(aliasinfo));
713 aliases = (aliasinfo *) realloc(aliases, nslots * sizeof(aliasinfo));
715 return(aliases != NULL);
719 * Lists the contents of the aliases list.
726 for (n = 0; n < naliases; n++) {
727 if (aliases[n].val == -1)
730 switch (aliases[n].type) {
732 (void) puts("HOST_ALIAS");
736 (void) puts("CMND_ALIAS");
740 (void) puts("USER_ALIAS");
744 (void) puts("RUNAS_ALIAS");
747 (void) printf("\t%s: %d\n", aliases[n].name, aliases[n].val);
752 * Lists the contents of cm_list and ga_list for `sudo -l'.
759 struct generic_alias *ga, key;
761 (void) printf("User %s may run the following commands on this host:\n",
763 for (i = 0; i < cm_list_len; i++) {
765 /* Print the runas list. */
766 (void) fputs(" ", stdout);
767 if (cm_list[i].runas) {
769 p = strtok(cm_list[i].runas, ", ");
771 if (p != cm_list[i].runas)
772 (void) fputs(", ", stdout);
775 key.type = RUNAS_ALIAS;
776 if ((ga = (struct generic_alias *) lfind((VOID *) &key,
777 (VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp)))
778 (void) fputs(ga->entries, stdout);
780 (void) fputs(p, stdout);
781 } while ((p = strtok(NULL, ", ")));
782 (void) fputs(") ", stdout);
784 (void) printf("(%s) ", def_str(I_RUNAS_DEFAULT));
787 /* Is a password required? */
788 if (cm_list[i].nopasswd == TRUE && def_flag(I_AUTHENTICATE))
789 (void) fputs("NOPASSWD: ", stdout);
790 else if (cm_list[i].nopasswd == FALSE && !def_flag(I_AUTHENTICATE))
791 (void) fputs("PASSWD: ", stdout);
793 /* Print the actual command or expanded Cmnd_Alias. */
794 key.alias = cm_list[i].cmnd;
795 key.type = CMND_ALIAS;
796 if ((ga = (struct generic_alias *) lfind((VOID *) &key,
797 (VOID *) &ga_list[0], &ga_list_len, sizeof(key), genaliascmp)))
798 (void) puts(ga->entries);
800 (void) puts(cm_list[i].cmnd);
803 /* Be nice and free up space now that we are done. */
804 for (i = 0; i < ga_list_len; i++) {
805 free(ga_list[i].alias);
806 free(ga_list[i].entries);
811 for (i = 0; i < cm_list_len; i++) {
812 free(cm_list[i].runas);
813 free(cm_list[i].cmnd);
822 * Appends a source string to the destination, optionally prefixing a separator.
825 append(src, dstp, dst_len, dst_size, separator)
827 size_t *dst_len, *dst_size;
830 size_t src_len = strlen(src);
834 * Only add the separator if there is something to separate from.
835 * If the last char is a '!', don't apply the separator (XXX).
837 if (separator && dst && dst[*dst_len - 1] != '!')
838 src_len += strlen(separator);
842 /* Assumes dst will be NULL if not set. */
844 dst = (char *) emalloc(BUFSIZ);
850 /* Allocate more space if necessary. */
851 if (*dst_size <= *dst_len + src_len) {
852 while (*dst_size <= *dst_len + src_len)
855 dst = (char *) erealloc(dst, *dst_size);
859 /* Copy src -> dst adding a separator if appropriate and adjust len. */
864 (void) strcat(dst, separator);
865 (void) strcat(dst, src);
869 * Frees up space used by the aliases list and resets the associated counters.
877 for (n = 0; n < naliases; n++)
878 free(aliases[n].name);
882 naliases = nslots = 0;
886 * Increments ga_list_len, allocating more space as necessary.
892 if (++ga_list_len >= ga_list_size) {
893 while ((ga_list_size += STACKINCREMENT) < ga_list_len)
895 ga_list = (struct generic_alias *)
896 erealloc(ga_list, sizeof(struct generic_alias) * ga_list_size);
899 ga_list[ga_list_len - 1].entries = NULL;
903 * Increments cm_list_len, allocating more space as necessary.
909 if (++cm_list_len >= cm_list_size) {
910 while ((cm_list_size += STACKINCREMENT) < cm_list_len)
913 cm_list_len = 0; /* start at 0 since it is a subscript */
914 cm_list = (struct command_match *)
915 erealloc(cm_list, sizeof(struct command_match) * cm_list_size);
918 cm_list[cm_list_len].runas = cm_list[cm_list_len].cmnd = NULL;
919 cm_list[cm_list_len].nopasswd = FALSE;
923 * Frees up spaced used by a previous parser run and allocates new space
924 * for various data structures.
930 /* Free up old data structures if we run the parser more than once. */
940 /* Allocate space for the matching stack. */
941 stacksize = STACKINCREMENT;
942 match = (struct matchstack *) emalloc(sizeof(struct matchstack) * stacksize);
944 /* Allocate space for the match list (for `sudo -l'). */
945 if (printmatches == TRUE)
948 #line 940 "sudo.tab.c"
949 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
950 #if defined(__cplusplus) || __STDC__
951 static int yygrowstack(void)
953 static int yygrowstack()
960 if ((newsize = yystacksize) == 0)
961 newsize = YYINITSTACKSIZE;
962 else if (newsize >= YYMAXDEPTH)
964 else if ((newsize *= 2) > YYMAXDEPTH)
965 newsize = YYMAXDEPTH;
967 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
968 (short *)malloc(newsize * sizeof *newss);
973 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
974 (YYSTYPE *)malloc(newsize * sizeof *newvs);
979 yystacksize = newsize;
980 yysslim = yyss + newsize - 1;
993 #define YYABORT goto yyabort
994 #define YYREJECT goto yyabort
995 #define YYACCEPT goto yyaccept
996 #define YYERROR goto yyerrlab
998 #if defined(__cplusplus) || __STDC__
1004 int yym, yyn, yystate;
1006 #if defined(__cplusplus) || __STDC__
1008 #else /* !(defined(__cplusplus) || __STDC__) */
1010 #endif /* !(defined(__cplusplus) || __STDC__) */
1012 if ((yys = getenv("YYDEBUG")))
1015 if (yyn >= '0' && yyn <= '9')
1016 yydebug = yyn - '0';
1018 #endif /* YYDEBUG */
1024 if (yyss == NULL && yygrowstack()) goto yyoverflow;
1027 *yyssp = yystate = 0;
1030 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1033 if ((yychar = yylex()) < 0) yychar = 0;
1038 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1039 if (!yys) yys = "illegal-symbol";
1040 printf("%sdebug: state %d, reading %d (%s)\n",
1041 YYPREFIX, yystate, yychar, yys);
1045 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1046 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1050 printf("%sdebug: state %d, shifting to state %d\n",
1051 YYPREFIX, yystate, yytable[yyn]);
1053 if (yyssp >= yysslim && yygrowstack())
1057 *++yyssp = yystate = yytable[yyn];
1060 if (yyerrflag > 0) --yyerrflag;
1063 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1064 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1069 if (yyerrflag) goto yyinrecovery;
1070 #if defined(lint) || defined(__GNUC__)
1074 yyerror("syntax error");
1075 #if defined(lint) || defined(__GNUC__)
1086 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1087 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1091 printf("%sdebug: state %d, error recovery shifting\
1092 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1094 if (yyssp >= yysslim && yygrowstack())
1098 *++yyssp = yystate = yytable[yyn];
1106 printf("%sdebug: error recovery discarding state %d\n",
1109 if (yyssp <= yyss) goto yyabort;
1117 if (yychar == 0) goto yyabort;
1122 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1123 if (!yys) yys = "illegal-symbol";
1124 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1125 YYPREFIX, yystate, yychar, yys);
1134 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1135 YYPREFIX, yystate, yyn, yyrule[yyn]);
1138 yyval = yyvsp[1-yym];
1142 #line 264 "parse.yacc"
1146 #line 266 "parse.yacc"
1150 #line 267 "parse.yacc"
1154 #line 267 "parse.yacc"
1156 while (top && user_matches != TRUE)
1161 #line 272 "parse.yacc"
1165 #line 274 "parse.yacc"
1169 #line 276 "parse.yacc"
1173 #line 278 "parse.yacc"
1177 #line 280 "parse.yacc"
1181 #line 285 "parse.yacc"
1183 defaults_matches = TRUE;
1187 #line 288 "parse.yacc"
1191 #line 288 "parse.yacc"
1193 defaults_matches = user_matches;
1198 #line 292 "parse.yacc"
1202 #line 292 "parse.yacc"
1204 defaults_matches = host_matches;
1209 #line 301 "parse.yacc"
1211 if (defaults_matches == TRUE &&
1212 !set_default(yyvsp[0].string, NULL, TRUE)) {
1216 free(yyvsp[0].string);
1220 #line 309 "parse.yacc"
1222 if (defaults_matches == TRUE &&
1223 !set_default(yyvsp[0].string, NULL, FALSE)) {
1227 free(yyvsp[0].string);
1231 #line 317 "parse.yacc"
1233 if (defaults_matches == TRUE &&
1234 !set_default(yyvsp[-2].string, yyvsp[0].string, TRUE)) {
1238 free(yyvsp[-2].string);
1239 free(yyvsp[0].string);
1243 #line 326 "parse.yacc"
1245 if (defaults_matches == TRUE &&
1246 !set_default(yyvsp[-2].string, yyvsp[0].string, '+')) {
1250 free(yyvsp[-2].string);
1251 free(yyvsp[0].string);
1255 #line 335 "parse.yacc"
1257 if (defaults_matches == TRUE &&
1258 !set_default(yyvsp[-2].string, yyvsp[0].string, '-')) {
1262 free(yyvsp[-2].string);
1263 free(yyvsp[0].string);
1267 #line 349 "parse.yacc"
1270 * We already did a push if necessary in
1271 * cmndspec so just reset some values so
1272 * the next 'privilege' gets a clean slate.
1276 if (def_flag(I_AUTHENTICATE))
1283 #line 364 "parse.yacc"
1285 if (yyvsp[0].BOOLEAN != -1)
1286 host_matches = yyvsp[0].BOOLEAN;
1290 #line 368 "parse.yacc"
1292 if (yyvsp[0].BOOLEAN != -1)
1293 host_matches = ! yyvsp[0].BOOLEAN;
1297 #line 373 "parse.yacc"
1299 yyval.BOOLEAN = TRUE;
1303 #line 376 "parse.yacc"
1305 if (addr_matches(yyvsp[0].string))
1306 yyval.BOOLEAN = TRUE;
1309 free(yyvsp[0].string);
1313 #line 383 "parse.yacc"
1315 if (netgr_matches(yyvsp[0].string, user_host, user_shost, NULL))
1316 yyval.BOOLEAN = TRUE;
1319 free(yyvsp[0].string);
1323 #line 390 "parse.yacc"
1325 if (hostname_matches(user_shost, user_host, yyvsp[0].string) == 0)
1326 yyval.BOOLEAN = TRUE;
1329 free(yyvsp[0].string);
1333 #line 397 "parse.yacc"
1335 aliasinfo *aip = find_alias(yyvsp[0].string, HOST_ALIAS);
1337 /* could be an all-caps hostname */
1339 yyval.BOOLEAN = aip->val;
1340 else if (strcasecmp(user_shost, yyvsp[0].string) == 0)
1341 yyval.BOOLEAN = TRUE;
1344 (void) fprintf(stderr,
1345 "%s: undeclared Host_Alias `%s' referenced near line %d\n",
1346 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1354 free(yyvsp[0].string);
1358 #line 425 "parse.yacc"
1361 * Push the entry onto the stack if it is worth
1362 * saving and clear cmnd_matches for next cmnd.
1364 * We need to save at least one entry on
1365 * the stack so sudoers_lookup() can tell that
1366 * the user was listed in sudoers. Also, we
1367 * need to be able to tell whether or not a
1368 * user was listed for this specific host.
1370 * If keepall is set and the user matches then
1371 * we need to keep entries around too...
1373 if (user_matches != -1 && host_matches != -1 &&
1374 cmnd_matches != -1 && runas_matches != -1)
1376 else if (user_matches != -1 && (top == 1 ||
1377 (top == 2 && host_matches != -1 &&
1378 match[0].host == -1)))
1380 else if (user_matches == TRUE && keepall)
1386 #line 452 "parse.yacc"
1388 if (yyvsp[0].BOOLEAN != -1)
1389 cmnd_matches = yyvsp[0].BOOLEAN;
1393 #line 456 "parse.yacc"
1395 if (printmatches == TRUE) {
1396 if (in_alias == TRUE)
1397 append_entries("!", ", ");
1398 else if (host_matches == TRUE &&
1399 user_matches == TRUE)
1400 append_cmnd("!", NULL);
1405 #line 464 "parse.yacc"
1407 if (yyvsp[0].BOOLEAN != -1)
1408 cmnd_matches = ! yyvsp[0].BOOLEAN;
1412 #line 470 "parse.yacc"
1414 if (printmatches == TRUE && host_matches == TRUE &&
1415 user_matches == TRUE) {
1416 if (runas_matches == -1) {
1417 cm_list[cm_list_len].runas_len = 0;
1419 /* Inherit runas data. */
1420 cm_list[cm_list_len].runas =
1421 estrdup(cm_list[cm_list_len-1].runas);
1422 cm_list[cm_list_len].runas_len =
1423 cm_list[cm_list_len-1].runas_len;
1424 cm_list[cm_list_len].runas_size =
1425 cm_list[cm_list_len-1].runas_size;
1429 * If this is the first entry in a command list
1430 * then check against default runas user.
1432 if (runas_matches == -1)
1433 runas_matches = (strcmp(*user_runas,
1434 def_str(I_RUNAS_DEFAULT)) == 0);
1438 #line 493 "parse.yacc"
1440 runas_matches = (yyvsp[0].BOOLEAN == TRUE ? TRUE : FALSE);
1444 #line 498 "parse.yacc"
1448 #line 499 "parse.yacc"
1450 /* Later entries override earlier ones. */
1451 if (yyvsp[0].BOOLEAN != -1)
1452 yyval.BOOLEAN = yyvsp[0].BOOLEAN;
1454 yyval.BOOLEAN = yyvsp[-2].BOOLEAN;
1458 #line 508 "parse.yacc"
1462 #line 509 "parse.yacc"
1464 if (printmatches == TRUE) {
1465 if (in_alias == TRUE)
1466 append_entries("!", ", ");
1467 else if (host_matches == TRUE &&
1468 user_matches == TRUE)
1469 append_runas("!", ", ");
1474 #line 517 "parse.yacc"
1476 /* Set $$ to the negation of runasuser */
1477 yyval.BOOLEAN = (yyvsp[0].BOOLEAN == -1 ? -1 : ! yyvsp[0].BOOLEAN);
1481 #line 522 "parse.yacc"
1483 if (printmatches == TRUE) {
1484 if (in_alias == TRUE)
1485 append_entries(yyvsp[0].string, ", ");
1486 else if (host_matches == TRUE &&
1487 user_matches == TRUE)
1488 append_runas(yyvsp[0].string, ", ");
1490 if (strcmp(yyvsp[0].string, *user_runas) == 0)
1491 yyval.BOOLEAN = TRUE;
1494 free(yyvsp[0].string);
1498 #line 536 "parse.yacc"
1500 if (printmatches == TRUE) {
1501 if (in_alias == TRUE)
1502 append_entries(yyvsp[0].string, ", ");
1503 else if (host_matches == TRUE &&
1504 user_matches == TRUE)
1505 append_runas(yyvsp[0].string, ", ");
1507 if (usergr_matches(yyvsp[0].string, *user_runas))
1508 yyval.BOOLEAN = TRUE;
1511 free(yyvsp[0].string);
1515 #line 550 "parse.yacc"
1517 if (printmatches == TRUE) {
1518 if (in_alias == TRUE)
1519 append_entries(yyvsp[0].string, ", ");
1520 else if (host_matches == TRUE &&
1521 user_matches == TRUE)
1522 append_runas(yyvsp[0].string, ", ");
1524 if (netgr_matches(yyvsp[0].string, NULL, NULL, *user_runas))
1525 yyval.BOOLEAN = TRUE;
1528 free(yyvsp[0].string);
1532 #line 564 "parse.yacc"
1534 aliasinfo *aip = find_alias(yyvsp[0].string, RUNAS_ALIAS);
1536 if (printmatches == TRUE) {
1537 if (in_alias == TRUE)
1538 append_entries(yyvsp[0].string, ", ");
1539 else if (host_matches == TRUE &&
1540 user_matches == TRUE)
1541 append_runas(yyvsp[0].string, ", ");
1543 /* could be an all-caps username */
1545 yyval.BOOLEAN = aip->val;
1546 else if (strcmp(yyvsp[0].string, *user_runas) == 0)
1547 yyval.BOOLEAN = TRUE;
1550 (void) fprintf(stderr,
1551 "%s: undeclared Runas_Alias `%s' referenced near line %d\n",
1552 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1560 free(yyvsp[0].string);
1564 #line 593 "parse.yacc"
1566 if (printmatches == TRUE) {
1567 if (in_alias == TRUE)
1568 append_entries("ALL", ", ");
1569 else if (host_matches == TRUE &&
1570 user_matches == TRUE)
1571 append_runas("ALL", ", ");
1573 yyval.BOOLEAN = TRUE;
1577 #line 605 "parse.yacc"
1579 /* Inherit NOPASSWD/PASSWD status. */
1580 if (printmatches == TRUE && host_matches == TRUE &&
1581 user_matches == TRUE) {
1582 if (no_passwd == TRUE)
1583 cm_list[cm_list_len].nopasswd = TRUE;
1585 cm_list[cm_list_len].nopasswd = FALSE;
1590 #line 615 "parse.yacc"
1593 if (printmatches == TRUE && host_matches == TRUE &&
1594 user_matches == TRUE)
1595 cm_list[cm_list_len].nopasswd = TRUE;
1599 #line 621 "parse.yacc"
1602 if (printmatches == TRUE && host_matches == TRUE &&
1603 user_matches == TRUE)
1604 cm_list[cm_list_len].nopasswd = FALSE;
1608 #line 629 "parse.yacc"
1610 if (printmatches == TRUE) {
1611 if (in_alias == TRUE)
1612 append_entries("ALL", ", ");
1613 else if (host_matches == TRUE &&
1614 user_matches == TRUE) {
1615 append_cmnd("ALL", NULL);
1616 expand_match_list();
1620 yyval.BOOLEAN = TRUE;
1624 safe_cmnd = estrdup(user_cmnd);
1628 #line 646 "parse.yacc"
1632 if (printmatches == TRUE) {
1633 if (in_alias == TRUE)
1634 append_entries(yyvsp[0].string, ", ");
1635 else if (host_matches == TRUE &&
1636 user_matches == TRUE) {
1637 append_cmnd(yyvsp[0].string, NULL);
1638 expand_match_list();
1642 if ((aip = find_alias(yyvsp[0].string, CMND_ALIAS)))
1643 yyval.BOOLEAN = aip->val;
1646 (void) fprintf(stderr,
1647 "%s: undeclared Cmnd_Alias `%s' referenced near line %d\n",
1648 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1656 free(yyvsp[0].string);
1660 #line 675 "parse.yacc"
1662 if (printmatches == TRUE) {
1663 if (in_alias == TRUE) {
1664 append_entries(yyvsp[0].command.cmnd, ", ");
1665 if (yyvsp[0].command.args)
1666 append_entries(yyvsp[0].command.args, " ");
1668 if (host_matches == TRUE &&
1669 user_matches == TRUE) {
1670 append_cmnd(yyvsp[0].command.cmnd, NULL);
1671 if (yyvsp[0].command.args)
1672 append_cmnd(yyvsp[0].command.args, " ");
1673 expand_match_list();
1677 if (command_matches(user_cmnd, user_args,
1678 yyvsp[0].command.cmnd, yyvsp[0].command.args))
1679 yyval.BOOLEAN = TRUE;
1683 free(yyvsp[0].command.cmnd);
1684 if (yyvsp[0].command.args)
1685 free(yyvsp[0].command.args);
1689 #line 707 "parse.yacc"
1693 #line 707 "parse.yacc"
1695 if ((host_matches != -1 || pedantic) &&
1696 !add_alias(yyvsp[-3].string, HOST_ALIAS, host_matches))
1702 #line 723 "parse.yacc"
1705 if (printmatches == TRUE) {
1707 /* Allocate space for ga_list if necessary. */
1709 ga_list[ga_list_len-1].type = CMND_ALIAS;
1710 ga_list[ga_list_len-1].alias = estrdup(yyvsp[0].string);
1715 #line 732 "parse.yacc"
1717 if ((cmnd_matches != -1 || pedantic) &&
1718 !add_alias(yyvsp[-3].string, CMND_ALIAS, cmnd_matches))
1721 free(yyvsp[-3].string);
1723 if (printmatches == TRUE)
1728 #line 744 "parse.yacc"
1732 #line 752 "parse.yacc"
1734 if (printmatches == TRUE) {
1736 /* Allocate space for ga_list if necessary. */
1738 ga_list[ga_list_len-1].type = RUNAS_ALIAS;
1739 ga_list[ga_list_len-1].alias = estrdup(yyvsp[0].string);
1744 #line 760 "parse.yacc"
1746 if ((yyvsp[0].BOOLEAN != -1 || pedantic) &&
1747 !add_alias(yyvsp[-3].string, RUNAS_ALIAS, yyvsp[0].BOOLEAN))
1749 free(yyvsp[-3].string);
1751 if (printmatches == TRUE)
1756 #line 775 "parse.yacc"
1760 #line 775 "parse.yacc"
1762 if ((user_matches != -1 || pedantic) &&
1763 !add_alias(yyvsp[-3].string, USER_ALIAS, user_matches))
1766 free(yyvsp[-3].string);
1770 #line 788 "parse.yacc"
1772 if (yyvsp[0].BOOLEAN != -1)
1773 user_matches = yyvsp[0].BOOLEAN;
1777 #line 792 "parse.yacc"
1779 if (yyvsp[0].BOOLEAN != -1)
1780 user_matches = ! yyvsp[0].BOOLEAN;
1784 #line 797 "parse.yacc"
1786 if (strcmp(yyvsp[0].string, user_name) == 0)
1787 yyval.BOOLEAN = TRUE;
1790 free(yyvsp[0].string);
1794 #line 804 "parse.yacc"
1796 if (usergr_matches(yyvsp[0].string, user_name))
1797 yyval.BOOLEAN = TRUE;
1800 free(yyvsp[0].string);
1804 #line 811 "parse.yacc"
1806 if (netgr_matches(yyvsp[0].string, NULL, NULL, user_name))
1807 yyval.BOOLEAN = TRUE;
1810 free(yyvsp[0].string);
1814 #line 818 "parse.yacc"
1816 aliasinfo *aip = find_alias(yyvsp[0].string, USER_ALIAS);
1818 /* could be an all-caps username */
1820 yyval.BOOLEAN = aip->val;
1821 else if (strcmp(yyvsp[0].string, user_name) == 0)
1822 yyval.BOOLEAN = TRUE;
1825 (void) fprintf(stderr,
1826 "%s: undeclared User_Alias `%s' referenced near line %d\n",
1827 (pedantic == 1) ? "Warning" : "Error", yyvsp[0].string, sudolineno);
1833 free(yyvsp[0].string);
1837 #line 838 "parse.yacc"
1839 yyval.BOOLEAN = TRUE;
1842 #line 1834 "sudo.tab.c"
1848 if (yystate == 0 && yym == 0)
1852 printf("%sdebug: after reduction, shifting from state 0 to\
1853 state %d\n", YYPREFIX, YYFINAL);
1860 if ((yychar = yylex()) < 0) yychar = 0;
1865 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1866 if (!yys) yys = "illegal-symbol";
1867 printf("%sdebug: state %d, reading %d (%s)\n",
1868 YYPREFIX, YYFINAL, yychar, yys);
1872 if (yychar == 0) goto yyaccept;
1875 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1876 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1877 yystate = yytable[yyn];
1879 yystate = yydgoto[yym];
1882 printf("%sdebug: after reduction, shifting from state %d \
1883 to state %d\n", YYPREFIX, *yyssp, yystate);
1885 if (yyssp >= yysslim && yygrowstack())
1893 yyerror("yacc stack overflow");