1#include <config.h> 2#include <stdlib.h> 3#include <string.h> 4#define YYBYACC 1 5#define YYMAJOR 1 6#define YYMINOR 9 7#define YYLEX yylex() 8#define YYEMPTY -1 9#define yyclearin (yychar=(YYEMPTY)) 10#define yyerrok (yyerrflag=0) 11#define YYRECOVERING() (yyerrflag!=0) 12#define YYPREFIX "yy" 13#line 2 "gram.y" 14/* 15 * Copyright (c) 1996, 1998-2005, 2007-2010 16 * Todd C. Miller <Todd.Miller@courtesan.com> 17 * 18 * Permission to use, copy, modify, and distribute this software for any 19 * purpose with or without fee is hereby granted, provided that the above 20 * copyright notice and this permission notice appear in all copies. 21 * 22 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 23 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 24 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 25 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 27 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 28 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * Sponsored in part by the Defense Advanced Research Projects 33 * Agency (DARPA) and Air Force Research Laboratory, Air Force 34 * Materiel Command, USAF, under agreement number F39502-99-1-0512. 35 */ 36 37#include <config.h> 38 39#include <sys/types.h> 40#include <sys/param.h> 41#include <stdio.h> 42#ifdef STDC_HEADERS 43# include <stdlib.h> 44# include <stddef.h> 45#else 46# ifdef HAVE_STDLIB_H 47# include <stdlib.h> 48# endif 49#endif /* STDC_HEADERS */ 50#ifdef HAVE_STRING_H 51# include <string.h> 52#endif /* HAVE_STRING_H */ 53#ifdef HAVE_STRINGS_H 54# include <strings.h> 55#endif /* HAVE_STRINGS_H */ 56#ifdef HAVE_UNISTD_H 57# include <unistd.h> 58#endif /* HAVE_UNISTD_H */ 59#if defined(YYBISON) && defined(HAVE_ALLOCA_H) && !defined(__GNUC__) 60# include <alloca.h> 61#endif /* YYBISON && HAVE_ALLOCA_H && !__GNUC__ */ 62#include <limits.h> 63 64#include "sudo.h" 65#include "parse.h" 66#include "gram.h" 67 68/* 69 * We must define SIZE_MAX for yacc's skeleton.c. 70 * If there is no SIZE_MAX or SIZE_T_MAX we have to assume that size_t 71 * could be signed (as it is on SunOS 4.x). 72 */ 73#ifndef SIZE_MAX 74# ifdef SIZE_T_MAX 75# define SIZE_MAX SIZE_T_MAX 76# else 77# define SIZE_MAX INT_MAX 78# endif /* SIZE_T_MAX */ 79#endif /* SIZE_MAX */ 80 81/* 82 * Globals 83 */ 84extern int sudolineno; 85extern int last_token; 86extern char *sudoers; 87int sudoers_warnings = TRUE; 88int parse_error = FALSE; 89int pedantic = FALSE; 90int errorlineno = -1; 91char *errorfile = NULL; 92 93struct defaults_list defaults; 94struct userspec_list userspecs; 95 96/* 97 * Local protoypes 98 */ 99static void add_defaults __P((int, struct member *, struct defaults *)); 100static void add_userspec __P((struct member *, struct privilege *)); 101static struct defaults *new_default __P((char *, char *, int)); 102static struct member *new_member __P((char *, int)); 103 void yyerror __P((const char *)); 104 105void 106yyerror(s) 107 const char *s; 108{ 109 /* If we last saw a newline the error is on the preceding line. */ 110 if (last_token == COMMENT) 111 sudolineno--; 112 113 /* Save the line the first error occurred on. */ 114 if (errorlineno == -1) { 115 errorlineno = sudolineno; 116 errorfile = estrdup(sudoers); 117 } 118 if (sudoers_warnings && s != NULL) { 119#ifndef TRACELEXER 120 (void) fprintf(stderr, ">>> %s: %s near line %d <<<\n", sudoers, s, 121 sudolineno); 122#else 123 (void) fprintf(stderr, "<*> "); 124#endif 125 } 126 parse_error = TRUE; 127} 128#line 118 "gram.y" 129#ifndef YYSTYPE_DEFINED 130#define YYSTYPE_DEFINED 131typedef union { 132 struct cmndspec *cmndspec; 133 struct defaults *defaults; 134 struct member *member; 135 struct runascontainer *runas; 136 struct privilege *privilege; 137 struct sudo_command command; 138 struct cmndtag tag; 139 struct selinux_info seinfo; 140 char *string; 141 int tok; 142} YYSTYPE; 143#endif /* YYSTYPE_DEFINED */ 144#line 144 "y.tab.c" 145#define COMMAND 257 146#define ALIAS 258 147#define DEFVAR 259 148#define NTWKADDR 260 149#define NETGROUP 261 150#define USERGROUP 262 151#define WORD 263 152#define DEFAULTS 264 153#define DEFAULTS_HOST 265 154#define DEFAULTS_USER 266 155#define DEFAULTS_RUNAS 267 156#define DEFAULTS_CMND 268 157#define NOPASSWD 269 158#define PASSWD 270 159#define NOEXEC 271 160#define EXEC 272 161#define SETENV 273 162#define NOSETENV 274 163#define LOG_INPUT 275 164#define NOLOG_INPUT 276 165#define LOG_OUTPUT 277 166#define NOLOG_OUTPUT 278 167#define ALL 279 168#define COMMENT 280 169#define HOSTALIAS 281 170#define CMNDALIAS 282 171#define USERALIAS 283 172#define RUNASALIAS 284 173#define ERROR 285 174#define TYPE 286 175#define ROLE 287 176#define YYERRCODE 256 177#if defined(__cplusplus) || defined(__STDC__) 178const short yylhs[] = 179#else 180short yylhs[] = 181#endif 182 { -1, 183 0, 0, 25, 25, 26, 26, 26, 26, 26, 26, 184 26, 26, 26, 26, 26, 26, 4, 4, 3, 3, 185 3, 3, 3, 20, 20, 19, 10, 10, 8, 8, 186 8, 8, 8, 2, 2, 1, 6, 6, 23, 24, 187 22, 22, 22, 22, 22, 17, 17, 18, 18, 18, 188 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 189 21, 5, 5, 5, 28, 28, 31, 9, 9, 29, 190 29, 32, 7, 7, 30, 30, 33, 27, 27, 34, 191 13, 13, 11, 11, 12, 12, 12, 12, 12, 16, 192 16, 14, 14, 15, 15, 15, 193}; 194#if defined(__cplusplus) || defined(__STDC__) 195const short yylen[] = 196#else 197short yylen[] = 198#endif 199 { 2, 200 0, 1, 1, 2, 1, 2, 2, 2, 2, 2, 201 2, 2, 3, 3, 3, 3, 1, 3, 1, 2, 202 3, 3, 3, 1, 3, 3, 1, 2, 1, 1, 203 1, 1, 1, 1, 3, 4, 1, 2, 3, 3, 204 0, 1, 1, 2, 2, 0, 3, 1, 3, 2, 205 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 206 2, 1, 1, 1, 1, 3, 3, 1, 3, 1, 207 3, 3, 1, 3, 1, 3, 3, 1, 3, 3, 208 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 209 3, 1, 2, 1, 1, 1, 210}; 211#if defined(__cplusplus) || defined(__STDC__) 212const short yydefred[] = 213#else 214short yydefred[] = 215#endif 216 { 0, 217 0, 85, 87, 88, 89, 0, 0, 0, 0, 0, 218 86, 5, 0, 0, 0, 0, 0, 0, 81, 83, 219 0, 0, 3, 6, 0, 0, 17, 0, 29, 32, 220 31, 33, 30, 0, 27, 0, 68, 0, 0, 64, 221 63, 62, 0, 37, 73, 0, 0, 0, 65, 0, 222 0, 70, 0, 0, 78, 0, 0, 75, 84, 0, 223 0, 24, 0, 4, 0, 0, 0, 20, 0, 28, 224 0, 0, 0, 0, 38, 0, 0, 0, 0, 0, 225 0, 0, 0, 0, 0, 82, 0, 0, 21, 22, 226 23, 18, 69, 74, 0, 66, 0, 71, 0, 79, 227 0, 76, 0, 34, 0, 0, 25, 0, 0, 0, 228 0, 0, 0, 51, 0, 0, 94, 96, 95, 0, 229 90, 92, 0, 0, 47, 35, 0, 0, 0, 44, 230 45, 93, 0, 0, 40, 39, 52, 53, 54, 55, 231 56, 57, 58, 59, 60, 61, 36, 91, 232}; 233#if defined(__cplusplus) || defined(__STDC__) 234const short yydgoto[] = 235#else 236short yydgoto[] = 237#endif 238 { 18, 239 104, 105, 27, 28, 44, 45, 46, 35, 61, 37, 240 19, 20, 21, 121, 122, 123, 106, 110, 62, 63, 241 129, 114, 115, 116, 22, 23, 54, 48, 51, 57, 242 49, 52, 58, 55, 243}; 244#if defined(__cplusplus) || defined(__STDC__) 245const short yysindex[] = 246#else 247short yysindex[] = 248#endif 249 { 475, 250 -270, 0, 0, 0, 0, -29, 567, 594, 594, -2, 251 0, 0, -240, -222, -216, -212, -241, 0, 0, 0, 252 -25, 475, 0, 0, -10, -207, 0, 9, 0, 0, 253 0, 0, 0, -235, 0, -33, 0, -31, -31, 0, 254 0, 0, -242, 0, 0, -30, -7, 3, 0, -6, 255 4, 0, -5, 6, 0, -1, 8, 0, 0, 594, 256 -20, 0, 10, 0, -205, -196, -194, 0, -29, 0, 257 567, 9, 9, 9, 0, -2, 9, 567, -240, -2, 258 -222, 594, -216, 594, -212, 0, 31, 567, 0, 0, 259 0, 0, 0, 0, 26, 0, 28, 0, 29, 0, 260 29, 0, 541, 0, 32, -247, 0, 86, -15, 33, 261 31, 14, 16, 0, -208, -204, 0, 0, 0, -231, 262 0, 0, 38, 86, 0, 0, -179, -178, 491, 0, 263 0, 0, 86, 38, 0, 0, 0, 0, 0, 0, 264 0, 0, 0, 0, 0, 0, 0, 0,}; 265#if defined(__cplusplus) || defined(__STDC__) 266const short yyrindex[] = 267#else 268short yyrindex[] = 269#endif 270 { 87, 271 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 272 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 273 0, 90, 0, 0, 1, 0, 0, 177, 0, 0, 274 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 275 0, 0, 0, 0, 0, 0, 0, 207, 0, 0, 276 237, 0, 0, 271, 0, 0, 300, 0, 0, 0, 277 0, 0, 329, 0, 0, 0, 0, 0, 0, 0, 278 0, 358, 387, 417, 0, 0, 446, 0, 0, 0, 279 0, 0, 0, 0, 0, 0, -26, 0, 0, 0, 280 0, 0, 0, 0, 30, 0, 59, 0, 89, 0, 281 118, 0, 0, 0, 148, 514, 0, 0, 45, 0, 282 -26, 0, 0, 0, 537, 565, 0, 0, 0, 0, 283 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 284 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 285 0, 0, 0, 0, 0, 0, 0, 0,}; 286#if defined(__cplusplus) || defined(__STDC__) 287const short yygindex[] = 288#else 289short yygindex[] = 290#endif 291 { 0, 292 -17, 0, 27, 11, 54, -64, 15, 64, 2, 34, 293 39, 84, -3, -27, -18, -21, 0, 0, 19, 0, 294 0, 0, -12, -4, 0, 88, 0, 0, 0, 0, 295 35, 40, 23, 37, 296}; 297#define YYTABLESIZE 873 298#if defined(__cplusplus) || defined(__STDC__) 299const short yytable[] = 300#else 301short yytable[] = 302#endif 303 { 26, 304 19, 26, 26, 26, 38, 39, 46, 34, 36, 24, 305 71, 94, 60, 76, 40, 41, 2, 47, 60, 3, 306 4, 5, 29, 71, 30, 31, 117, 32, 60, 67, 307 43, 118, 66, 19, 67, 50, 42, 11, 112, 113, 308 87, 53, 124, 33, 19, 56, 72, 119, 73, 74, 309 65, 68, 69, 78, 80, 82, 77, 89, 72, 84, 310 79, 81, 67, 83, 147, 85, 90, 88, 91, 71, 311 103, 76, 60, 125, 127, 111, 128, 112, 99, 95, 312 101, 133, 113, 135, 136, 48, 1, 67, 80, 2, 313 50, 72, 49, 126, 97, 92, 75, 70, 86, 109, 314 59, 132, 134, 131, 93, 148, 107, 102, 0, 64, 315 130, 0, 0, 96, 0, 0, 72, 77, 120, 100, 316 98, 80, 0, 0, 0, 0, 0, 0, 0, 0, 317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 318 0, 0, 0, 0, 0, 0, 80, 26, 0, 0, 319 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 321 0, 0, 0, 0, 0, 77, 12, 0, 0, 0, 322 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 323 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 324 0, 0, 0, 0, 0, 26, 9, 0, 0, 12, 325 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 326 0, 0, 0, 0, 0, 25, 0, 25, 25, 25, 327 46, 46, 29, 0, 30, 31, 10, 32, 0, 9, 328 0, 0, 46, 46, 46, 46, 46, 46, 46, 46, 329 46, 46, 46, 33, 40, 41, 19, 0, 19, 46, 330 46, 19, 19, 19, 19, 19, 19, 19, 19, 10, 331 8, 0, 0, 0, 0, 0, 42, 0, 0, 19, 332 19, 19, 19, 19, 19, 67, 0, 67, 0, 0, 333 67, 67, 67, 67, 67, 67, 67, 67, 0, 11, 334 0, 0, 0, 8, 0, 0, 0, 0, 67, 67, 335 67, 67, 67, 67, 72, 0, 72, 0, 0, 72, 336 72, 72, 72, 72, 72, 72, 72, 0, 7, 0, 337 0, 0, 11, 0, 0, 0, 0, 72, 72, 72, 338 72, 72, 72, 117, 80, 0, 80, 0, 118, 80, 339 80, 80, 80, 80, 80, 80, 80, 15, 0, 0, 340 0, 7, 0, 0, 119, 0, 0, 80, 80, 80, 341 80, 80, 80, 77, 0, 77, 0, 0, 77, 77, 342 77, 77, 77, 77, 77, 77, 13, 0, 0, 0, 343 15, 0, 0, 0, 0, 0, 77, 77, 77, 77, 344 77, 77, 0, 26, 0, 26, 0, 0, 26, 26, 345 26, 26, 26, 26, 26, 26, 14, 0, 0, 13, 346 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 347 26, 26, 12, 0, 12, 0, 0, 12, 12, 12, 348 12, 12, 12, 12, 12, 16, 0, 0, 0, 14, 349 0, 0, 0, 0, 0, 12, 12, 12, 12, 12, 350 12, 0, 9, 0, 9, 0, 0, 9, 9, 9, 351 9, 9, 9, 9, 9, 0, 0, 0, 16, 0, 352 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 353 9, 0, 10, 0, 10, 0, 0, 10, 10, 10, 354 10, 10, 10, 10, 10, 0, 0, 17, 0, 0, 355 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 356 10, 0, 0, 43, 0, 0, 8, 0, 8, 0, 357 0, 8, 8, 8, 8, 8, 8, 8, 8, 0, 358 0, 0, 0, 0, 0, 0, 41, 0, 0, 8, 359 8, 8, 8, 8, 8, 11, 0, 11, 0, 0, 360 11, 11, 11, 11, 11, 11, 11, 11, 0, 42, 361 0, 0, 0, 17, 0, 0, 0, 0, 11, 11, 362 11, 11, 11, 11, 7, 0, 7, 0, 0, 7, 363 7, 7, 7, 7, 7, 7, 7, 43, 108, 34, 364 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 365 7, 7, 7, 15, 0, 15, 0, 0, 15, 15, 366 15, 15, 15, 15, 15, 15, 17, 0, 0, 0, 367 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 368 15, 15, 13, 0, 13, 0, 0, 13, 13, 13, 369 13, 13, 13, 13, 13, 0, 0, 0, 0, 0, 370 0, 0, 0, 0, 0, 13, 13, 13, 13, 13, 371 13, 0, 14, 0, 14, 0, 0, 14, 14, 14, 372 14, 14, 14, 14, 14, 0, 0, 0, 0, 0, 373 0, 0, 0, 0, 0, 14, 14, 14, 14, 14, 374 14, 16, 0, 16, 0, 0, 16, 16, 16, 16, 375 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 376 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 377 1, 0, 2, 0, 0, 3, 4, 5, 6, 7, 378 8, 9, 10, 0, 0, 0, 0, 40, 41, 0, 379 0, 0, 0, 11, 12, 13, 14, 15, 16, 137, 380 138, 139, 140, 141, 142, 143, 144, 145, 146, 42, 381 41, 41, 0, 0, 0, 0, 0, 0, 0, 0, 382 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, 383 41, 41, 41, 42, 42, 0, 0, 0, 2, 0, 384 0, 3, 4, 5, 0, 42, 42, 42, 42, 42, 385 42, 42, 42, 42, 42, 42, 0, 0, 0, 11, 386 0, 43, 43, 0, 29, 0, 30, 31, 0, 32, 387 0, 0, 0, 43, 43, 43, 43, 43, 43, 43, 388 43, 43, 43, 43, 0, 33, 0, 0, 0, 0, 389 0, 2, 0, 0, 3, 4, 5, 0, 0, 0, 390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 391 0, 0, 11, 392}; 393#if defined(__cplusplus) || defined(__STDC__) 394const short yycheck[] = 395#else 396short yycheck[] = 397#endif 398 { 33, 399 0, 33, 33, 33, 8, 9, 33, 33, 7, 280, 400 44, 76, 44, 44, 257, 258, 258, 258, 44, 261, 401 262, 263, 258, 44, 260, 261, 258, 263, 44, 0, 402 33, 263, 43, 33, 45, 258, 279, 279, 286, 287, 403 61, 258, 58, 279, 44, 258, 36, 279, 38, 39, 404 61, 259, 44, 61, 61, 61, 46, 263, 0, 61, 405 58, 58, 33, 58, 129, 58, 263, 58, 263, 44, 406 40, 44, 44, 41, 61, 44, 61, 286, 82, 78, 407 84, 44, 287, 263, 263, 41, 0, 58, 0, 0, 408 41, 33, 41, 111, 80, 69, 43, 34, 60, 103, 409 17, 120, 124, 116, 71, 133, 88, 85, -1, 22, 410 115, -1, -1, 79, -1, -1, 58, 0, 33, 83, 411 81, 33, -1, -1, -1, -1, -1, -1, -1, -1, 412 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 413 -1, -1, -1, -1, -1, -1, 58, 0, -1, -1, 414 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, 415 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 416 -1, -1, -1, -1, -1, 58, 0, -1, -1, -1, 417 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, 418 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 419 -1, -1, -1, -1, -1, 58, 0, -1, -1, 33, 420 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 421 -1, -1, -1, -1, -1, 259, -1, 259, 259, 259, 422 257, 258, 258, -1, 260, 261, 0, 263, -1, 33, 423 -1, -1, 269, 270, 271, 272, 273, 274, 275, 276, 424 277, 278, 279, 279, 257, 258, 256, -1, 258, 286, 425 287, 261, 262, 263, 264, 265, 266, 267, 268, 33, 426 0, -1, -1, -1, -1, -1, 279, -1, -1, 279, 427 280, 281, 282, 283, 284, 256, -1, 258, -1, -1, 428 261, 262, 263, 264, 265, 266, 267, 268, -1, 0, 429 -1, -1, -1, 33, -1, -1, -1, -1, 279, 280, 430 281, 282, 283, 284, 256, -1, 258, -1, -1, 261, 431 262, 263, 264, 265, 266, 267, 268, -1, 0, -1, 432 -1, -1, 33, -1, -1, -1, -1, 279, 280, 281, 433 282, 283, 284, 258, 256, -1, 258, -1, 263, 261, 434 262, 263, 264, 265, 266, 267, 268, 0, -1, -1, 435 -1, 33, -1, -1, 279, -1, -1, 279, 280, 281, 436 282, 283, 284, 256, -1, 258, -1, -1, 261, 262, 437 263, 264, 265, 266, 267, 268, 0, -1, -1, -1, 438 33, -1, -1, -1, -1, -1, 279, 280, 281, 282, 439 283, 284, -1, 256, -1, 258, -1, -1, 261, 262, 440 263, 264, 265, 266, 267, 268, 0, -1, -1, 33, 441 -1, -1, -1, -1, -1, -1, 279, 280, 281, 282, 442 283, 284, 256, -1, 258, -1, -1, 261, 262, 263, 443 264, 265, 266, 267, 268, 0, -1, -1, -1, 33, 444 -1, -1, -1, -1, -1, 279, 280, 281, 282, 283, 445 284, -1, 256, -1, 258, -1, -1, 261, 262, 263, 446 264, 265, 266, 267, 268, -1, -1, -1, 33, -1, 447 -1, -1, -1, -1, -1, 279, 280, 281, 282, 283, 448 284, -1, 256, -1, 258, -1, -1, 261, 262, 263, 449 264, 265, 266, 267, 268, -1, -1, 33, -1, -1, 450 -1, -1, -1, -1, -1, 279, 280, 281, 282, 283, 451 284, -1, -1, 33, -1, -1, 256, -1, 258, -1, 452 -1, 261, 262, 263, 264, 265, 266, 267, 268, -1, 453 -1, -1, -1, -1, -1, -1, 33, -1, -1, 279, 454 280, 281, 282, 283, 284, 256, -1, 258, -1, -1, 455 261, 262, 263, 264, 265, 266, 267, 268, -1, 33, 456 -1, -1, -1, 33, -1, -1, -1, -1, 279, 280, 457 281, 282, 283, 284, 256, -1, 258, -1, -1, 261, 458 262, 263, 264, 265, 266, 267, 268, 33, 58, 33, 459 -1, -1, -1, -1, -1, -1, -1, 279, 280, 281, 460 282, 283, 284, 256, -1, 258, -1, -1, 261, 262, 461 263, 264, 265, 266, 267, 268, 33, -1, -1, -1, 462 -1, -1, -1, -1, -1, -1, 279, 280, 281, 282, 463 283, 284, 256, -1, 258, -1, -1, 261, 262, 263, 464 264, 265, 266, 267, 268, -1, -1, -1, -1, -1, 465 -1, -1, -1, -1, -1, 279, 280, 281, 282, 283, 466 284, -1, 256, -1, 258, -1, -1, 261, 262, 263, 467 264, 265, 266, 267, 268, -1, -1, -1, -1, -1, 468 -1, -1, -1, -1, -1, 279, 280, 281, 282, 283, 469 284, 256, -1, 258, -1, -1, 261, 262, 263, 264, 470 265, 266, 267, 268, -1, -1, -1, -1, -1, -1, 471 -1, -1, -1, -1, 279, 280, 281, 282, 283, 284, 472 256, -1, 258, -1, -1, 261, 262, 263, 264, 265, 473 266, 267, 268, -1, -1, -1, -1, 257, 258, -1, 474 -1, -1, -1, 279, 280, 281, 282, 283, 284, 269, 475 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 476 257, 258, -1, -1, -1, -1, -1, -1, -1, -1, 477 -1, -1, 269, 270, 271, 272, 273, 274, 275, 276, 478 277, 278, 279, 257, 258, -1, -1, -1, 258, -1, 479 -1, 261, 262, 263, -1, 269, 270, 271, 272, 273, 480 274, 275, 276, 277, 278, 279, -1, -1, -1, 279, 481 -1, 257, 258, -1, 258, -1, 260, 261, -1, 263, 482 -1, -1, -1, 269, 270, 271, 272, 273, 274, 275, 483 276, 277, 278, 279, -1, 279, -1, -1, -1, -1, 484 -1, 258, -1, -1, 261, 262, 263, -1, -1, -1, 485 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 486 -1, -1, 279, 487}; 488#define YYFINAL 18 489#ifndef YYDEBUG 490#define YYDEBUG 0 491#endif 492#define YYMAXTOKEN 287 493#if YYDEBUG 494#if defined(__cplusplus) || defined(__STDC__) 495const char * const yyname[] = 496#else 497char *yyname[] = 498#endif 499 { 500"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, 501"'!'",0,0,0,0,0,0,"'('","')'",0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,"':'", 5020,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, 5030,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, 5040,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, 5050,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, 5060,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, 507"COMMAND","ALIAS","DEFVAR","NTWKADDR","NETGROUP","USERGROUP","WORD","DEFAULTS", 508"DEFAULTS_HOST","DEFAULTS_USER","DEFAULTS_RUNAS","DEFAULTS_CMND","NOPASSWD", 509"PASSWD","NOEXEC","EXEC","SETENV","NOSETENV","LOG_INPUT","NOLOG_INPUT", 510"LOG_OUTPUT","NOLOG_OUTPUT","ALL","COMMENT","HOSTALIAS","CMNDALIAS","USERALIAS", 511"RUNASALIAS","ERROR","TYPE","ROLE", 512}; 513#if defined(__cplusplus) || defined(__STDC__) 514const char * const yyrule[] = 515#else 516char *yyrule[] = 517#endif 518 {"$accept : file", 519"file :", 520"file : line", 521"line : entry", 522"line : line entry", 523"entry : COMMENT", 524"entry : error COMMENT", 525"entry : userlist privileges", 526"entry : USERALIAS useraliases", 527"entry : HOSTALIAS hostaliases", 528"entry : CMNDALIAS cmndaliases", 529"entry : RUNASALIAS runasaliases", 530"entry : DEFAULTS defaults_list", 531"entry : DEFAULTS_USER userlist defaults_list", 532"entry : DEFAULTS_RUNAS userlist defaults_list", 533"entry : DEFAULTS_HOST hostlist defaults_list", 534"entry : DEFAULTS_CMND cmndlist defaults_list", 535"defaults_list : defaults_entry", 536"defaults_list : defaults_list ',' defaults_entry", 537"defaults_entry : DEFVAR", 538"defaults_entry : '!' DEFVAR", 539"defaults_entry : DEFVAR '=' WORD", 540"defaults_entry : DEFVAR '+' WORD", 541"defaults_entry : DEFVAR '-' WORD", 542"privileges : privilege", 543"privileges : privileges ':' privilege", 544"privilege : hostlist '=' cmndspeclist", 545"ophost : host", 546"ophost : '!' host", 547"host : ALIAS", 548"host : ALL", 549"host : NETGROUP", 550"host : NTWKADDR", 551"host : WORD", 552"cmndspeclist : cmndspec", 553"cmndspeclist : cmndspeclist ',' cmndspec", 554"cmndspec : runasspec selinux cmndtag opcmnd", 555"opcmnd : cmnd", 556"opcmnd : '!' cmnd", 557"rolespec : ROLE '=' WORD", 558"typespec : TYPE '=' WORD", 559"selinux :", 560"selinux : rolespec", 561"selinux : typespec", 562"selinux : rolespec typespec", 563"selinux : typespec rolespec", 564"runasspec :", 565"runasspec : '(' runaslist ')'", 566"runaslist : userlist", 567"runaslist : userlist ':' grouplist", 568"runaslist : ':' grouplist", 569"cmndtag :", 570"cmndtag : cmndtag NOPASSWD", 571"cmndtag : cmndtag PASSWD", 572"cmndtag : cmndtag NOEXEC", 573"cmndtag : cmndtag EXEC", 574"cmndtag : cmndtag SETENV", 575"cmndtag : cmndtag NOSETENV", 576"cmndtag : cmndtag LOG_INPUT", 577"cmndtag : cmndtag NOLOG_INPUT", 578"cmndtag : cmndtag LOG_OUTPUT", 579"cmndtag : cmndtag NOLOG_OUTPUT", 580"cmnd : ALL", 581"cmnd : ALIAS", 582"cmnd : COMMAND", 583"hostaliases : hostalias", 584"hostaliases : hostaliases ':' hostalias", 585"hostalias : ALIAS '=' hostlist", 586"hostlist : ophost", 587"hostlist : hostlist ',' ophost", 588"cmndaliases : cmndalias", 589"cmndaliases : cmndaliases ':' cmndalias", 590"cmndalias : ALIAS '=' cmndlist", 591"cmndlist : opcmnd", 592"cmndlist : cmndlist ',' opcmnd", 593"runasaliases : runasalias", 594"runasaliases : runasaliases ':' runasalias", 595"runasalias : ALIAS '=' userlist", 596"useraliases : useralias", 597"useraliases : useraliases ':' useralias", 598"useralias : ALIAS '=' userlist", 599"userlist : opuser", 600"userlist : userlist ',' opuser", 601"opuser : user", 602"opuser : '!' user", 603"user : ALIAS", 604"user : ALL", 605"user : NETGROUP", 606"user : USERGROUP", 607"user : WORD", 608"grouplist : opgroup", 609"grouplist : grouplist ',' opgroup", 610"opgroup : group", 611"opgroup : '!' group", 612"group : ALIAS", 613"group : ALL", 614"group : WORD", 615}; 616#endif 617#ifdef YYSTACKSIZE 618#undef YYMAXDEPTH 619#define YYMAXDEPTH YYSTACKSIZE 620#else 621#ifdef YYMAXDEPTH 622#define YYSTACKSIZE YYMAXDEPTH 623#else 624#define YYSTACKSIZE 10000 625#define YYMAXDEPTH 10000 626#endif 627#endif 628#define YYINITSTACKSIZE 200 629/* LINTUSED */ 630int yydebug; 631int yynerrs; 632int yyerrflag; 633int yychar; 634short *yyssp; 635YYSTYPE *yyvsp; 636YYSTYPE yyval; 637YYSTYPE yylval; 638short *yyss; 639short *yysslim; 640YYSTYPE *yyvs; 641int yystacksize; 642#line 612 "gram.y" 643static struct defaults * 644new_default(var, val, op) 645 char *var; 646 char *val; 647 int op; 648{ 649 struct defaults *d; 650 651 d = emalloc(sizeof(struct defaults)); 652 d->var = var; 653 d->val = val; 654 tq_init(&d->binding); 655 d->type = 0; 656 d->op = op; 657 d->prev = d; 658 d->next = NULL; 659 660 return d; 661} 662 663static struct member * 664new_member(name, type) 665 char *name; 666 int type; 667{ 668 struct member *m; 669 670 m = emalloc(sizeof(struct member)); 671 m->name = name; 672 m->type = type; 673 m->prev = m; 674 m->next = NULL; 675 676 return m; 677} 678 679/* 680 * Add a list of defaults structures to the defaults list. 681 * The binding, if non-NULL, specifies a list of hosts, users, or 682 * runas users the entries apply to (specified by the type). 683 */ 684static void 685add_defaults(type, bmem, defs) 686 int type; 687 struct member *bmem; 688 struct defaults *defs; 689{ 690 struct defaults *d; 691 struct member_list binding; 692 693 /* 694 * We can only call list2tq once on bmem as it will zero 695 * out the prev pointer when it consumes bmem. 696 */ 697 list2tq(&binding, bmem); 698 699 /* 700 * Set type and binding (who it applies to) for new entries. 701 */ 702 for (d = defs; d != NULL; d = d->next) { 703 d->type = type; 704 d->binding = binding; 705 } 706 tq_append(&defaults, defs); 707} 708 709/* 710 * Allocate a new struct userspec, populate it, and insert it at the 711 * and of the userspecs list. 712 */ 713static void 714add_userspec(members, privs) 715 struct member *members; 716 struct privilege *privs; 717{ 718 struct userspec *u; 719 720 u = emalloc(sizeof(*u)); 721 list2tq(&u->users, members); 722 list2tq(&u->privileges, privs); 723 u->prev = u; 724 u->next = NULL; 725 tq_append(&userspecs, u); 726} 727 728/* 729 * Free up space used by data structures from a previous parser run and sets 730 * the current sudoers file to path. 731 */ 732void 733init_parser(path, quiet) 734 char *path; 735 int quiet; 736{ 737 struct defaults *d; 738 struct member *m, *binding; 739 struct userspec *us; 740 struct privilege *priv; 741 struct cmndspec *cs; 742 struct sudo_command *c; 743 744 while ((us = tq_pop(&userspecs)) != NULL) { 745 while ((m = tq_pop(&us->users)) != NULL) { 746 efree(m->name); 747 efree(m); 748 } 749 while ((priv = tq_pop(&us->privileges)) != NULL) { 750 struct member *runasuser = NULL, *runasgroup = NULL; 751#ifdef HAVE_SELINUX 752 char *role = NULL, *type = NULL; 753#endif /* HAVE_SELINUX */ 754 755 while ((m = tq_pop(&priv->hostlist)) != NULL) { 756 efree(m->name); 757 efree(m); 758 } 759 while ((cs = tq_pop(&priv->cmndlist)) != NULL) { 760#ifdef HAVE_SELINUX 761 /* Only free the first instance of a role/type. */ 762 if (cs->role != role) { 763 role = cs->role; 764 efree(cs->role); 765 } 766 if (cs->type != type) { 767 type = cs->type; 768 efree(cs->type); 769 } 770#endif /* HAVE_SELINUX */ 771 if (tq_last(&cs->runasuserlist) != runasuser) { 772 runasuser = tq_last(&cs->runasuserlist); 773 while ((m = tq_pop(&cs->runasuserlist)) != NULL) { 774 efree(m->name); 775 efree(m); 776 } 777 } 778 if (tq_last(&cs->runasgrouplist) != runasgroup) { 779 runasgroup = tq_last(&cs->runasgrouplist); 780 while ((m = tq_pop(&cs->runasgrouplist)) != NULL) { 781 efree(m->name); 782 efree(m); 783 } 784 } 785 if (cs->cmnd->type == COMMAND) { 786 c = (struct sudo_command *) cs->cmnd->name; 787 efree(c->cmnd); 788 efree(c->args); 789 } 790 efree(cs->cmnd->name); 791 efree(cs->cmnd); 792 efree(cs); 793 } 794 efree(priv); 795 } 796 efree(us); 797 } 798 tq_init(&userspecs); 799 800 binding = NULL; 801 while ((d = tq_pop(&defaults)) != NULL) { 802 if (tq_last(&d->binding) != binding) { 803 binding = tq_last(&d->binding); 804 while ((m = tq_pop(&d->binding)) != NULL) { 805 if (m->type == COMMAND) { 806 c = (struct sudo_command *) m->name; 807 efree(c->cmnd); 808 efree(c->args); 809 } 810 efree(m->name); 811 efree(m); 812 } 813 } 814 efree(d->var); 815 efree(d->val); 816 efree(d); 817 } 818 tq_init(&defaults); 819 820 init_aliases(); 821 822 init_lexer(); 823 824 efree(sudoers); 825 sudoers = path ? estrdup(path) : NULL; 826 827 parse_error = FALSE; 828 errorlineno = -1; 829 errorfile = sudoers; 830 sudoers_warnings = !quiet; 831} 832#line 780 "y.tab.c" 833/* allocate initial stack or double stack size, up to YYMAXDEPTH */ 834#if defined(__cplusplus) || defined(__STDC__) 835static int yygrowstack(void) 836#else 837static int yygrowstack() 838#endif 839{ 840 int newsize, i; 841 short *newss; 842 YYSTYPE *newvs; 843 844 if ((newsize = yystacksize) == 0) 845 newsize = YYINITSTACKSIZE; 846 else if (newsize >= YYMAXDEPTH) 847 return -1; 848 else if ((newsize *= 2) > YYMAXDEPTH) 849 newsize = YYMAXDEPTH; 850#ifdef SIZE_MAX 851#define YY_SIZE_MAX SIZE_MAX 852#else 853#define YY_SIZE_MAX 0x7fffffff 854#endif 855 if (YY_SIZE_MAX / newsize < sizeof *newss) 856 goto bail; 857 i = yyssp - yyss; 858 newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : 859 (short *)malloc(newsize * sizeof *newss); /* overflow check above */ 860 if (newss == NULL) 861 goto bail; 862 yyss = newss; 863 yyssp = newss + i; 864 newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : 865 (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */ 866 if (newvs == NULL) 867 goto bail; 868 yyvs = newvs; 869 yyvsp = newvs + i; 870 yystacksize = newsize; 871 yysslim = yyss + newsize - 1; 872 return 0; 873bail: 874 if (yyss) 875 free(yyss); 876 if (yyvs) 877 free(yyvs); 878 yyss = yyssp = NULL; 879 yyvs = yyvsp = NULL; 880 yystacksize = 0; 881 return -1; 882} 883 884#define YYABORT goto yyabort 885#define YYREJECT goto yyabort 886#define YYACCEPT goto yyaccept 887#define YYERROR goto yyerrlab 888int 889#if defined(__cplusplus) || defined(__STDC__) 890yyparse(void) 891#else 892yyparse() 893#endif 894{ 895 int yym, yyn, yystate; 896#if YYDEBUG 897#if defined(__cplusplus) || defined(__STDC__) 898 const char *yys; 899#else /* !(defined(__cplusplus) || defined(__STDC__)) */ 900 char *yys; 901#endif /* !(defined(__cplusplus) || defined(__STDC__)) */ 902 903 if ((yys = getenv("YYDEBUG"))) 904 { 905 yyn = *yys; 906 if (yyn >= '0' && yyn <= '9') 907 yydebug = yyn - '0'; 908 } 909#endif /* YYDEBUG */ 910 911 yynerrs = 0; 912 yyerrflag = 0; 913 yychar = (-1); 914 915 if (yyss == NULL && yygrowstack()) goto yyoverflow; 916 yyssp = yyss; 917 yyvsp = yyvs; 918 *yyssp = yystate = 0; 919 920yyloop: 921 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 922 if (yychar < 0) 923 { 924 if ((yychar = yylex()) < 0) yychar = 0; 925#if YYDEBUG 926 if (yydebug) 927 { 928 yys = 0; 929 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 930 if (!yys) yys = "illegal-symbol"; 931 printf("%sdebug: state %d, reading %d (%s)\n", 932 YYPREFIX, yystate, yychar, yys); 933 } 934#endif 935 } 936 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 937 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 938 { 939#if YYDEBUG 940 if (yydebug) 941 printf("%sdebug: state %d, shifting to state %d\n", 942 YYPREFIX, yystate, yytable[yyn]); 943#endif 944 if (yyssp >= yysslim && yygrowstack()) 945 { 946 goto yyoverflow; 947 } 948 *++yyssp = yystate = yytable[yyn]; 949 *++yyvsp = yylval; 950 yychar = (-1); 951 if (yyerrflag > 0) --yyerrflag; 952 goto yyloop; 953 } 954 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 955 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 956 { 957 yyn = yytable[yyn]; 958 goto yyreduce; 959 } 960 if (yyerrflag) goto yyinrecovery; 961#if defined(lint) || defined(__GNUC__) 962 goto yynewerror; 963#endif 964yynewerror: 965 yyerror("syntax error"); 966#if defined(lint) || defined(__GNUC__) 967 goto yyerrlab; 968#endif 969yyerrlab: 970 ++yynerrs; 971yyinrecovery: 972 if (yyerrflag < 3) 973 { 974 yyerrflag = 3; 975 for (;;) 976 { 977 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && 978 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 979 { 980#if YYDEBUG 981 if (yydebug) 982 printf("%sdebug: state %d, error recovery shifting\ 983 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); 984#endif 985 if (yyssp >= yysslim && yygrowstack()) 986 { 987 goto yyoverflow; 988 } 989 *++yyssp = yystate = yytable[yyn]; 990 *++yyvsp = yylval; 991 goto yyloop; 992 } 993 else 994 { 995#if YYDEBUG 996 if (yydebug) 997 printf("%sdebug: error recovery discarding state %d\n", 998 YYPREFIX, *yyssp); 999#endif 1000 if (yyssp <= yyss) goto yyabort; 1001 --yyssp; 1002 --yyvsp; 1003 } 1004 } 1005 } 1006 else 1007 { 1008 if (yychar == 0) goto yyabort; 1009#if YYDEBUG 1010 if (yydebug) 1011 { 1012 yys = 0; 1013 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1014 if (!yys) yys = "illegal-symbol"; 1015 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 1016 YYPREFIX, yystate, yychar, yys); 1017 } 1018#endif 1019 yychar = (-1); 1020 goto yyloop; 1021 } 1022yyreduce: 1023#if YYDEBUG 1024 if (yydebug) 1025 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 1026 YYPREFIX, yystate, yyn, yyrule[yyn]); 1027#endif 1028 yym = yylen[yyn]; 1029 if (yym) 1030 yyval = yyvsp[1-yym]; 1031 else 1032 memset(&yyval, 0, sizeof yyval); 1033 switch (yyn) 1034 { 1035case 1: 1036#line 193 "gram.y" 1037{ ; } 1038break; 1039case 5: 1040#line 201 "gram.y" 1041{ 1042 ; 1043 } 1044break; 1045case 6: 1046#line 204 "gram.y" 1047{ 1048 yyerrok; 1049 } 1050break; 1051case 7: 1052#line 207 "gram.y" 1053{ 1054 add_userspec(yyvsp[-1].member, yyvsp[0].privilege); 1055 } 1056break; 1057case 8: 1058#line 210 "gram.y" 1059{ 1060 ; 1061 } 1062break; 1063case 9: 1064#line 213 "gram.y" 1065{ 1066 ; 1067 } 1068break; 1069case 10: 1070#line 216 "gram.y" 1071{ 1072 ; 1073 } 1074break; 1075case 11: 1076#line 219 "gram.y" 1077{ 1078 ; 1079 } 1080break; 1081case 12: 1082#line 222 "gram.y" 1083{ 1084 add_defaults(DEFAULTS, NULL, yyvsp[0].defaults); 1085 } 1086break; 1087case 13: 1088#line 225 "gram.y" 1089{ 1090 add_defaults(DEFAULTS_USER, yyvsp[-1].member, yyvsp[0].defaults); 1091 } 1092break; 1093case 14: 1094#line 228 "gram.y" 1095{ 1096 add_defaults(DEFAULTS_RUNAS, yyvsp[-1].member, yyvsp[0].defaults); 1097 } 1098break; 1099case 15: 1100#line 231 "gram.y" 1101{ 1102 add_defaults(DEFAULTS_HOST, yyvsp[-1].member, yyvsp[0].defaults); 1103 } 1104break; 1105case 16: 1106#line 234 "gram.y" 1107{ 1108 add_defaults(DEFAULTS_CMND, yyvsp[-1].member, yyvsp[0].defaults); 1109 } 1110break; 1111case 18: 1112#line 240 "gram.y" 1113{ 1114 list_append(yyvsp[-2].defaults, yyvsp[0].defaults); 1115 yyval.defaults = yyvsp[-2].defaults; 1116 } 1117break; 1118case 19: 1119#line 246 "gram.y" 1120{ 1121 yyval.defaults = new_default(yyvsp[0].string, NULL, TRUE); 1122 } 1123break; 1124case 20: 1125#line 249 "gram.y" 1126{ 1127 yyval.defaults = new_default(yyvsp[0].string, NULL, FALSE); 1128 } 1129break; 1130case 21: 1131#line 252 "gram.y" 1132{ 1133 yyval.defaults = new_default(yyvsp[-2].string, yyvsp[0].string, TRUE); 1134 } 1135break; 1136case 22: 1137#line 255 "gram.y" 1138{ 1139 yyval.defaults = new_default(yyvsp[-2].string, yyvsp[0].string, '+'); 1140 } 1141break; 1142case 23: 1143#line 258 "gram.y" 1144{ 1145 yyval.defaults = new_default(yyvsp[-2].string, yyvsp[0].string, '-'); 1146 } 1147break; 1148case 25: 1149#line 264 "gram.y" 1150{ 1151 list_append(yyvsp[-2].privilege, yyvsp[0].privilege); 1152 yyval.privilege = yyvsp[-2].privilege; 1153 } 1154break; 1155case 26: 1156#line 270 "gram.y" 1157{ 1158 struct privilege *p = emalloc(sizeof(*p)); 1159 list2tq(&p->hostlist, yyvsp[-2].member); 1160 list2tq(&p->cmndlist, yyvsp[0].cmndspec); 1161 p->prev = p; 1162 p->next = NULL; 1163 yyval.privilege = p; 1164 } 1165break; 1166case 27: 1167#line 280 "gram.y" 1168{ 1169 yyval.member = yyvsp[0].member; 1170 yyval.member->negated = FALSE; 1171 } 1172break; 1173case 28: 1174#line 284 "gram.y" 1175{ 1176 yyval.member = yyvsp[0].member; 1177 yyval.member->negated = TRUE; 1178 } 1179break; 1180case 29: 1181#line 290 "gram.y" 1182{ 1183 yyval.member = new_member(yyvsp[0].string, ALIAS); 1184 } 1185break; 1186case 30: 1187#line 293 "gram.y" 1188{ 1189 yyval.member = new_member(NULL, ALL); 1190 } 1191break; 1192case 31: 1193#line 296 "gram.y" 1194{ 1195 yyval.member = new_member(yyvsp[0].string, NETGROUP); 1196 } 1197break; 1198case 32: 1199#line 299 "gram.y" 1200{ 1201 yyval.member = new_member(yyvsp[0].string, NTWKADDR); 1202 } 1203break; 1204case 33: 1205#line 302 "gram.y" 1206{ 1207 yyval.member = new_member(yyvsp[0].string, WORD); 1208 } 1209break; 1210case 35: 1211#line 308 "gram.y" 1212{ 1213 list_append(yyvsp[-2].cmndspec, yyvsp[0].cmndspec); 1214#ifdef HAVE_SELINUX 1215 /* propagate role and type */ 1216 if (yyvsp[0].cmndspec->role == NULL) 1217 yyvsp[0].cmndspec->role = yyvsp[0].cmndspec->prev->role; 1218 if (yyvsp[0].cmndspec->type == NULL) 1219 yyvsp[0].cmndspec->type = yyvsp[0].cmndspec->prev->type; 1220#endif /* HAVE_SELINUX */ 1221 /* propagate tags and runas list */ 1222 if (yyvsp[0].cmndspec->tags.nopasswd == UNSPEC) 1223 yyvsp[0].cmndspec->tags.nopasswd = yyvsp[0].cmndspec->prev->tags.nopasswd; 1224 if (yyvsp[0].cmndspec->tags.noexec == UNSPEC) 1225 yyvsp[0].cmndspec->tags.noexec = yyvsp[0].cmndspec->prev->tags.noexec; 1226 if (yyvsp[0].cmndspec->tags.setenv == UNSPEC && 1227 yyvsp[0].cmndspec->prev->tags.setenv != IMPLIED) 1228 yyvsp[0].cmndspec->tags.setenv = yyvsp[0].cmndspec->prev->tags.setenv; 1229 if (yyvsp[0].cmndspec->tags.log_input == UNSPEC) 1230 yyvsp[0].cmndspec->tags.log_input = yyvsp[0].cmndspec->prev->tags.log_input; 1231 if (yyvsp[0].cmndspec->tags.log_output == UNSPEC) 1232 yyvsp[0].cmndspec->tags.log_output = yyvsp[0].cmndspec->prev->tags.log_output; 1233 if ((tq_empty(&yyvsp[0].cmndspec->runasuserlist) && 1234 tq_empty(&yyvsp[0].cmndspec->runasgrouplist)) && 1235 (!tq_empty(&yyvsp[0].cmndspec->prev->runasuserlist) || 1236 !tq_empty(&yyvsp[0].cmndspec->prev->runasgrouplist))) { 1237 yyvsp[0].cmndspec->runasuserlist = yyvsp[0].cmndspec->prev->runasuserlist; 1238 yyvsp[0].cmndspec->runasgrouplist = yyvsp[0].cmndspec->prev->runasgrouplist; 1239 } 1240 yyval.cmndspec = yyvsp[-2].cmndspec; 1241 } 1242break; 1243case 36: 1244#line 340 "gram.y" 1245{ 1246 struct cmndspec *cs = emalloc(sizeof(*cs)); 1247 if (yyvsp[-3].runas != NULL) { 1248 list2tq(&cs->runasuserlist, yyvsp[-3].runas->runasusers); 1249 list2tq(&cs->runasgrouplist, yyvsp[-3].runas->runasgroups); 1250 efree(yyvsp[-3].runas); 1251 } else { 1252 tq_init(&cs->runasuserlist); 1253 tq_init(&cs->runasgrouplist); 1254 } 1255#ifdef HAVE_SELINUX 1256 cs->role = yyvsp[-2].seinfo.role; 1257 cs->type = yyvsp[-2].seinfo.type; 1258#endif 1259 cs->tags = yyvsp[-1].tag; 1260 cs->cmnd = yyvsp[0].member; 1261 cs->prev = cs; 1262 cs->next = NULL; 1263 /* sudo "ALL" implies the SETENV tag */ 1264 if (cs->cmnd->type == ALL && !cs->cmnd->negated && 1265 cs->tags.setenv == UNSPEC) 1266 cs->tags.setenv = IMPLIED; 1267 yyval.cmndspec = cs; 1268 } 1269break; 1270case 37: 1271#line 366 "gram.y" 1272{ 1273 yyval.member = yyvsp[0].member; 1274 yyval.member->negated = FALSE; 1275 } 1276break; 1277case 38: 1278#line 370 "gram.y" 1279{ 1280 yyval.member = yyvsp[0].member; 1281 yyval.member->negated = TRUE; 1282 } 1283break; 1284case 39: 1285#line 376 "gram.y" 1286{ 1287 yyval.string = yyvsp[0].string; 1288 } 1289break; 1290case 40: 1291#line 381 "gram.y" 1292{ 1293 yyval.string = yyvsp[0].string; 1294 } 1295break; 1296case 41: 1297#line 386 "gram.y" 1298{ 1299 yyval.seinfo.role = NULL; 1300 yyval.seinfo.type = NULL; 1301 } 1302break; 1303case 42: 1304#line 390 "gram.y" 1305{ 1306 yyval.seinfo.role = yyvsp[0].string; 1307 yyval.seinfo.type = NULL; 1308 } 1309break; 1310case 43: 1311#line 394 "gram.y" 1312{ 1313 yyval.seinfo.type = yyvsp[0].string; 1314 yyval.seinfo.role = NULL; 1315 } 1316break; 1317case 44: 1318#line 398 "gram.y" 1319{ 1320 yyval.seinfo.role = yyvsp[-1].string; 1321 yyval.seinfo.type = yyvsp[0].string; 1322 } 1323break; 1324case 45: 1325#line 402 "gram.y" 1326{ 1327 yyval.seinfo.type = yyvsp[-1].string; 1328 yyval.seinfo.role = yyvsp[0].string; 1329 } 1330break; 1331case 46: 1332#line 408 "gram.y" 1333{ 1334 yyval.runas = NULL; 1335 } 1336break; 1337case 47: 1338#line 411 "gram.y" 1339{ 1340 yyval.runas = yyvsp[-1].runas; 1341 } 1342break; 1343case 48: 1344#line 416 "gram.y" 1345{ 1346 yyval.runas = emalloc(sizeof(struct runascontainer)); 1347 yyval.runas->runasusers = yyvsp[0].member; 1348 yyval.runas->runasgroups = NULL; 1349 } 1350break; 1351case 49: 1352#line 421 "gram.y" 1353{ 1354 yyval.runas = emalloc(sizeof(struct runascontainer)); 1355 yyval.runas->runasusers = yyvsp[-2].member; 1356 yyval.runas->runasgroups = yyvsp[0].member; 1357 } 1358break; 1359case 50: 1360#line 426 "gram.y" 1361{ 1362 yyval.runas = emalloc(sizeof(struct runascontainer)); 1363 yyval.runas->runasusers = NULL; 1364 yyval.runas->runasgroups = yyvsp[0].member; 1365 } 1366break; 1367case 51: 1368#line 433 "gram.y" 1369{ 1370 yyval.tag.nopasswd = yyval.tag.noexec = yyval.tag.setenv = 1371 yyval.tag.log_input = yyval.tag.log_output = UNSPEC; 1372 } 1373break; 1374case 52: 1375#line 437 "gram.y" 1376{ 1377 yyval.tag.nopasswd = TRUE; 1378 } 1379break; 1380case 53: 1381#line 440 "gram.y" 1382{ 1383 yyval.tag.nopasswd = FALSE; 1384 } 1385break; 1386case 54: 1387#line 443 "gram.y" 1388{ 1389 yyval.tag.noexec = TRUE; 1390 } 1391break; 1392case 55: 1393#line 446 "gram.y" 1394{ 1395 yyval.tag.noexec = FALSE; 1396 } 1397break; 1398case 56: 1399#line 449 "gram.y" 1400{ 1401 yyval.tag.setenv = TRUE; 1402 } 1403break; 1404case 57: 1405#line 452 "gram.y" 1406{ 1407 yyval.tag.setenv = FALSE; 1408 } 1409break; 1410case 58: 1411#line 455 "gram.y" 1412{ 1413 yyval.tag.log_input = TRUE; 1414 } 1415break; 1416case 59: 1417#line 458 "gram.y" 1418{ 1419 yyval.tag.log_input = FALSE; 1420 } 1421break; 1422case 60: 1423#line 461 "gram.y" 1424{ 1425 yyval.tag.log_output = TRUE; 1426 } 1427break; 1428case 61: 1429#line 464 "gram.y" 1430{ 1431 yyval.tag.log_output = FALSE; 1432 } 1433break; 1434case 62: 1435#line 469 "gram.y" 1436{ 1437 yyval.member = new_member(NULL, ALL); 1438 } 1439break; 1440case 63: 1441#line 472 "gram.y" 1442{ 1443 yyval.member = new_member(yyvsp[0].string, ALIAS); 1444 } 1445break; 1446case 64: 1447#line 475 "gram.y" 1448{ 1449 struct sudo_command *c = emalloc(sizeof(*c)); 1450 c->cmnd = yyvsp[0].command.cmnd; 1451 c->args = yyvsp[0].command.args; 1452 yyval.member = new_member((char *)c, COMMAND); 1453 } 1454break; 1455case 67: 1456#line 487 "gram.y" 1457{ 1458 char *s; 1459 if ((s = alias_add(yyvsp[-2].string, HOSTALIAS, yyvsp[0].member)) != NULL) { 1460 yyerror(s); 1461 YYERROR; 1462 } 1463 } 1464break; 1465case 69: 1466#line 497 "gram.y" 1467{ 1468 list_append(yyvsp[-2].member, yyvsp[0].member); 1469 yyval.member = yyvsp[-2].member; 1470 } 1471break; 1472case 72: 1473#line 507 "gram.y" 1474{ 1475 char *s; 1476 if ((s = alias_add(yyvsp[-2].string, CMNDALIAS, yyvsp[0].member)) != NULL) { 1477 yyerror(s); 1478 YYERROR; 1479 } 1480 } 1481break; 1482case 74: 1483#line 517 "gram.y" 1484{ 1485 list_append(yyvsp[-2].member, yyvsp[0].member); 1486 yyval.member = yyvsp[-2].member; 1487 } 1488break; 1489case 77: 1490#line 527 "gram.y" 1491{ 1492 char *s; 1493 if ((s = alias_add(yyvsp[-2].string, RUNASALIAS, yyvsp[0].member)) != NULL) { 1494 yyerror(s); 1495 YYERROR; 1496 } 1497 } 1498break; 1499case 80: 1500#line 540 "gram.y" 1501{ 1502 char *s; 1503 if ((s = alias_add(yyvsp[-2].string, USERALIAS, yyvsp[0].member)) != NULL) { 1504 yyerror(s); 1505 YYERROR; 1506 } 1507 } 1508break; 1509case 82: 1510#line 550 "gram.y" 1511{ 1512 list_append(yyvsp[-2].member, yyvsp[0].member); 1513 yyval.member = yyvsp[-2].member; 1514 } 1515break; 1516case 83: 1517#line 556 "gram.y" 1518{ 1519 yyval.member = yyvsp[0].member; 1520 yyval.member->negated = FALSE; 1521 } 1522break; 1523case 84: 1524#line 560 "gram.y" 1525{ 1526 yyval.member = yyvsp[0].member; 1527 yyval.member->negated = TRUE; 1528 } 1529break; 1530case 85: 1531#line 566 "gram.y" 1532{ 1533 yyval.member = new_member(yyvsp[0].string, ALIAS); 1534 } 1535break; 1536case 86: 1537#line 569 "gram.y" 1538{ 1539 yyval.member = new_member(NULL, ALL); 1540 } 1541break; 1542case 87: 1543#line 572 "gram.y" 1544{ 1545 yyval.member = new_member(yyvsp[0].string, NETGROUP); 1546 } 1547break; 1548case 88: 1549#line 575 "gram.y" 1550{ 1551 yyval.member = new_member(yyvsp[0].string, USERGROUP); 1552 } 1553break; 1554case 89: 1555#line 578 "gram.y" 1556{ 1557 yyval.member = new_member(yyvsp[0].string, WORD); 1558 } 1559break; 1560case 91: 1561#line 584 "gram.y" 1562{ 1563 list_append(yyvsp[-2].member, yyvsp[0].member); 1564 yyval.member = yyvsp[-2].member; 1565 } 1566break; 1567case 92: 1568#line 590 "gram.y" 1569{ 1570 yyval.member = yyvsp[0].member; 1571 yyval.member->negated = FALSE; 1572 } 1573break; 1574case 93: 1575#line 594 "gram.y" 1576{ 1577 yyval.member = yyvsp[0].member; 1578 yyval.member->negated = TRUE; 1579 } 1580break; 1581case 94: 1582#line 600 "gram.y" 1583{ 1584 yyval.member = new_member(yyvsp[0].string, ALIAS); 1585 } 1586break; 1587case 95: 1588#line 603 "gram.y" 1589{ 1590 yyval.member = new_member(NULL, ALL); 1591 } 1592break; 1593case 96: 1594#line 606 "gram.y" 1595{ 1596 yyval.member = new_member(yyvsp[0].string, WORD); 1597 } 1598break; 1599#line 1547 "y.tab.c" 1600 } 1601 yyssp -= yym; 1602 yystate = *yyssp; 1603 yyvsp -= yym; 1604 yym = yylhs[yyn]; 1605 if (yystate == 0 && yym == 0) 1606 { 1607#if YYDEBUG 1608 if (yydebug) 1609 printf("%sdebug: after reduction, shifting from state 0 to\ 1610 state %d\n", YYPREFIX, YYFINAL); 1611#endif 1612 yystate = YYFINAL; 1613 *++yyssp = YYFINAL; 1614 *++yyvsp = yyval; 1615 if (yychar < 0) 1616 { 1617 if ((yychar = yylex()) < 0) yychar = 0; 1618#if YYDEBUG 1619 if (yydebug) 1620 { 1621 yys = 0; 1622 if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 1623 if (!yys) yys = "illegal-symbol"; 1624 printf("%sdebug: state %d, reading %d (%s)\n", 1625 YYPREFIX, YYFINAL, yychar, yys); 1626 } 1627#endif 1628 } 1629 if (yychar == 0) goto yyaccept; 1630 goto yyloop; 1631 } 1632 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 1633 yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 1634 yystate = yytable[yyn]; 1635 else 1636 yystate = yydgoto[yym]; 1637#if YYDEBUG 1638 if (yydebug) 1639 printf("%sdebug: after reduction, shifting from state %d \ 1640to state %d\n", YYPREFIX, *yyssp, yystate); 1641#endif 1642 if (yyssp >= yysslim && yygrowstack()) 1643 { 1644 goto yyoverflow; 1645 } 1646 *++yyssp = yystate; 1647 *++yyvsp = yyval; 1648 goto yyloop; 1649yyoverflow: 1650 yyerror("yacc stack overflow"); 1651yyabort: 1652 if (yyss) 1653 free(yyss); 1654 if (yyvs) 1655 free(yyvs); 1656 yyss = yyssp = NULL; 1657 yyvs = yyvsp = NULL; 1658 yystacksize = 0; 1659 return (1); 1660yyaccept: 1661 if (yyss) 1662 free(yyss); 1663 if (yyvs) 1664 free(yyvs); 1665 yyss = yyssp = NULL; 1666 yyvs = yyvsp = NULL; 1667 yystacksize = 0; 1668 return (0); 1669} 1670