Coverage Report

Created: 2026-12-01 07:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/sudo/plugins/sudoers/gram.c
Line
Count
Source
1
#include <config.h>
2
/* A Bison parser, made by GNU Bison 3.8.2.  */
3
4
/* Bison implementation for Yacc-like parsers in C
5
6
   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
7
   Inc.
8
9
   This program is free software: you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation, either version 3 of the License, or
12
   (at your option) any later version.
13
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
21
22
/* As a special exception, you may create a larger work that contains
23
   part or all of the Bison parser skeleton and distribute that work
24
   under terms of your choice, so long as that work isn't itself a
25
   parser generator using the skeleton or a modified version thereof
26
   as a parser skeleton.  Alternatively, if you modify or redistribute
27
   the parser skeleton itself, you may (at your option) remove this
28
   special exception, which will cause the skeleton and the resulting
29
   Bison output files to be licensed under the GNU General Public
30
   License without this special exception.
31
32
   This special exception was added by the Free Software Foundation in
33
   version 2.2 of Bison.  */
34
35
/* C LALR(1) parser skeleton written by Richard Stallman, by
36
   simplifying the original so-called "semantic" parser.  */
37
38
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
39
   especially those whose name start with YY_ or yy_.  They are
40
   private implementation details that can be changed or removed.  */
41
42
/* All symbols defined below should begin with yy or YY, to avoid
43
   infringing on user name space.  This should be done even for local
44
   variables, as they might otherwise be expanded by user macros.
45
   There are some unavoidable exceptions within include files to
46
   define necessary library symbols; they are noted "INFRINGES ON
47
   USER NAME SPACE" below.  */
48
49
/* Identify Bison output, and Bison version.  */
50
#define YYBISON 30802
51
52
/* Bison version string.  */
53
#define YYBISON_VERSION "3.8.2"
54
55
/* Skeleton name.  */
56
#define YYSKELETON_NAME "yacc.c"
57
58
/* Pure parsers.  */
59
#define YYPURE 0
60
61
/* Push parsers.  */
62
#define YYPUSH 0
63
64
/* Pull parsers.  */
65
#define YYPULL 1
66
67
68
/* Substitute the variable and function names.  */
69
#define yyparse         sudoersparse
70
1.97M
#define yylex           sudoerslex
71
65.4k
#define yyerror         sudoerserror
72
#define yydebug         sudoersdebug
73
105k
#define yynerrs         sudoersnerrs
74
2.41M
#define yylval          sudoerslval
75
12.4M
#define yychar          sudoerschar
76
77
/* First part of user prologue.  */
78
#line 1 "gram.y"
79
80
/*
81
 * SPDX-License-Identifier: ISC
82
 *
83
 * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2024
84
 *  Todd C. Miller <Todd.Miller@sudo.ws>
85
 *
86
 * Permission to use, copy, modify, and distribute this software for any
87
 * purpose with or without fee is hereby granted, provided that the above
88
 * copyright notice and this permission notice appear in all copies.
89
 *
90
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
91
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
92
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
93
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
94
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
95
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
96
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
97
 *
98
 * Sponsored in part by the Defense Advanced Research Projects
99
 * Agency (DARPA) and Air Force Research Laboratory, Air Force
100
 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
101
 */
102
103
#include <config.h>
104
105
#include <stdio.h>
106
#include <stdlib.h>
107
#include <stddef.h>
108
#include <string.h>
109
#include <unistd.h>
110
#include <errno.h>
111
112
#include <sudoers.h>
113
#include <sudo_digest.h>
114
#include <toke.h>
115
116
#ifdef YYBISON
117
# define YYERROR_VERBOSE
118
#endif
119
120
/* If we last saw a newline the entry is on the preceding line. */
121
360k
#define this_lineno (sudoerschar == '\n' ? sudolineno - 1 : sudolineno)
122
123
// PVS Studio suppression
124
// -V::560, 592, 1037, 1042
125
126
/*
127
 * Globals
128
 */
129
bool parse_error = false;
130
131
static struct sudoers_parser_config parser_conf =
132
    SUDOERS_PARSER_CONFIG_INITIALIZER;
133
134
/* Optional logging function for parse errors. */
135
sudoers_logger_t sudoers_error_hook;
136
137
static int alias_line, alias_column;
138
139
#ifdef NO_LEAKS
140
static struct parser_leak_list parser_leak_list =
141
    SLIST_HEAD_INITIALIZER(parser_leak_list);
142
#endif
143
144
struct sudoers_parse_tree parsed_policy = {
145
    { NULL, NULL }, /* entries */
146
    TAILQ_HEAD_INITIALIZER(parsed_policy.userspecs),
147
    TAILQ_HEAD_INITIALIZER(parsed_policy.defaults),
148
    NULL, /* aliases */
149
    NULL, /* lhost */
150
    NULL, /* shost */
151
    NULL, /* nss */
152
    NULL  /* ctx */
153
};
154
155
/*
156
 * Local prototypes
157
 */
158
static bool add_defaults(short, struct member *, struct defaults *);
159
static bool add_userspec(struct member *, struct privilege *);
160
static struct command_digest *new_digest(unsigned int, char *);
161
static struct defaults *new_default(char *, char *, short);
162
static struct member *new_member(char *, short);
163
static struct sudo_command *new_command(char *, char *);
164
static void alias_error(const char *name, short type, int errnum);
165
static void init_options(struct command_options *opts);
166
static void propagate_cmndspec(struct cmndspec *cs, const struct cmndspec *prev);
167
168
#line 168 "gram.c"
169
170
# ifndef YY_CAST
171
#  ifdef __cplusplus
172
#   define YY_CAST(Type, Val) static_cast<Type> (Val)
173
#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
174
#  else
175
8.24M
#   define YY_CAST(Type, Val) ((Type) (Val))
176
#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
177
#  endif
178
# endif
179
# ifndef YY_NULLPTR
180
#  if defined __cplusplus
181
#   if 201103L <= __cplusplus
182
#    define YY_NULLPTR nullptr
183
#   else
184
#    define YY_NULLPTR 0
185
#   endif
186
#  else
187
#   define YY_NULLPTR ((void*)0)
188
#  endif
189
# endif
190
191
/* Use api.header.include to #include this header
192
   instead of duplicating it here.  */
193
#ifndef YY_SUDOERS_Y_TAB_H_INCLUDED
194
# define YY_SUDOERS_Y_TAB_H_INCLUDED
195
/* Debug traces.  */
196
#ifndef YYDEBUG
197
# define YYDEBUG 0
198
#endif
199
#if YYDEBUG
200
extern int sudoersdebug;
201
#endif
202
203
/* Token kinds.  */
204
#ifndef YYTOKENTYPE
205
# define YYTOKENTYPE
206
  enum yytokentype
207
  {
208
    YYEMPTY = -2,
209
    YYEOF = 0,                     /* "end of file"  */
210
    YYerror = 256,                 /* error  */
211
    YYUNDEF = 257,                 /* "invalid token"  */
212
    COMMAND = 258,                 /* COMMAND  */
213
    ALIAS = 259,                   /* ALIAS  */
214
    DEFVAR = 260,                  /* DEFVAR  */
215
    NTWKADDR = 261,                /* NTWKADDR  */
216
    NETGROUP = 262,                /* NETGROUP  */
217
    USERGROUP = 263,               /* USERGROUP  */
218
    WORD = 264,                    /* WORD  */
219
    DIGEST = 265,                  /* DIGEST  */
220
    INCLUDE = 266,                 /* INCLUDE  */
221
    INCLUDEDIR = 267,              /* INCLUDEDIR  */
222
    DEFAULTS = 268,                /* DEFAULTS  */
223
    DEFAULTS_HOST = 269,           /* DEFAULTS_HOST  */
224
    DEFAULTS_USER = 270,           /* DEFAULTS_USER  */
225
    DEFAULTS_RUNAS = 271,          /* DEFAULTS_RUNAS  */
226
    DEFAULTS_CMND = 272,           /* DEFAULTS_CMND  */
227
    NOPASSWD = 273,                /* NOPASSWD  */
228
    PASSWD = 274,                  /* PASSWD  */
229
    NOEXEC = 275,                  /* NOEXEC  */
230
    EXEC = 276,                    /* EXEC  */
231
    SETENV = 277,                  /* SETENV  */
232
    NOSETENV = 278,                /* NOSETENV  */
233
    LOG_INPUT = 279,               /* LOG_INPUT  */
234
    NOLOG_INPUT = 280,             /* NOLOG_INPUT  */
235
    LOG_OUTPUT = 281,              /* LOG_OUTPUT  */
236
    NOLOG_OUTPUT = 282,            /* NOLOG_OUTPUT  */
237
    MAIL = 283,                    /* MAIL  */
238
    NOMAIL = 284,                  /* NOMAIL  */
239
    FOLLOWLNK = 285,               /* FOLLOWLNK  */
240
    NOFOLLOWLNK = 286,             /* NOFOLLOWLNK  */
241
    INTERCEPT = 287,               /* INTERCEPT  */
242
    NOINTERCEPT = 288,             /* NOINTERCEPT  */
243
    ALL = 289,                     /* ALL  */
244
    HOSTALIAS = 290,               /* HOSTALIAS  */
245
    CMNDALIAS = 291,               /* CMNDALIAS  */
246
    USERALIAS = 292,               /* USERALIAS  */
247
    RUNASALIAS = 293,              /* RUNASALIAS  */
248
    ERROR = 294,                   /* ERROR  */
249
    NOMATCH = 295,                 /* NOMATCH  */
250
    CHROOT = 296,                  /* CHROOT  */
251
    CWD = 297,                     /* CWD  */
252
    TYPE = 298,                    /* TYPE  */
253
    ROLE = 299,                    /* ROLE  */
254
    APPARMOR_PROFILE = 300,        /* APPARMOR_PROFILE  */
255
    PRIVS = 301,                   /* PRIVS  */
256
    LIMITPRIVS = 302,              /* LIMITPRIVS  */
257
    CMND_TIMEOUT = 303,            /* CMND_TIMEOUT  */
258
    NOTBEFORE = 304,               /* NOTBEFORE  */
259
    NOTAFTER = 305,                /* NOTAFTER  */
260
    MYSELF = 306,                  /* MYSELF  */
261
    SHA224_TOK = 307,              /* SHA224_TOK  */
262
    SHA256_TOK = 308,              /* SHA256_TOK  */
263
    SHA384_TOK = 309,              /* SHA384_TOK  */
264
    SHA512_TOK = 310               /* SHA512_TOK  */
265
  };
266
  typedef enum yytokentype yytoken_kind_t;
267
#endif
268
/* Token kinds.  */
269
4.99M
#define YYEMPTY -2
270
2.95M
#define YYEOF 0
271
2.56M
#define YYerror 256
272
0
#define YYUNDEF 257
273
871k
#define COMMAND 258
274
78.4k
#define ALIAS 259
275
#define DEFVAR 260
276
1.19k
#define NTWKADDR 261
277
664
#define NETGROUP 262
278
47.3k
#define USERGROUP 263
279
161k
#define WORD 264
280
#define DIGEST 265
281
#define INCLUDE 266
282
#define INCLUDEDIR 267
283
3.69k
#define DEFAULTS 268
284
506
#define DEFAULTS_HOST 269
285
642
#define DEFAULTS_USER 270
286
449
#define DEFAULTS_RUNAS 271
287
1.92k
#define DEFAULTS_CMND 272
288
#define NOPASSWD 273
289
#define PASSWD 274
290
#define NOEXEC 275
291
#define EXEC 276
292
#define SETENV 277
293
#define NOSETENV 278
294
#define LOG_INPUT 279
295
#define NOLOG_INPUT 280
296
#define LOG_OUTPUT 281
297
#define NOLOG_OUTPUT 282
298
#define MAIL 283
299
#define NOMAIL 284
300
#define FOLLOWLNK 285
301
#define NOFOLLOWLNK 286
302
#define INTERCEPT 287
303
#define NOINTERCEPT 288
304
875k
#define ALL 289
305
1.23k
#define HOSTALIAS 290
306
5.32k
#define CMNDALIAS 291
307
1.29k
#define USERALIAS 292
308
1.51k
#define RUNASALIAS 293
309
99.5k
#define ERROR 294
310
#define NOMATCH 295
311
#define CHROOT 296
312
#define CWD 297
313
#define TYPE 298
314
#define ROLE 299
315
#define APPARMOR_PROFILE 300
316
#define PRIVS 301
317
#define LIMITPRIVS 302
318
#define CMND_TIMEOUT 303
319
#define NOTBEFORE 304
320
#define NOTAFTER 305
321
17.2k
#define MYSELF 306
322
#define SHA224_TOK 307
323
#define SHA256_TOK 308
324
#define SHA384_TOK 309
325
#define SHA512_TOK 310
326
327
/* Value type.  */
328
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
329
union YYSTYPE
330
{
331
#line 91 "gram.y"
332
333
    struct cmndspec *cmndspec;
334
    struct defaults *defaults;
335
    struct member *member;
336
    struct runascontainer *runas;
337
    struct privilege *privilege;
338
    struct command_digest *digest;
339
    struct sudo_command command;
340
    struct command_options options;
341
    struct cmndtag tag;
342
    char *string;
343
    const char *cstring;
344
    int tok;
345
346
#line 346 "gram.c"
347
348
};
349
typedef union YYSTYPE YYSTYPE;
350
# define YYSTYPE_IS_TRIVIAL 1
351
# define YYSTYPE_IS_DECLARED 1
352
#endif
353
354
355
extern YYSTYPE sudoerslval;
356
357
358
int sudoersparse (void);
359
360
361
#endif /* !YY_SUDOERS_Y_TAB_H_INCLUDED  */
362
/* Symbol kind.  */
363
enum yysymbol_kind_t
364
{
365
  YYSYMBOL_YYEMPTY = -2,
366
  YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
367
  YYSYMBOL_YYerror = 1,                    /* error  */
368
  YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
369
  YYSYMBOL_COMMAND = 3,                    /* COMMAND  */
370
  YYSYMBOL_ALIAS = 4,                      /* ALIAS  */
371
  YYSYMBOL_DEFVAR = 5,                     /* DEFVAR  */
372
  YYSYMBOL_NTWKADDR = 6,                   /* NTWKADDR  */
373
  YYSYMBOL_NETGROUP = 7,                   /* NETGROUP  */
374
  YYSYMBOL_USERGROUP = 8,                  /* USERGROUP  */
375
  YYSYMBOL_WORD = 9,                       /* WORD  */
376
  YYSYMBOL_DIGEST = 10,                    /* DIGEST  */
377
  YYSYMBOL_INCLUDE = 11,                   /* INCLUDE  */
378
  YYSYMBOL_INCLUDEDIR = 12,                /* INCLUDEDIR  */
379
  YYSYMBOL_DEFAULTS = 13,                  /* DEFAULTS  */
380
  YYSYMBOL_DEFAULTS_HOST = 14,             /* DEFAULTS_HOST  */
381
  YYSYMBOL_DEFAULTS_USER = 15,             /* DEFAULTS_USER  */
382
  YYSYMBOL_DEFAULTS_RUNAS = 16,            /* DEFAULTS_RUNAS  */
383
  YYSYMBOL_DEFAULTS_CMND = 17,             /* DEFAULTS_CMND  */
384
  YYSYMBOL_NOPASSWD = 18,                  /* NOPASSWD  */
385
  YYSYMBOL_PASSWD = 19,                    /* PASSWD  */
386
  YYSYMBOL_NOEXEC = 20,                    /* NOEXEC  */
387
  YYSYMBOL_EXEC = 21,                      /* EXEC  */
388
  YYSYMBOL_SETENV = 22,                    /* SETENV  */
389
  YYSYMBOL_NOSETENV = 23,                  /* NOSETENV  */
390
  YYSYMBOL_LOG_INPUT = 24,                 /* LOG_INPUT  */
391
  YYSYMBOL_NOLOG_INPUT = 25,               /* NOLOG_INPUT  */
392
  YYSYMBOL_LOG_OUTPUT = 26,                /* LOG_OUTPUT  */
393
  YYSYMBOL_NOLOG_OUTPUT = 27,              /* NOLOG_OUTPUT  */
394
  YYSYMBOL_MAIL = 28,                      /* MAIL  */
395
  YYSYMBOL_NOMAIL = 29,                    /* NOMAIL  */
396
  YYSYMBOL_FOLLOWLNK = 30,                 /* FOLLOWLNK  */
397
  YYSYMBOL_NOFOLLOWLNK = 31,               /* NOFOLLOWLNK  */
398
  YYSYMBOL_INTERCEPT = 32,                 /* INTERCEPT  */
399
  YYSYMBOL_NOINTERCEPT = 33,               /* NOINTERCEPT  */
400
  YYSYMBOL_ALL = 34,                       /* ALL  */
401
  YYSYMBOL_HOSTALIAS = 35,                 /* HOSTALIAS  */
402
  YYSYMBOL_CMNDALIAS = 36,                 /* CMNDALIAS  */
403
  YYSYMBOL_USERALIAS = 37,                 /* USERALIAS  */
404
  YYSYMBOL_RUNASALIAS = 38,                /* RUNASALIAS  */
405
  YYSYMBOL_39_ = 39,                       /* ':'  */
406
  YYSYMBOL_40_ = 40,                       /* '='  */
407
  YYSYMBOL_41_ = 41,                       /* ','  */
408
  YYSYMBOL_42_ = 42,                       /* '!'  */
409
  YYSYMBOL_43_ = 43,                       /* '+'  */
410
  YYSYMBOL_44_ = 44,                       /* '-'  */
411
  YYSYMBOL_45_ = 45,                       /* '('  */
412
  YYSYMBOL_46_ = 46,                       /* ')'  */
413
  YYSYMBOL_47_n_ = 47,                     /* '\n'  */
414
  YYSYMBOL_ERROR = 48,                     /* ERROR  */
415
  YYSYMBOL_NOMATCH = 49,                   /* NOMATCH  */
416
  YYSYMBOL_CHROOT = 50,                    /* CHROOT  */
417
  YYSYMBOL_CWD = 51,                       /* CWD  */
418
  YYSYMBOL_TYPE = 52,                      /* TYPE  */
419
  YYSYMBOL_ROLE = 53,                      /* ROLE  */
420
  YYSYMBOL_APPARMOR_PROFILE = 54,          /* APPARMOR_PROFILE  */
421
  YYSYMBOL_PRIVS = 55,                     /* PRIVS  */
422
  YYSYMBOL_LIMITPRIVS = 56,                /* LIMITPRIVS  */
423
  YYSYMBOL_CMND_TIMEOUT = 57,              /* CMND_TIMEOUT  */
424
  YYSYMBOL_NOTBEFORE = 58,                 /* NOTBEFORE  */
425
  YYSYMBOL_NOTAFTER = 59,                  /* NOTAFTER  */
426
  YYSYMBOL_MYSELF = 60,                    /* MYSELF  */
427
  YYSYMBOL_SHA224_TOK = 61,                /* SHA224_TOK  */
428
  YYSYMBOL_SHA256_TOK = 62,                /* SHA256_TOK  */
429
  YYSYMBOL_SHA384_TOK = 63,                /* SHA384_TOK  */
430
  YYSYMBOL_SHA512_TOK = 64,                /* SHA512_TOK  */
431
  YYSYMBOL_YYACCEPT = 65,                  /* $accept  */
432
  YYSYMBOL_file = 66,                      /* file  */
433
  YYSYMBOL_line = 67,                      /* line  */
434
  YYSYMBOL_entry = 68,                     /* entry  */
435
  YYSYMBOL_include = 69,                   /* include  */
436
  YYSYMBOL_includedir = 70,                /* includedir  */
437
  YYSYMBOL_defaults_list = 71,             /* defaults_list  */
438
  YYSYMBOL_defaults_entry = 72,            /* defaults_entry  */
439
  YYSYMBOL_privileges = 73,                /* privileges  */
440
  YYSYMBOL_privilege = 74,                 /* privilege  */
441
  YYSYMBOL_ophost = 75,                    /* ophost  */
442
  YYSYMBOL_host = 76,                      /* host  */
443
  YYSYMBOL_cmndspeclist = 77,              /* cmndspeclist  */
444
  YYSYMBOL_cmndspec = 78,                  /* cmndspec  */
445
  YYSYMBOL_digestspec = 79,                /* digestspec  */
446
  YYSYMBOL_digestlist = 80,                /* digestlist  */
447
  YYSYMBOL_digcmnd = 81,                   /* digcmnd  */
448
  YYSYMBOL_opcmnd = 82,                    /* opcmnd  */
449
  YYSYMBOL_chdirspec = 83,                 /* chdirspec  */
450
  YYSYMBOL_chrootspec = 84,                /* chrootspec  */
451
  YYSYMBOL_timeoutspec = 85,               /* timeoutspec  */
452
  YYSYMBOL_notbeforespec = 86,             /* notbeforespec  */
453
  YYSYMBOL_notafterspec = 87,              /* notafterspec  */
454
  YYSYMBOL_rolespec = 88,                  /* rolespec  */
455
  YYSYMBOL_typespec = 89,                  /* typespec  */
456
  YYSYMBOL_apparmor_profilespec = 90,      /* apparmor_profilespec  */
457
  YYSYMBOL_privsspec = 91,                 /* privsspec  */
458
  YYSYMBOL_limitprivsspec = 92,            /* limitprivsspec  */
459
  YYSYMBOL_runasspec = 93,                 /* runasspec  */
460
  YYSYMBOL_runaslist = 94,                 /* runaslist  */
461
  YYSYMBOL_reserved_word = 95,             /* reserved_word  */
462
  YYSYMBOL_reserved_alias = 96,            /* reserved_alias  */
463
  YYSYMBOL_options = 97,                   /* options  */
464
  YYSYMBOL_cmndtag = 98,                   /* cmndtag  */
465
  YYSYMBOL_cmnd = 99,                      /* cmnd  */
466
  YYSYMBOL_hostaliases = 100,              /* hostaliases  */
467
  YYSYMBOL_hostalias = 101,                /* hostalias  */
468
  YYSYMBOL_102_1 = 102,                    /* $@1  */
469
  YYSYMBOL_hostlist = 103,                 /* hostlist  */
470
  YYSYMBOL_cmndaliases = 104,              /* cmndaliases  */
471
  YYSYMBOL_cmndalias = 105,                /* cmndalias  */
472
  YYSYMBOL_106_2 = 106,                    /* $@2  */
473
  YYSYMBOL_cmndlist = 107,                 /* cmndlist  */
474
  YYSYMBOL_runasaliases = 108,             /* runasaliases  */
475
  YYSYMBOL_runasalias = 109,               /* runasalias  */
476
  YYSYMBOL_110_3 = 110,                    /* $@3  */
477
  YYSYMBOL_useraliases = 111,              /* useraliases  */
478
  YYSYMBOL_useralias = 112,                /* useralias  */
479
  YYSYMBOL_113_4 = 113,                    /* $@4  */
480
  YYSYMBOL_userlist = 114,                 /* userlist  */
481
  YYSYMBOL_opuser = 115,                   /* opuser  */
482
  YYSYMBOL_user = 116,                     /* user  */
483
  YYSYMBOL_grouplist = 117,                /* grouplist  */
484
  YYSYMBOL_opgroup = 118,                  /* opgroup  */
485
  YYSYMBOL_group = 119                     /* group  */
486
};
487
typedef enum yysymbol_kind_t yysymbol_kind_t;
488
489
490
491
492
#ifdef short
493
# undef short
494
#endif
495
496
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
497
   <limits.h> and (if available) <stdint.h> are included
498
   so that the code can choose integer types of a good width.  */
499
500
#ifndef __PTRDIFF_MAX__
501
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
502
# if defined HAVE_STDINT_H
503
#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
504
#  define YY_STDINT_H
505
# endif
506
#endif
507
508
/* Narrow types that promote to a signed type and that can represent a
509
   signed or unsigned integer of at least N bits.  In tables they can
510
   save space and decrease cache pressure.  Promoting to a signed type
511
   helps avoid bugs in integer arithmetic.  */
512
513
#ifdef __INT_LEAST8_MAX__
514
typedef __INT_LEAST8_TYPE__ yytype_int8;
515
#elif defined YY_STDINT_H
516
typedef int_least8_t yytype_int8;
517
#else
518
typedef signed char yytype_int8;
519
#endif
520
521
#ifdef __INT_LEAST16_MAX__
522
typedef __INT_LEAST16_TYPE__ yytype_int16;
523
#elif defined YY_STDINT_H
524
typedef int_least16_t yytype_int16;
525
#else
526
typedef short yytype_int16;
527
#endif
528
529
/* Work around bug in HP-UX 11.23, which defines these macros
530
   incorrectly for preprocessor constants.  This workaround can likely
531
   be removed in 2023, as HPE has promised support for HP-UX 11.23
532
   (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
533
   <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
534
#ifdef __hpux
535
# undef UINT_LEAST8_MAX
536
# undef UINT_LEAST16_MAX
537
# define UINT_LEAST8_MAX 255
538
# define UINT_LEAST16_MAX 65535
539
#endif
540
541
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
542
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
543
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
544
       && UINT_LEAST8_MAX <= INT_MAX)
545
typedef uint_least8_t yytype_uint8;
546
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
547
typedef unsigned char yytype_uint8;
548
#else
549
typedef short yytype_uint8;
550
#endif
551
552
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
553
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
554
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
555
       && UINT_LEAST16_MAX <= INT_MAX)
556
typedef uint_least16_t yytype_uint16;
557
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
558
typedef unsigned short yytype_uint16;
559
#else
560
typedef int yytype_uint16;
561
#endif
562
563
#ifndef YYPTRDIFF_T
564
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
565
12.7k
#  define YYPTRDIFF_T __PTRDIFF_TYPE__
566
#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
567
# elif defined PTRDIFF_MAX
568
#  ifndef ptrdiff_t
569
#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
570
#  endif
571
#  define YYPTRDIFF_T ptrdiff_t
572
#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
573
# else
574
#  define YYPTRDIFF_T long
575
#  define YYPTRDIFF_MAXIMUM LONG_MAX
576
# endif
577
#endif
578
579
#ifndef YYSIZE_T
580
# ifdef __SIZE_TYPE__
581
#  define YYSIZE_T __SIZE_TYPE__
582
# elif defined size_t
583
#  define YYSIZE_T size_t
584
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
585
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
586
#  define YYSIZE_T size_t
587
# else
588
#  define YYSIZE_T unsigned
589
# endif
590
#endif
591
592
#define YYSIZE_MAXIMUM                                  \
593
  YY_CAST (YYPTRDIFF_T,                                 \
594
           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
595
            ? YYPTRDIFF_MAXIMUM                         \
596
            : YY_CAST (YYSIZE_T, -1)))
597
598
0
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
599
600
601
/* Stored state numbers (used for stacks). */
602
typedef yytype_uint8 yy_state_t;
603
604
/* State numbers in computations.  */
605
typedef int yy_state_fast_t;
606
607
#ifndef YY_
608
# if defined YYENABLE_NLS && YYENABLE_NLS
609
#  if ENABLE_NLS
610
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
611
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
612
#  endif
613
# endif
614
# ifndef YY_
615
65.4k
#  define YY_(Msgid) Msgid
616
# endif
617
#endif
618
619
620
#ifndef YY_ATTRIBUTE_PURE
621
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
622
#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
623
# else
624
#  define YY_ATTRIBUTE_PURE
625
# endif
626
#endif
627
628
#ifndef YY_ATTRIBUTE_UNUSED
629
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
630
#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
631
# else
632
#  define YY_ATTRIBUTE_UNUSED
633
# endif
634
#endif
635
636
/* Suppress unused-variable warnings by "using" E.  */
637
#if ! defined lint || defined __GNUC__
638
1.99M
# define YY_USE(E) ((void) (E))
639
#else
640
# define YY_USE(E) /* empty */
641
#endif
642
643
/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
644
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
645
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
646
#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
647
    _Pragma ("GCC diagnostic push")                                     \
648
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
649
# else
650
#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
651
    _Pragma ("GCC diagnostic push")                                     \
652
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
653
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
654
# endif
655
# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
656
    _Pragma ("GCC diagnostic pop")
657
#else
658
# define YY_INITIAL_VALUE(Value) Value
659
#endif
660
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
661
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
662
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
663
#endif
664
#ifndef YY_INITIAL_VALUE
665
# define YY_INITIAL_VALUE(Value) /* Nothing. */
666
#endif
667
668
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
669
# define YY_IGNORE_USELESS_CAST_BEGIN                          \
670
    _Pragma ("GCC diagnostic push")                            \
671
    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
672
# define YY_IGNORE_USELESS_CAST_END            \
673
    _Pragma ("GCC diagnostic pop")
674
#endif
675
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
676
# define YY_IGNORE_USELESS_CAST_BEGIN
677
# define YY_IGNORE_USELESS_CAST_END
678
#endif
679
680
681
4.61M
#define YY_ASSERT(E) ((void) (0 && (E)))
682
683
#if !defined yyoverflow
684
685
/* The parser invokes alloca or malloc; define the necessary symbols.  */
686
687
# ifdef YYSTACK_USE_ALLOCA
688
#  if YYSTACK_USE_ALLOCA
689
#   ifdef __GNUC__
690
#    define YYSTACK_ALLOC __builtin_alloca
691
#   elif defined __BUILTIN_VA_ARG_INCR
692
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
693
#   elif defined _AIX
694
#    define YYSTACK_ALLOC __alloca
695
#   elif defined _MSC_VER
696
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
697
#    define alloca _alloca
698
#   else
699
#    define YYSTACK_ALLOC alloca
700
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
701
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
702
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
703
#     ifndef EXIT_SUCCESS
704
#      define EXIT_SUCCESS 0
705
#     endif
706
#    endif
707
#   endif
708
#  endif
709
# endif
710
711
# ifdef YYSTACK_ALLOC
712
   /* Pacify GCC's 'empty if-body' warning.  */
713
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
714
#  ifndef YYSTACK_ALLOC_MAXIMUM
715
    /* The OS might guarantee only one guard page at the bottom of the stack,
716
       and a page size can be as small as 4096 bytes.  So we cannot safely
717
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
718
       to allow for a few compiler-allocated temporary stack slots.  */
719
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
720
#  endif
721
# else
722
#  define YYSTACK_ALLOC YYMALLOC
723
0
#  define YYSTACK_FREE YYFREE
724
#  ifndef YYSTACK_ALLOC_MAXIMUM
725
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
726
#  endif
727
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
728
       && ! ((defined YYMALLOC || defined malloc) \
729
             && (defined YYFREE || defined free)))
730
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
731
#   ifndef EXIT_SUCCESS
732
#    define EXIT_SUCCESS 0
733
#   endif
734
#  endif
735
#  ifndef YYMALLOC
736
#   define YYMALLOC malloc
737
#   if ! defined malloc && ! defined EXIT_SUCCESS
738
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
739
#   endif
740
#  endif
741
#  ifndef YYFREE
742
0
#   define YYFREE free
743
#   if ! defined free && ! defined EXIT_SUCCESS
744
void free (void *); /* INFRINGES ON USER NAME SPACE */
745
#   endif
746
#  endif
747
# endif
748
#endif /* !defined yyoverflow */
749
750
#if (! defined yyoverflow \
751
     && (! defined __cplusplus \
752
         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
753
754
/* A type that is properly aligned for any stack member.  */
755
union yyalloc
756
{
757
  yy_state_t yyss_alloc;
758
  YYSTYPE yyvs_alloc;
759
};
760
761
/* The size of the maximum gap between one aligned stack and the next.  */
762
0
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
763
764
/* The size of an array large to enough to hold all stacks, each with
765
   N elements.  */
766
# define YYSTACK_BYTES(N) \
767
     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
768
      + YYSTACK_GAP_MAXIMUM)
769
770
# define YYCOPY_NEEDED 1
771
772
/* Relocate STACK from its old location to the new one.  The
773
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
774
   elements in the stack, and YYPTR gives the new location of the
775
   stack.  Advance YYPTR to a properly aligned location for the next
776
   stack.  */
777
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
778
0
    do                                                                  \
779
0
      {                                                                 \
780
0
        YYPTRDIFF_T yynewbytes;                                         \
781
0
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
782
0
        Stack = &yyptr->Stack_alloc;                                    \
783
0
        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
784
0
        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
785
0
      }                                                                 \
786
0
    while (0)
787
788
#endif
789
790
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
791
/* Copy COUNT objects from SRC to DST.  The source and destination do
792
   not overlap.  */
793
# ifndef YYCOPY
794
#  if defined __GNUC__ && 1 < __GNUC__
795
#   define YYCOPY(Dst, Src, Count) \
796
0
      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
797
#  else
798
#   define YYCOPY(Dst, Src, Count)              \
799
      do                                        \
800
        {                                       \
801
          YYPTRDIFF_T yyi;                      \
802
          for (yyi = 0; yyi < (Count); yyi++)   \
803
            (Dst)[yyi] = (Src)[yyi];            \
804
        }                                       \
805
      while (0)
806
#  endif
807
# endif
808
#endif /* !YYCOPY_NEEDED */
809
810
/* YYFINAL -- State number of the termination state.  */
811
4.61M
#define YYFINAL  90
812
/* YYLAST -- Last index in YYTABLE.  */
813
8.99M
#define YYLAST   332
814
815
/* YYNTOKENS -- Number of terminals.  */
816
2.51M
#define YYNTOKENS  65
817
/* YYNNTS -- Number of nonterminals.  */
818
#define YYNNTS  55
819
/* YYNRULES -- Number of rules.  */
820
#define YYNRULES  155
821
/* YYNSTATES -- Number of states.  */
822
#define YYNSTATES  256
823
824
/* YYMAXUTOK -- Last valid token kind.  */
825
2.97M
#define YYMAXUTOK   310
826
827
828
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
829
   as returned by yylex, with out-of-bounds checking.  */
830
#define YYTRANSLATE(YYX)                                \
831
3.37M
  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
832
3.37M
   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
833
3.37M
   : YYSYMBOL_YYUNDEF)
834
835
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
836
   as returned by yylex.  */
837
static const yytype_int8 yytranslate[] =
838
{
839
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
840
      47,     2,     2,     2,     2,     2,     2,     2,     2,     2,
841
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
842
       2,     2,     2,    42,     2,     2,     2,     2,     2,     2,
843
      45,    46,     2,    43,    41,    44,     2,     2,     2,     2,
844
       2,     2,     2,     2,     2,     2,     2,     2,    39,     2,
845
       2,    40,     2,     2,     2,     2,     2,     2,     2,     2,
846
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
847
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
848
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
849
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
850
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
851
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
852
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
853
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
854
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
855
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
856
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
857
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
858
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
859
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
860
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
861
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
862
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
863
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
864
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
865
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
866
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
867
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
868
      35,    36,    37,    38,    48,    49,    50,    51,    52,    53,
869
      54,    55,    56,    57,    58,    59,    60,    61,    62,    63,
870
      64
871
};
872
873
#if YYDEBUG
874
/* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
875
static const yytype_int16 yyrline[] =
876
{
877
       0,   205,   205,   208,   211,   212,   215,   218,   221,   229,
878
     237,   243,   246,   249,   252,   255,   259,   263,   267,   271,
879
     277,   280,   286,   289,   295,   296,   303,   312,   321,   331,
880
     341,   353,   354,   359,   365,   382,   386,   392,   401,   409,
881
     418,   427,   438,   439,   449,   513,   522,   531,   540,   551,
882
     552,   559,   562,   576,   580,   586,   602,   624,   629,   633,
883
     638,   643,   648,   653,   657,   662,   665,   670,   687,   699,
884
     715,   733,   752,   753,   754,   755,   756,   757,   758,   759,
885
     760,   761,   762,   765,   771,   774,   779,   784,   793,   802,
886
     814,   819,   824,   829,   834,   841,   844,   847,   850,   853,
887
     856,   859,   862,   865,   868,   871,   874,   877,   880,   883,
888
     886,   889,   894,   908,   917,   938,   961,   962,   965,   965,
889
     977,   980,   981,   988,   989,   992,   992,  1004,  1007,  1008,
890
    1015,  1016,  1019,  1019,  1031,  1034,  1035,  1038,  1038,  1050,
891
    1053,  1054,  1061,  1065,  1071,  1080,  1088,  1097,  1106,  1117,
892
    1118,  1125,  1129,  1135,  1144,  1152
893
};
894
#endif
895
896
/** Accessing symbol of state STATE.  */
897
661k
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
898
899
#if YYDEBUG || 0
900
/* The user-facing name of the symbol whose (internal) number is
901
   YYSYMBOL.  No bounds checking.  */
902
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
903
904
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
905
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
906
static const char *const yytname[] =
907
{
908
  "\"end of file\"", "error", "\"invalid token\"", "COMMAND", "ALIAS",
909
  "DEFVAR", "NTWKADDR", "NETGROUP", "USERGROUP", "WORD", "DIGEST",
910
  "INCLUDE", "INCLUDEDIR", "DEFAULTS", "DEFAULTS_HOST", "DEFAULTS_USER",
911
  "DEFAULTS_RUNAS", "DEFAULTS_CMND", "NOPASSWD", "PASSWD", "NOEXEC",
912
  "EXEC", "SETENV", "NOSETENV", "LOG_INPUT", "NOLOG_INPUT", "LOG_OUTPUT",
913
  "NOLOG_OUTPUT", "MAIL", "NOMAIL", "FOLLOWLNK", "NOFOLLOWLNK",
914
  "INTERCEPT", "NOINTERCEPT", "ALL", "HOSTALIAS", "CMNDALIAS", "USERALIAS",
915
  "RUNASALIAS", "':'", "'='", "','", "'!'", "'+'", "'-'", "'('", "')'",
916
  "'\\n'", "ERROR", "NOMATCH", "CHROOT", "CWD", "TYPE", "ROLE",
917
  "APPARMOR_PROFILE", "PRIVS", "LIMITPRIVS", "CMND_TIMEOUT", "NOTBEFORE",
918
  "NOTAFTER", "MYSELF", "SHA224_TOK", "SHA256_TOK", "SHA384_TOK",
919
  "SHA512_TOK", "$accept", "file", "line", "entry", "include",
920
  "includedir", "defaults_list", "defaults_entry", "privileges",
921
  "privilege", "ophost", "host", "cmndspeclist", "cmndspec", "digestspec",
922
  "digestlist", "digcmnd", "opcmnd", "chdirspec", "chrootspec",
923
  "timeoutspec", "notbeforespec", "notafterspec", "rolespec", "typespec",
924
  "apparmor_profilespec", "privsspec", "limitprivsspec", "runasspec",
925
  "runaslist", "reserved_word", "reserved_alias", "options", "cmndtag",
926
  "cmnd", "hostaliases", "hostalias", "$@1", "hostlist", "cmndaliases",
927
  "cmndalias", "$@2", "cmndlist", "runasaliases", "runasalias", "$@3",
928
  "useraliases", "useralias", "$@4", "userlist", "opuser", "user",
929
  "grouplist", "opgroup", "group", YY_NULLPTR
930
};
931
932
static const char *
933
yysymbol_name (yysymbol_kind_t yysymbol)
934
{
935
  return yytname[yysymbol];
936
}
937
#endif
938
939
5.67M
#define YYPACT_NINF (-116)
940
941
#define yypact_value_is_default(Yyn) \
942
5.67M
  ((Yyn) == YYPACT_NINF)
943
944
#define YYTABLE_NINF (-4)
945
946
#define yytable_value_is_error(Yyn) \
947
12.4k
  0
948
949
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
950
   STATE-NUM.  */
951
static const yytype_int16 yypact[] =
952
{
953
     174,   -29,  -116,  -116,  -116,  -116,    35,    38,    11,   239,
954
     150,   150,     8,  -116,    32,    76,    88,   114,   254,  -116,
955
      58,   218,  -116,  -116,  -116,    70,  -116,  -116,  -116,    12,
956
      13,   136,    73,    14,  -116,  -116,  -116,  -116,  -116,  -116,
957
     276,  -116,  -116,     4,    10,    10,  -116,  -116,  -116,  -116,
958
     190,    42,    81,    85,    97,  -116,    64,  -116,  -116,  -116,
959
      52,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,
960
    -116,  -116,  -116,  -116,    57,     2,  -116,  -116,   111,     9,
961
    -116,  -116,   112,    56,  -116,  -116,   123,    61,  -116,  -116,
962
    -116,  -116,   150,    62,  -116,    75,    90,  -116,   130,  -116,
963
     188,   204,   205,  -116,    11,  -116,  -116,   239,    55,    66,
964
     108,  -116,   207,   210,   213,   228,   143,  -116,     8,   155,
965
     175,   239,    32,  -116,   209,     8,    76,  -116,   211,   150,
966
      88,  -116,   217,   150,   114,  -116,  -116,   194,  -116,   202,
967
    -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,
968
    -116,  -116,  -116,  -116,  -116,  -116,  -116,   239,   225,  -116,
969
       8,   227,  -116,   150,   229,  -116,   150,   229,  -116,  -116,
970
    -116,   233,   230,  -116,  -116,   225,   227,   229,   229,   235,
971
     232,   121,   202,   240,  -116,  -116,  -116,   255,   238,  -116,
972
    -116,  -116,   235,  -116,   234,   236,   244,   246,   247,   260,
973
     261,   262,   263,   264,  -116,  -116,  -116,  -116,  -116,  -116,
974
    -116,  -116,  -116,  -116,     1,  -116,   235,   238,   241,   296,
975
     297,   298,   299,   300,   302,   303,   304,   305,  -116,  -116,
976
    -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,
977
    -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,
978
    -116,  -116,  -116,  -116,  -116,  -116
979
};
980
981
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
982
   Performed when YYTABLE does not specify something else to do.  Zero
983
   means the default is an error.  */
984
static const yytype_uint8 yydefact[] =
985
{
986
       0,     0,   144,   146,   147,   148,     0,     0,     0,     0,
987
       0,     0,     0,   145,     0,     0,     0,     0,     0,     6,
988
       0,     0,     4,     8,     9,     0,   140,   142,     7,     0,
989
       0,    26,     0,     0,    24,    37,    40,    39,    41,    38,
990
       0,   121,    35,     0,     0,     0,   114,   113,   115,   112,
991
       0,     0,     0,     0,     0,    49,     0,   128,    51,    53,
992
       0,   118,    72,    73,    74,    79,    78,    82,    80,    81,
993
      75,    76,    77,    83,     0,     0,   116,   125,     0,     0,
994
     123,   137,     0,     0,   135,   132,     0,     0,   130,   143,
995
       1,     5,     0,     0,    31,     0,     0,    20,     0,    22,
996
       0,     0,     0,    27,     0,    15,    36,     0,     0,     0,
997
       0,    54,     0,     0,     0,     0,     0,    52,     0,     0,
998
       0,     0,     0,    12,     0,     0,     0,    13,     0,     0,
999
       0,    11,     0,     0,     0,    14,   141,     0,    10,    65,
1000
      21,    23,    28,    29,    30,    25,   122,    18,    16,    17,
1001
      45,    46,    47,    48,    50,   129,    19,     0,   120,   117,
1002
       0,   127,   124,     0,   139,   136,     0,   134,   131,    33,
1003
      32,    67,    34,    42,    84,   119,   126,   138,   133,    71,
1004
       0,    68,    65,    95,   153,   155,   154,     0,    70,   149,
1005
     151,    66,     0,    43,     0,     0,     0,     0,     0,     0,
1006
       0,     0,     0,     0,    85,    86,    89,    87,    88,    90,
1007
      91,    92,    93,    94,     0,   152,     0,    69,     0,     0,
1008
       0,     0,     0,     0,     0,     0,     0,     0,    96,    97,
1009
      98,    99,   102,   103,   104,   105,   106,   107,   110,   111,
1010
     108,   109,   100,   101,    44,   150,    56,    55,    61,    60,
1011
      62,    63,    64,    57,    58,    59
1012
};
1013
1014
/* YYPGOTO[NTERM-NUM].  */
1015
static const yytype_int16 yypgoto[] =
1016
{
1017
    -116,  -116,  -116,   294,  -116,  -116,    -6,   212,  -116,   180,
1018
     214,   278,  -116,   137,   206,  -116,  -115,   267,  -116,  -116,
1019
    -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,  -116,
1020
    -116,    -9,  -116,  -116,   270,  -116,   203,  -116,    -7,  -116,
1021
     198,  -116,   -85,  -116,   192,  -116,  -116,   197,  -116,   -10,
1022
     237,   310,   138,   115,   145
1023
};
1024
1025
/* YYDEFGOTO[NTERM-NUM].  */
1026
static const yytype_uint8 yydefgoto[] =
1027
{
1028
       0,    20,    21,    22,    23,    24,    33,    34,    93,    94,
1029
      41,    42,   172,   173,    55,    56,    57,    58,   204,   205,
1030
     206,   207,   208,   209,   210,   211,   212,   213,   174,   180,
1031
      73,    74,   183,   214,    59,    75,    76,   120,    95,    79,
1032
      80,   124,    60,    87,    88,   132,    83,    84,   128,    25,
1033
      26,    27,   188,   189,   190
1034
};
1035
1036
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
1037
   positive, shift that token.  If negative, reduce the rule whose
1038
   number is the opposite.  If YYTABLE_NINF, syntax error.  */
1039
static const yytype_int16 yytable[] =
1040
{
1041
      44,    45,    43,   155,    46,    47,    78,    82,    86,    31,
1042
      48,    46,    47,    96,    98,    31,    31,    48,    28,   228,
1043
     229,   230,   231,   232,   233,   234,   235,   236,   237,   238,
1044
     239,   240,   241,   242,   243,    49,    61,   108,   109,   110,
1045
     161,   122,    49,    50,    29,   107,    32,    30,   126,   123,
1046
      50,    92,    32,    32,   119,   104,   127,    31,    90,    97,
1047
      99,   105,    51,    52,    53,    54,    62,    46,    47,    51,
1048
      52,    53,    54,    48,    35,   176,    36,    37,   103,    38,
1049
      77,   112,    63,    64,    65,    66,    67,    68,    69,    70,
1050
      71,    72,    81,   118,    32,   130,   104,   121,    49,   244,
1051
     134,   137,   147,   131,    39,   116,    50,   104,   135,   138,
1052
      62,    92,    40,   148,   158,   139,   107,    78,    85,   164,
1053
     113,    82,    62,   167,   114,    86,    63,    64,    65,    66,
1054
      67,    68,    69,    70,    71,    72,   115,   140,    63,    64,
1055
      65,    66,    67,    68,    69,    70,    71,    72,    62,   104,
1056
     175,   125,   129,   177,     2,   149,   178,     3,     4,     5,
1057
     192,   181,    92,   133,    63,    64,    65,    66,    67,    68,
1058
      69,    70,    71,    72,    -2,     1,   100,   141,     2,   101,
1059
     102,     3,     4,     5,    13,     6,     7,     8,     9,    10,
1060
      11,    12,    18,    46,    47,   169,   104,   142,    35,    48,
1061
      36,    37,   156,    38,    51,    52,    53,    54,    13,    14,
1062
      15,    16,    17,   143,   144,   157,    18,   150,    -3,     1,
1063
     151,    19,     2,   152,    49,     3,     4,     5,    39,     6,
1064
       7,     8,     9,    10,    11,    12,    40,     2,   153,   184,
1065
       3,     4,     5,    35,   185,    36,    37,   171,    38,   160,
1066
     246,   163,    13,    14,    15,    16,    17,   166,     2,   184,
1067
      18,     3,     4,     5,   185,    19,   107,    13,   118,   186,
1068
      92,   182,   179,    39,   218,    18,   219,   187,   191,   216,
1069
      35,    40,    36,    37,   220,    38,   221,   222,    13,   186,
1070
     194,   195,   196,   197,   198,   199,   200,   201,   202,   203,
1071
     223,   224,   225,   226,   227,   247,   248,   249,   250,   251,
1072
      39,   252,   253,   254,   255,    91,   145,   170,   106,   193,
1073
     111,   146,   154,   117,   162,   159,   168,   165,    89,   136,
1074
     217,   245,   215
1075
};
1076
1077
static const yytype_uint8 yycheck[] =
1078
{
1079
      10,    11,     9,   118,     3,     4,    15,    16,    17,     5,
1080
       9,     3,     4,     1,     1,     5,     5,     9,    47,    18,
1081
      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
1082
      29,    30,    31,    32,    33,    34,     4,    43,    44,    45,
1083
     125,    39,    34,    42,     9,    41,    42,     9,    39,    47,
1084
      42,    41,    42,    42,    60,    41,    47,     5,     0,    47,
1085
      47,    47,    61,    62,    63,    64,    34,     3,     4,    61,
1086
      62,    63,    64,     9,     4,   160,     6,     7,     5,     9,
1087
       4,    39,    50,    51,    52,    53,    54,    55,    56,    57,
1088
      58,    59,     4,    41,    42,    39,    41,    40,    34,   214,
1089
      39,    39,    47,    47,    34,    41,    42,    41,    47,    47,
1090
      34,    41,    42,    47,   121,    40,    41,   126,     4,   129,
1091
      39,   130,    34,   133,    39,   134,    50,    51,    52,    53,
1092
      54,    55,    56,    57,    58,    59,    39,    47,    50,    51,
1093
      52,    53,    54,    55,    56,    57,    58,    59,    34,    41,
1094
     157,    40,    40,   163,     4,    47,   166,     7,     8,     9,
1095
      39,   171,    41,    40,    50,    51,    52,    53,    54,    55,
1096
      56,    57,    58,    59,     0,     1,    40,    47,     4,    43,
1097
      44,     7,     8,     9,    34,    11,    12,    13,    14,    15,
1098
      16,    17,    42,     3,     4,     1,    41,     9,     4,     9,
1099
       6,     7,    47,     9,    61,    62,    63,    64,    34,    35,
1100
      36,    37,    38,     9,     9,    40,    42,    10,     0,     1,
1101
      10,    47,     4,    10,    34,     7,     8,     9,    34,    11,
1102
      12,    13,    14,    15,    16,    17,    42,     4,    10,     4,
1103
       7,     8,     9,     4,     9,     6,     7,    45,     9,    40,
1104
       9,    40,    34,    35,    36,    37,    38,    40,     4,     4,
1105
      42,     7,     8,     9,     9,    47,    41,    34,    41,    34,
1106
      41,    41,    39,    34,    40,    42,    40,    42,    46,    41,
1107
       4,    42,     6,     7,    40,     9,    40,    40,    34,    34,
1108
      50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
1109
      40,    40,    40,    40,    40,     9,     9,     9,     9,     9,
1110
      34,     9,     9,     9,     9,    21,   104,   137,    40,   182,
1111
      50,   107,   116,    56,   126,   122,   134,   130,    18,    92,
1112
     192,   216,   187
1113
};
1114
1115
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
1116
   state STATE-NUM.  */
1117
static const yytype_int8 yystos[] =
1118
{
1119
       0,     1,     4,     7,     8,     9,    11,    12,    13,    14,
1120
      15,    16,    17,    34,    35,    36,    37,    38,    42,    47,
1121
      66,    67,    68,    69,    70,   114,   115,   116,    47,     9,
1122
       9,     5,    42,    71,    72,     4,     6,     7,     9,    34,
1123
      42,    75,    76,   103,   114,   114,     3,     4,     9,    34,
1124
      42,    61,    62,    63,    64,    79,    80,    81,    82,    99,
1125
     107,     4,    34,    50,    51,    52,    53,    54,    55,    56,
1126
      57,    58,    59,    95,    96,   100,   101,     4,    96,   104,
1127
     105,     4,    96,   111,   112,     4,    96,   108,   109,   116,
1128
       0,    68,    41,    73,    74,   103,     1,    47,     1,    47,
1129
      40,    43,    44,     5,    41,    47,    76,    41,    71,    71,
1130
      71,    99,    39,    39,    39,    39,    41,    82,    41,    71,
1131
     102,    40,    39,    47,   106,    40,    39,    47,   113,    40,
1132
      39,    47,   110,    40,    39,    47,   115,    39,    47,    40,
1133
      47,    47,     9,     9,     9,    72,    75,    47,    47,    47,
1134
      10,    10,    10,    10,    79,    81,    47,    40,   103,   101,
1135
      40,   107,   105,    40,   114,   112,    40,   114,   109,     1,
1136
      74,    45,    77,    78,    93,   103,   107,   114,   114,    39,
1137
      94,   114,    41,    97,     4,     9,    34,    42,   117,   118,
1138
     119,    46,    39,    78,    50,    51,    52,    53,    54,    55,
1139
      56,    57,    58,    59,    83,    84,    85,    86,    87,    88,
1140
      89,    90,    91,    92,    98,   119,    41,   117,    40,    40,
1141
      40,    40,    40,    40,    40,    40,    40,    40,    18,    19,
1142
      20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
1143
      30,    31,    32,    33,    81,   118,     9,     9,     9,     9,
1144
       9,     9,     9,     9,     9,     9
1145
};
1146
1147
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
1148
static const yytype_int8 yyr1[] =
1149
{
1150
       0,    65,    66,    66,    67,    67,    68,    68,    68,    68,
1151
      68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
1152
      69,    69,    70,    70,    71,    71,    72,    72,    72,    72,
1153
      72,    73,    73,    73,    74,    75,    75,    76,    76,    76,
1154
      76,    76,    77,    77,    78,    79,    79,    79,    79,    80,
1155
      80,    81,    81,    82,    82,    83,    84,    85,    86,    87,
1156
      88,    89,    90,    91,    92,    93,    93,    94,    94,    94,
1157
      94,    94,    95,    95,    95,    95,    95,    95,    95,    95,
1158
      95,    95,    95,    96,    97,    97,    97,    97,    97,    97,
1159
      97,    97,    97,    97,    97,    98,    98,    98,    98,    98,
1160
      98,    98,    98,    98,    98,    98,    98,    98,    98,    98,
1161
      98,    98,    99,    99,    99,    99,   100,   100,   102,   101,
1162
     101,   103,   103,   104,   104,   106,   105,   105,   107,   107,
1163
     108,   108,   110,   109,   109,   111,   111,   113,   112,   112,
1164
     114,   114,   115,   115,   116,   116,   116,   116,   116,   117,
1165
     117,   118,   118,   119,   119,   119
1166
};
1167
1168
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
1169
static const yytype_int8 yyr2[] =
1170
{
1171
       0,     2,     0,     1,     1,     2,     1,     2,     1,     1,
1172
       3,     3,     3,     3,     3,     3,     4,     4,     4,     4,
1173
       3,     4,     3,     4,     1,     3,     1,     2,     3,     3,
1174
       3,     1,     3,     3,     3,     1,     2,     1,     1,     1,
1175
       1,     1,     1,     3,     4,     3,     3,     3,     3,     1,
1176
       3,     1,     2,     1,     2,     3,     3,     3,     3,     3,
1177
       3,     3,     3,     3,     3,     0,     3,     0,     1,     3,
1178
       2,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1179
       1,     1,     1,     1,     0,     2,     2,     2,     2,     2,
1180
       2,     2,     2,     2,     2,     0,     2,     2,     2,     2,
1181
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1182
       2,     2,     1,     1,     1,     1,     1,     3,     0,     4,
1183
       3,     1,     3,     1,     3,     0,     4,     3,     1,     3,
1184
       1,     3,     0,     4,     3,     1,     3,     0,     4,     3,
1185
       1,     3,     1,     2,     1,     1,     1,     1,     1,     1,
1186
       3,     1,     2,     1,     1,     1
1187
};
1188
1189
1190
enum { YYENOMEM = -2 };
1191
1192
105k
#define yyerrok         (yyerrstatus = 0)
1193
#define yyclearin       (yychar = YYEMPTY)
1194
1195
12.4k
#define YYACCEPT        goto yyacceptlab
1196
294
#define YYABORT         goto yyabortlab
1197
40.1k
#define YYERROR         goto yyerrorlab
1198
0
#define YYNOMEM         goto yyexhaustedlab
1199
1200
1201
#define YYRECOVERING()  (!!yyerrstatus)
1202
1203
#define YYBACKUP(Token, Value)                                    \
1204
  do                                                              \
1205
    if (yychar == YYEMPTY)                                        \
1206
      {                                                           \
1207
        yychar = (Token);                                         \
1208
        yylval = (Value);                                         \
1209
        YYPOPSTACK (yylen);                                       \
1210
        yystate = *yyssp;                                         \
1211
        goto yybackup;                                            \
1212
      }                                                           \
1213
    else                                                          \
1214
      {                                                           \
1215
        yyerror (YY_("syntax error: cannot back up")); \
1216
        YYERROR;                                                  \
1217
      }                                                           \
1218
  while (0)
1219
1220
/* Backward compatibility with an undocumented macro.
1221
   Use YYerror or YYUNDEF. */
1222
#define YYERRCODE YYUNDEF
1223
1224
1225
/* Enable debugging if requested.  */
1226
#if YYDEBUG
1227
1228
# ifndef YYFPRINTF
1229
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1230
#  define YYFPRINTF fprintf
1231
# endif
1232
1233
# define YYDPRINTF(Args)                        \
1234
do {                                            \
1235
  if (yydebug)                                  \
1236
    YYFPRINTF Args;                             \
1237
} while (0)
1238
1239
1240
1241
1242
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
1243
do {                                                                      \
1244
  if (yydebug)                                                            \
1245
    {                                                                     \
1246
      YYFPRINTF (stderr, "%s ", Title);                                   \
1247
      yy_symbol_print (stderr,                                            \
1248
                  Kind, Value); \
1249
      YYFPRINTF (stderr, "\n");                                           \
1250
    }                                                                     \
1251
} while (0)
1252
1253
1254
/*-----------------------------------.
1255
| Print this symbol's value on YYO.  |
1256
`-----------------------------------*/
1257
1258
static void
1259
yy_symbol_value_print (FILE *yyo,
1260
                       yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1261
{
1262
  FILE *yyoutput = yyo;
1263
  YY_USE (yyoutput);
1264
  if (!yyvaluep)
1265
    return;
1266
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1267
  YY_USE (yykind);
1268
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1269
}
1270
1271
1272
/*---------------------------.
1273
| Print this symbol on YYO.  |
1274
`---------------------------*/
1275
1276
static void
1277
yy_symbol_print (FILE *yyo,
1278
                 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1279
{
1280
  YYFPRINTF (yyo, "%s %s (",
1281
             yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1282
1283
  yy_symbol_value_print (yyo, yykind, yyvaluep);
1284
  YYFPRINTF (yyo, ")");
1285
}
1286
1287
/*------------------------------------------------------------------.
1288
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1289
| TOP (included).                                                   |
1290
`------------------------------------------------------------------*/
1291
1292
static void
1293
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1294
{
1295
  YYFPRINTF (stderr, "Stack now");
1296
  for (; yybottom <= yytop; yybottom++)
1297
    {
1298
      int yybot = *yybottom;
1299
      YYFPRINTF (stderr, " %d", yybot);
1300
    }
1301
  YYFPRINTF (stderr, "\n");
1302
}
1303
1304
# define YY_STACK_PRINT(Bottom, Top)                            \
1305
do {                                                            \
1306
  if (yydebug)                                                  \
1307
    yy_stack_print ((Bottom), (Top));                           \
1308
} while (0)
1309
1310
1311
/*------------------------------------------------.
1312
| Report that the YYRULE is going to be reduced.  |
1313
`------------------------------------------------*/
1314
1315
static void
1316
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1317
                 int yyrule)
1318
{
1319
  int yylno = yyrline[yyrule];
1320
  int yynrhs = yyr2[yyrule];
1321
  int yyi;
1322
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1323
             yyrule - 1, yylno);
1324
  /* The symbols being reduced.  */
1325
  for (yyi = 0; yyi < yynrhs; yyi++)
1326
    {
1327
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1328
      yy_symbol_print (stderr,
1329
                       YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1330
                       &yyvsp[(yyi + 1) - (yynrhs)]);
1331
      YYFPRINTF (stderr, "\n");
1332
    }
1333
}
1334
1335
# define YY_REDUCE_PRINT(Rule)          \
1336
do {                                    \
1337
  if (yydebug)                          \
1338
    yy_reduce_print (yyssp, yyvsp, Rule); \
1339
} while (0)
1340
1341
/* Nonzero means print parse trace.  It is left uninitialized so that
1342
   multiple parsers can coexist.  */
1343
int yydebug;
1344
#else /* !YYDEBUG */
1345
6.62M
# define YYDPRINTF(Args) ((void) 0)
1346
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1347
# define YY_STACK_PRINT(Bottom, Top)
1348
# define YY_REDUCE_PRINT(Rule)
1349
#endif /* !YYDEBUG */
1350
1351
1352
/* YYINITDEPTH -- initial size of the parser's stacks.  */
1353
#ifndef YYINITDEPTH
1354
12.7k
# define YYINITDEPTH 200
1355
#endif
1356
1357
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1358
   if the built-in stack extension method is used).
1359
1360
   Do not make this value too large; the results are undefined if
1361
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1362
   evaluated with infinite-precision integer arithmetic.  */
1363
1364
#ifndef YYMAXDEPTH
1365
0
# define YYMAXDEPTH 10000
1366
#endif
1367
1368
1369
1370
1371
1372
1373
/*-----------------------------------------------.
1374
| Release the memory associated to this symbol.  |
1375
`-----------------------------------------------*/
1376
1377
static void
1378
yydestruct (const char *yymsg,
1379
            yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
1380
999k
{
1381
999k
  YY_USE (yyvaluep);
1382
999k
  if (!yymsg)
1383
0
    yymsg = "Deleting";
1384
999k
  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1385
1386
999k
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1387
999k
  YY_USE (yykind);
1388
999k
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1389
999k
}
1390
1391
1392
/* Lookahead token kind.  */
1393
int yychar;
1394
1395
/* The semantic value of the lookahead symbol.  */
1396
YYSTYPE yylval;
1397
/* Number of syntax errors so far.  */
1398
int yynerrs;
1399
1400
1401
1402
1403
/*----------.
1404
| yyparse.  |
1405
`----------*/
1406
1407
int
1408
yyparse (void)
1409
12.7k
{
1410
12.7k
    yy_state_fast_t yystate = 0;
1411
    /* Number of tokens to shift before error messages enabled.  */
1412
12.7k
    int yyerrstatus = 0;
1413
1414
    /* Refer to the stacks through separate pointers, to allow yyoverflow
1415
       to reallocate them elsewhere.  */
1416
1417
    /* Their size.  */
1418
12.7k
    YYPTRDIFF_T yystacksize = YYINITDEPTH;
1419
1420
    /* The state stack: array, bottom, top.  */
1421
12.7k
    yy_state_t yyssa[YYINITDEPTH];
1422
12.7k
    yy_state_t *yyss = yyssa;
1423
12.7k
    yy_state_t *yyssp = yyss;
1424
1425
    /* The semantic value stack: array, bottom, top.  */
1426
12.7k
    YYSTYPE yyvsa[YYINITDEPTH];
1427
12.7k
    YYSTYPE *yyvs = yyvsa;
1428
12.7k
    YYSTYPE *yyvsp = yyvs;
1429
1430
12.7k
  int yyn;
1431
  /* The return value of yyparse.  */
1432
12.7k
  int yyresult;
1433
  /* Lookahead symbol kind.  */
1434
12.7k
  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1435
  /* The variables used to return semantic value and location from the
1436
     action routines.  */
1437
12.7k
  YYSTYPE yyval;
1438
1439
1440
1441
3.23M
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1442
1443
  /* The number of symbols on the RHS of the reduced rule.
1444
     Keep to zero when no symbol should be popped.  */
1445
12.7k
  int yylen = 0;
1446
1447
12.7k
  YYDPRINTF ((stderr, "Starting parse\n"));
1448
1449
12.7k
  yychar = YYEMPTY; /* Cause a token to be read.  */
1450
1451
12.7k
  goto yysetstate;
1452
1453
1454
/*------------------------------------------------------------.
1455
| yynewstate -- push a new state, which is found in yystate.  |
1456
`------------------------------------------------------------*/
1457
4.59M
yynewstate:
1458
  /* In all cases, when you get here, the value and location stacks
1459
     have just been pushed.  So pushing a state here evens the stacks.  */
1460
4.59M
  yyssp++;
1461
1462
1463
/*--------------------------------------------------------------------.
1464
| yysetstate -- set current state (the top of the stack) to yystate.  |
1465
`--------------------------------------------------------------------*/
1466
4.61M
yysetstate:
1467
4.61M
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1468
4.61M
  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1469
4.61M
  YY_IGNORE_USELESS_CAST_BEGIN
1470
4.61M
  *yyssp = YY_CAST (yy_state_t, yystate);
1471
4.61M
  YY_IGNORE_USELESS_CAST_END
1472
4.61M
  YY_STACK_PRINT (yyss, yyssp);
1473
1474
4.61M
  if (yyss + yystacksize - 1 <= yyssp)
1475
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1476
    YYNOMEM;
1477
#else
1478
0
    {
1479
      /* Get the current used size of the three stacks, in elements.  */
1480
0
      YYPTRDIFF_T yysize = yyssp - yyss + 1;
1481
1482
# if defined yyoverflow
1483
      {
1484
        /* Give user a chance to reallocate the stack.  Use copies of
1485
           these so that the &'s don't force the real ones into
1486
           memory.  */
1487
        yy_state_t *yyss1 = yyss;
1488
        YYSTYPE *yyvs1 = yyvs;
1489
1490
        /* Each stack pointer address is followed by the size of the
1491
           data in use in that stack, in bytes.  This used to be a
1492
           conditional around just the two extra args, but that might
1493
           be undefined if yyoverflow is a macro.  */
1494
        yyoverflow (YY_("memory exhausted"),
1495
                    &yyss1, yysize * YYSIZEOF (*yyssp),
1496
                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
1497
                    &yystacksize);
1498
        yyss = yyss1;
1499
        yyvs = yyvs1;
1500
      }
1501
# else /* defined YYSTACK_RELOCATE */
1502
      /* Extend the stack our own way.  */
1503
0
      if (YYMAXDEPTH <= yystacksize)
1504
0
        YYNOMEM;
1505
0
      yystacksize *= 2;
1506
0
      if (YYMAXDEPTH < yystacksize)
1507
0
        yystacksize = YYMAXDEPTH;
1508
1509
0
      {
1510
0
        yy_state_t *yyss1 = yyss;
1511
0
        union yyalloc *yyptr =
1512
0
          YY_CAST (union yyalloc *,
1513
0
                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1514
0
        if (! yyptr)
1515
0
          YYNOMEM;
1516
0
        YYSTACK_RELOCATE (yyss_alloc, yyss);
1517
0
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1518
0
#  undef YYSTACK_RELOCATE
1519
0
        if (yyss1 != yyssa)
1520
0
          YYSTACK_FREE (yyss1);
1521
0
      }
1522
0
# endif
1523
1524
0
      yyssp = yyss + yysize - 1;
1525
0
      yyvsp = yyvs + yysize - 1;
1526
1527
0
      YY_IGNORE_USELESS_CAST_BEGIN
1528
0
      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1529
0
                  YY_CAST (long, yystacksize)));
1530
0
      YY_IGNORE_USELESS_CAST_END
1531
1532
0
      if (yyss + yystacksize - 1 <= yyssp)
1533
0
        YYABORT;
1534
0
    }
1535
4.61M
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1536
1537
1538
4.61M
  if (yystate == YYFINAL)
1539
12.4k
    YYACCEPT;
1540
1541
4.59M
  goto yybackup;
1542
1543
1544
/*-----------.
1545
| yybackup.  |
1546
`-----------*/
1547
4.59M
yybackup:
1548
  /* Do appropriate processing given the current state.  Read a
1549
     lookahead token if we need one and don't already have one.  */
1550
1551
  /* First try to decide what to do without reference to lookahead token.  */
1552
4.59M
  yyn = yypact[yystate];
1553
4.59M
  if (yypact_value_is_default (yyn))
1554
2.00M
    goto yydefault;
1555
1556
  /* Not known => get a lookahead token if don't already have one.  */
1557
1558
  /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1559
2.59M
  if (yychar == YYEMPTY)
1560
1.97M
    {
1561
1.97M
      YYDPRINTF ((stderr, "Reading a token\n"));
1562
1.97M
      yychar = yylex ();
1563
1.97M
    }
1564
1565
2.59M
  if (yychar <= YYEOF)
1566
25.2k
    {
1567
25.2k
      yychar = YYEOF;
1568
25.2k
      yytoken = YYSYMBOL_YYEOF;
1569
25.2k
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1570
25.2k
    }
1571
2.56M
  else if (yychar == YYerror)
1572
0
    {
1573
      /* The scanner already issued an error message, process directly
1574
         to error recovery.  But do not keep the error token as
1575
         lookahead, it is too special and may lead us to an endless
1576
         loop in error recovery. */
1577
0
      yychar = YYUNDEF;
1578
0
      yytoken = YYSYMBOL_YYerror;
1579
0
      goto yyerrlab1;
1580
0
    }
1581
2.56M
  else
1582
2.56M
    {
1583
2.56M
      yytoken = YYTRANSLATE (yychar);
1584
2.56M
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1585
2.56M
    }
1586
1587
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1588
     detect an error, take that action.  */
1589
2.59M
  yyn += yytoken;
1590
2.59M
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1591
943k
    goto yydefault;
1592
1.64M
  yyn = yytable[yyn];
1593
1.64M
  if (yyn <= 0)
1594
12.4k
    {
1595
12.4k
      if (yytable_value_is_error (yyn))
1596
0
        goto yyerrlab;
1597
12.4k
      yyn = -yyn;
1598
12.4k
      goto yyreduce;
1599
12.4k
    }
1600
1601
  /* Count tokens shifted since error; after three, turn off error
1602
     status.  */
1603
1.63M
  if (yyerrstatus)
1604
100k
    yyerrstatus--;
1605
1606
  /* Shift the lookahead token.  */
1607
1.63M
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1608
1.63M
  yystate = yyn;
1609
1.63M
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1610
1.63M
  *++yyvsp = yylval;
1611
1.63M
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1612
1613
  /* Discard the shifted token.  */
1614
1.63M
  yychar = YYEMPTY;
1615
1.63M
  goto yynewstate;
1616
1617
1618
/*-----------------------------------------------------------.
1619
| yydefault -- do the default action for the current state.  |
1620
`-----------------------------------------------------------*/
1621
2.94M
yydefault:
1622
2.94M
  yyn = yydefact[yystate];
1623
2.94M
  if (yyn == 0)
1624
404k
    goto yyerrlab;
1625
2.54M
  goto yyreduce;
1626
1627
1628
/*-----------------------------.
1629
| yyreduce -- do a reduction.  |
1630
`-----------------------------*/
1631
2.55M
yyreduce:
1632
  /* yyn is the number of a rule to reduce with.  */
1633
2.55M
  yylen = yyr2[yyn];
1634
1635
  /* If YYLEN is nonzero, implement the default value of the action:
1636
     '$$ = $1'.
1637
1638
     Otherwise, the following line sets YYVAL to garbage.
1639
     This behavior is undocumented and Bison
1640
     users should not rely upon it.  Assigning to YYVAL
1641
     unconditionally makes the parser a bit smaller, and it avoids a
1642
     GCC warning that YYVAL may be used uninitialized.  */
1643
2.55M
  yyval = yyvsp[1-yylen];
1644
1645
1646
2.55M
  YY_REDUCE_PRINT (yyn);
1647
2.55M
  switch (yyn)
1648
2.55M
    {
1649
72
  case 2: /* file: %empty  */
1650
72
#line 205 "gram.y"
1651
72
                        {
1652
72
          ; /* empty file */
1653
72
      }
1654
72
#line 1654 "gram.c"
1655
72
    break;
1656
1657
48.8k
  case 6: /* entry: '\n'  */
1658
48.8k
#line 215 "gram.y"
1659
48.8k
                             {
1660
48.8k
          ; /* blank line */
1661
48.8k
      }
1662
48.8k
#line 1662 "gram.c"
1663
48.8k
    break;
1664
1665
99.4k
  case 7: /* entry: error '\n'  */
1666
99.4k
#line 218 "gram.y"
1667
99.4k
                                   {
1668
99.4k
          yyerrok;
1669
99.4k
      }
1670
99.4k
#line 1670 "gram.c"
1671
99.4k
    break;
1672
1673
2.12k
  case 8: /* entry: include  */
1674
2.12k
#line 221 "gram.y"
1675
2.12k
                                {
1676
2.12k
          const bool success = push_include((yyvsp[0].string),
1677
2.12k
        parsed_policy.ctx->user.shost, &parser_conf);
1678
2.12k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1679
2.12k
          free((yyvsp[0].string));
1680
2.12k
          if (!success && !parser_conf.recovery)
1681
2.12k
        YYERROR;
1682
2.12k
      }
1683
0
#line 1683 "gram.c"
1684
0
    break;
1685
1686
8.01k
  case 9: /* entry: includedir  */
1687
8.01k
#line 229 "gram.y"
1688
8.01k
                                   {
1689
8.01k
          const bool success = push_includedir((yyvsp[0].string),
1690
8.01k
        parsed_policy.ctx->user.shost, &parser_conf);
1691
8.01k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1692
8.01k
          free((yyvsp[0].string));
1693
8.01k
          if (!success && !parser_conf.recovery)
1694
194
        YYERROR;
1695
8.01k
      }
1696
7.82k
#line 1696 "gram.c"
1697
7.82k
    break;
1698
1699
15.0k
  case 10: /* entry: userlist privileges '\n'  */
1700
15.0k
#line 237 "gram.y"
1701
15.0k
                                                 {
1702
15.0k
          if (!add_userspec((yyvsp[-2].member), (yyvsp[-1].privilege))) {
1703
0
        sudoerserror(N_("unable to allocate memory"));
1704
0
        YYERROR;
1705
0
          }
1706
15.0k
      }
1707
15.0k
#line 1707 "gram.c"
1708
15.0k
    break;
1709
1710
15.0k
  case 11: /* entry: USERALIAS useraliases '\n'  */
1711
92
#line 243 "gram.y"
1712
92
                                                   {
1713
92
          ;
1714
92
      }
1715
92
#line 1715 "gram.c"
1716
92
    break;
1717
1718
225
  case 12: /* entry: HOSTALIAS hostaliases '\n'  */
1719
225
#line 246 "gram.y"
1720
225
                                                   {
1721
225
          ;
1722
225
      }
1723
225
#line 1723 "gram.c"
1724
225
    break;
1725
1726
472
  case 13: /* entry: CMNDALIAS cmndaliases '\n'  */
1727
472
#line 249 "gram.y"
1728
472
                                                   {
1729
472
          ;
1730
472
      }
1731
472
#line 1731 "gram.c"
1732
472
    break;
1733
1734
208
  case 14: /* entry: RUNASALIAS runasaliases '\n'  */
1735
208
#line 252 "gram.y"
1736
208
                                                     {
1737
208
          ;
1738
208
      }
1739
208
#line 1739 "gram.c"
1740
208
    break;
1741
1742
3.69k
  case 15: /* entry: DEFAULTS defaults_list '\n'  */
1743
3.69k
#line 255 "gram.y"
1744
3.69k
                                                    {
1745
3.69k
          if (!add_defaults(DEFAULTS, NULL, (yyvsp[-1].defaults)))
1746
0
        YYERROR;
1747
3.69k
      }
1748
3.69k
#line 1748 "gram.c"
1749
3.69k
    break;
1750
1751
3.69k
  case 16: /* entry: DEFAULTS_USER userlist defaults_list '\n'  */
1752
642
#line 259 "gram.y"
1753
642
                                                                  {
1754
642
          if (!add_defaults(DEFAULTS_USER, (yyvsp[-2].member), (yyvsp[-1].defaults)))
1755
0
        YYERROR;
1756
642
      }
1757
642
#line 1757 "gram.c"
1758
642
    break;
1759
1760
642
  case 17: /* entry: DEFAULTS_RUNAS userlist defaults_list '\n'  */
1761
449
#line 263 "gram.y"
1762
449
                                                                   {
1763
449
          if (!add_defaults(DEFAULTS_RUNAS, (yyvsp[-2].member), (yyvsp[-1].defaults)))
1764
0
        YYERROR;
1765
449
      }
1766
449
#line 1766 "gram.c"
1767
449
    break;
1768
1769
506
  case 18: /* entry: DEFAULTS_HOST hostlist defaults_list '\n'  */
1770
506
#line 267 "gram.y"
1771
506
                                                                  {
1772
506
          if (!add_defaults(DEFAULTS_HOST, (yyvsp[-2].member), (yyvsp[-1].defaults)))
1773
0
        YYERROR;
1774
506
      }
1775
506
#line 1775 "gram.c"
1776
506
    break;
1777
1778
1.92k
  case 19: /* entry: DEFAULTS_CMND cmndlist defaults_list '\n'  */
1779
1.92k
#line 271 "gram.y"
1780
1.92k
                                                                  {
1781
1.92k
          if (!add_defaults(DEFAULTS_CMND, (yyvsp[-2].member), (yyvsp[-1].defaults)))
1782
0
        YYERROR;
1783
1.92k
      }
1784
1.92k
#line 1784 "gram.c"
1785
1.92k
    break;
1786
1787
1.92k
  case 20: /* include: INCLUDE WORD '\n'  */
1788
1.68k
#line 277 "gram.y"
1789
1.68k
                                          {
1790
1.68k
          (yyval.string) = (yyvsp[-1].string);
1791
1.68k
      }
1792
1.68k
#line 1792 "gram.c"
1793
1.68k
    break;
1794
1795
434
  case 21: /* include: INCLUDE WORD error '\n'  */
1796
434
#line 280 "gram.y"
1797
434
                                                {
1798
434
          yyerrok;
1799
434
          (yyval.string) = (yyvsp[-2].string);
1800
434
      }
1801
434
#line 1801 "gram.c"
1802
434
    break;
1803
1804
7.78k
  case 22: /* includedir: INCLUDEDIR WORD '\n'  */
1805
7.78k
#line 286 "gram.y"
1806
7.78k
                                             {
1807
7.78k
          (yyval.string) = (yyvsp[-1].string);
1808
7.78k
      }
1809
7.78k
#line 1809 "gram.c"
1810
7.78k
    break;
1811
1812
238
  case 23: /* includedir: INCLUDEDIR WORD error '\n'  */
1813
238
#line 289 "gram.y"
1814
238
                                                   {
1815
238
          yyerrok;
1816
238
          (yyval.string) = (yyvsp[-2].string);
1817
238
      }
1818
238
#line 1818 "gram.c"
1819
238
    break;
1820
1821
347k
  case 25: /* defaults_list: defaults_list ',' defaults_entry  */
1822
347k
#line 296 "gram.y"
1823
347k
                                                         {
1824
347k
          parser_leak_remove(LEAK_DEFAULTS, (yyvsp[0].defaults));
1825
347k
          HLTQ_CONCAT((yyvsp[-2].defaults), (yyvsp[0].defaults), entries);
1826
347k
          (yyval.defaults) = (yyvsp[-2].defaults);
1827
347k
      }
1828
347k
#line 1828 "gram.c"
1829
347k
    break;
1830
1831
345k
  case 26: /* defaults_entry: DEFVAR  */
1832
345k
#line 303 "gram.y"
1833
345k
                               {
1834
345k
          (yyval.defaults) = new_default((yyvsp[0].string), NULL, true);
1835
345k
          if ((yyval.defaults) == NULL) {
1836
0
        sudoerserror(N_("unable to allocate memory"));
1837
0
        YYERROR;
1838
0
          }
1839
345k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1840
345k
          parser_leak_add(LEAK_DEFAULTS, (yyval.defaults));
1841
345k
      }
1842
0
#line 1842 "gram.c"
1843
0
    break;
1844
1845
1.36k
  case 27: /* defaults_entry: '!' DEFVAR  */
1846
1.36k
#line 312 "gram.y"
1847
1.36k
                                   {
1848
1.36k
          (yyval.defaults) = new_default((yyvsp[0].string), NULL, false);
1849
1.36k
          if ((yyval.defaults) == NULL) {
1850
0
        sudoerserror(N_("unable to allocate memory"));
1851
0
        YYERROR;
1852
0
          }
1853
1.36k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1854
1.36k
          parser_leak_add(LEAK_DEFAULTS, (yyval.defaults));
1855
1.36k
      }
1856
0
#line 1856 "gram.c"
1857
0
    break;
1858
1859
7.79k
  case 28: /* defaults_entry: DEFVAR '=' WORD  */
1860
7.79k
#line 321 "gram.y"
1861
7.79k
                                        {
1862
7.79k
          (yyval.defaults) = new_default((yyvsp[-2].string), (yyvsp[0].string), true);
1863
7.79k
          if ((yyval.defaults) == NULL) {
1864
0
        sudoerserror(N_("unable to allocate memory"));
1865
0
        YYERROR;
1866
0
          }
1867
7.79k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].string));
1868
7.79k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1869
7.79k
          parser_leak_add(LEAK_DEFAULTS, (yyval.defaults));
1870
7.79k
      }
1871
0
#line 1871 "gram.c"
1872
0
    break;
1873
1874
318
  case 29: /* defaults_entry: DEFVAR '+' WORD  */
1875
318
#line 331 "gram.y"
1876
318
                                        {
1877
318
          (yyval.defaults) = new_default((yyvsp[-2].string), (yyvsp[0].string), '+');
1878
318
          if ((yyval.defaults) == NULL) {
1879
0
        sudoerserror(N_("unable to allocate memory"));
1880
0
        YYERROR;
1881
0
          }
1882
318
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].string));
1883
318
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1884
318
          parser_leak_add(LEAK_DEFAULTS, (yyval.defaults));
1885
318
      }
1886
0
#line 1886 "gram.c"
1887
0
    break;
1888
1889
344
  case 30: /* defaults_entry: DEFVAR '-' WORD  */
1890
344
#line 341 "gram.y"
1891
344
                                        {
1892
344
          (yyval.defaults) = new_default((yyvsp[-2].string), (yyvsp[0].string), '-');
1893
344
          if ((yyval.defaults) == NULL) {
1894
0
        sudoerserror(N_("unable to allocate memory"));
1895
0
        YYERROR;
1896
0
          }
1897
344
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].string));
1898
344
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1899
344
          parser_leak_add(LEAK_DEFAULTS, (yyval.defaults));
1900
344
      }
1901
0
#line 1901 "gram.c"
1902
0
    break;
1903
1904
912
  case 32: /* privileges: privileges ':' privilege  */
1905
912
#line 354 "gram.y"
1906
912
                                                 {
1907
912
          parser_leak_remove(LEAK_PRIVILEGE, (yyvsp[0].privilege));
1908
912
          HLTQ_CONCAT((yyvsp[-2].privilege), (yyvsp[0].privilege), entries);
1909
912
          (yyval.privilege) = (yyvsp[-2].privilege);
1910
912
      }
1911
912
#line 1911 "gram.c"
1912
912
    break;
1913
1914
5.15k
  case 33: /* privileges: privileges ':' error  */
1915
5.15k
#line 359 "gram.y"
1916
5.15k
                                             {
1917
5.15k
          yyerrok;
1918
5.15k
          (yyval.privilege) = (yyvsp[-2].privilege);
1919
5.15k
      }
1920
5.15k
#line 1920 "gram.c"
1921
5.15k
    break;
1922
1923
19.2k
  case 34: /* privilege: hostlist '=' cmndspeclist  */
1924
19.2k
#line 365 "gram.y"
1925
19.2k
                                                  {
1926
19.2k
          struct privilege *p = calloc(1, sizeof(*p));
1927
19.2k
          if (p == NULL) {
1928
0
        sudoerserror(N_("unable to allocate memory"));
1929
0
        YYERROR;
1930
0
          }
1931
19.2k
          parser_leak_add(LEAK_PRIVILEGE, p);
1932
19.2k
          TAILQ_INIT(&p->defaults);
1933
19.2k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[-2].member));
1934
19.2k
          HLTQ_TO_TAILQ(&p->hostlist, (yyvsp[-2].member), entries);
1935
19.2k
          parser_leak_remove(LEAK_CMNDSPEC, (yyvsp[0].cmndspec));
1936
19.2k
          HLTQ_TO_TAILQ(&p->cmndlist, (yyvsp[0].cmndspec), entries);
1937
19.2k
          HLTQ_INIT(p, entries);
1938
19.2k
          (yyval.privilege) = p;
1939
19.2k
      }
1940
0
#line 1940 "gram.c"
1941
0
    break;
1942
1943
74.0k
  case 35: /* ophost: host  */
1944
74.0k
#line 382 "gram.y"
1945
74.0k
                             {
1946
74.0k
          (yyval.member) = (yyvsp[0].member);
1947
74.0k
          (yyval.member)->negated = false;
1948
74.0k
      }
1949
74.0k
#line 1949 "gram.c"
1950
74.0k
    break;
1951
1952
5.34k
  case 36: /* ophost: '!' host  */
1953
5.34k
#line 386 "gram.y"
1954
5.34k
                                 {
1955
5.34k
          (yyval.member) = (yyvsp[0].member);
1956
5.34k
          (yyval.member)->negated = true;
1957
5.34k
      }
1958
5.34k
#line 1958 "gram.c"
1959
5.34k
    break;
1960
1961
11.8k
  case 37: /* host: ALIAS  */
1962
11.8k
#line 392 "gram.y"
1963
11.8k
                              {
1964
11.8k
          (yyval.member) = new_member((yyvsp[0].string), ALIAS);
1965
11.8k
          if ((yyval.member) == NULL) {
1966
0
        sudoerserror(N_("unable to allocate memory"));
1967
0
        YYERROR;
1968
0
          }
1969
11.8k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1970
11.8k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
1971
11.8k
      }
1972
0
#line 1972 "gram.c"
1973
0
    break;
1974
1975
3.50k
  case 38: /* host: ALL  */
1976
3.50k
#line 401 "gram.y"
1977
3.50k
                            {
1978
3.50k
          (yyval.member) = new_member(NULL, ALL);
1979
3.50k
          if ((yyval.member) == NULL) {
1980
0
        sudoerserror(N_("unable to allocate memory"));
1981
0
        YYERROR;
1982
0
          }
1983
3.50k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
1984
3.50k
      }
1985
0
#line 1985 "gram.c"
1986
0
    break;
1987
1988
281
  case 39: /* host: NETGROUP  */
1989
281
#line 409 "gram.y"
1990
281
                                 {
1991
281
          (yyval.member) = new_member((yyvsp[0].string), NETGROUP);
1992
281
          if ((yyval.member) == NULL) {
1993
0
        sudoerserror(N_("unable to allocate memory"));
1994
0
        YYERROR;
1995
0
          }
1996
281
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
1997
281
          parser_leak_add(LEAK_MEMBER, (yyval.member));
1998
281
      }
1999
0
#line 1999 "gram.c"
2000
0
    break;
2001
2002
1.19k
  case 40: /* host: NTWKADDR  */
2003
1.19k
#line 418 "gram.y"
2004
1.19k
                                 {
2005
1.19k
          (yyval.member) = new_member((yyvsp[0].string), NTWKADDR);
2006
1.19k
          if ((yyval.member) == NULL) {
2007
0
        sudoerserror(N_("unable to allocate memory"));
2008
0
        YYERROR;
2009
0
          }
2010
1.19k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2011
1.19k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
2012
1.19k
      }
2013
0
#line 2013 "gram.c"
2014
0
    break;
2015
2016
62.5k
  case 41: /* host: WORD  */
2017
62.5k
#line 427 "gram.y"
2018
62.5k
                             {
2019
62.5k
          (yyval.member) = new_member((yyvsp[0].string), WORD);
2020
62.5k
          if ((yyval.member) == NULL) {
2021
0
        sudoerserror(N_("unable to allocate memory"));
2022
0
        YYERROR;
2023
0
          }
2024
62.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2025
62.5k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
2026
62.5k
      }
2027
0
#line 2027 "gram.c"
2028
0
    break;
2029
2030
31.3k
  case 43: /* cmndspeclist: cmndspeclist ',' cmndspec  */
2031
31.3k
#line 439 "gram.y"
2032
31.3k
                                                  {
2033
31.3k
          const struct cmndspec *prev =
2034
31.3k
        HLTQ_LAST((yyvsp[-2].cmndspec), cmndspec, entries);
2035
31.3k
          propagate_cmndspec((yyvsp[0].cmndspec), prev);
2036
31.3k
          parser_leak_remove(LEAK_CMNDSPEC, (yyvsp[0].cmndspec));
2037
31.3k
          HLTQ_CONCAT((yyvsp[-2].cmndspec), (yyvsp[0].cmndspec), entries);
2038
31.3k
          (yyval.cmndspec) = (yyvsp[-2].cmndspec);
2039
31.3k
      }
2040
31.3k
#line 2040 "gram.c"
2041
31.3k
    break;
2042
2043
51.5k
  case 44: /* cmndspec: runasspec options cmndtag digcmnd  */
2044
51.5k
#line 449 "gram.y"
2045
51.5k
                                                          {
2046
51.5k
          struct cmndspec *cs = calloc(1, sizeof(*cs));
2047
51.5k
          if (cs == NULL) {
2048
0
        sudoerserror(N_("unable to allocate memory"));
2049
0
        YYERROR;
2050
0
          }
2051
51.5k
          parser_leak_add(LEAK_CMNDSPEC, cs);
2052
51.5k
          if ((yyvsp[-3].runas) != NULL) {
2053
8.73k
        if ((yyvsp[-3].runas)->runasusers != NULL) {
2054
8.73k
            cs->runasuserlist =
2055
8.73k
          malloc(sizeof(*cs->runasuserlist));
2056
8.73k
            if (cs->runasuserlist == NULL) {
2057
0
          free(cs);
2058
0
          sudoerserror(N_("unable to allocate memory"));
2059
0
          YYERROR;
2060
0
            }
2061
            /* g/c done via runas container */
2062
8.73k
            HLTQ_TO_TAILQ(cs->runasuserlist,
2063
8.73k
          (yyvsp[-3].runas)->runasusers, entries);
2064
8.73k
        }
2065
8.73k
        if ((yyvsp[-3].runas)->runasgroups != NULL) {
2066
1.22k
            cs->runasgrouplist =
2067
1.22k
          malloc(sizeof(*cs->runasgrouplist));
2068
1.22k
            if (cs->runasgrouplist == NULL) {
2069
0
          free(cs);
2070
0
          sudoerserror(N_("unable to allocate memory"));
2071
0
          YYERROR;
2072
0
            }
2073
            /* g/c done via runas container */
2074
1.22k
            HLTQ_TO_TAILQ(cs->runasgrouplist,
2075
1.22k
          (yyvsp[-3].runas)->runasgroups, entries);
2076
1.22k
        }
2077
8.73k
        parser_leak_remove(LEAK_RUNAS, (yyvsp[-3].runas));
2078
8.73k
        free((yyvsp[-3].runas));
2079
8.73k
          }
2080
51.5k
          cs->role = (yyvsp[-2].options).role;
2081
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).role);
2082
51.5k
          cs->type = (yyvsp[-2].options).type;
2083
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).type);
2084
51.5k
          cs->apparmor_profile = (yyvsp[-2].options).apparmor_profile;
2085
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).apparmor_profile);
2086
51.5k
          cs->privs = (yyvsp[-2].options).privs;
2087
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).privs);
2088
51.5k
          cs->limitprivs = (yyvsp[-2].options).limitprivs;
2089
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).limitprivs);
2090
51.5k
          cs->notbefore = (yyvsp[-2].options).notbefore;
2091
51.5k
          cs->notafter = (yyvsp[-2].options).notafter;
2092
51.5k
          cs->timeout = (yyvsp[-2].options).timeout;
2093
51.5k
          cs->runcwd = (yyvsp[-2].options).runcwd;
2094
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).runcwd);
2095
51.5k
          cs->runchroot = (yyvsp[-2].options).runchroot;
2096
51.5k
          parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).runchroot);
2097
51.5k
          cs->tags = (yyvsp[-1].tag);
2098
51.5k
          cs->cmnd = (yyvsp[0].member);
2099
51.5k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2100
51.5k
          HLTQ_INIT(cs, entries);
2101
          /* sudo "ALL" implies the SETENV tag */
2102
51.5k
          if (cs->cmnd->type == ALL && !cs->cmnd->negated &&
2103
1.76k
        cs->tags.setenv == UNSPEC)
2104
1.47k
        cs->tags.setenv = IMPLIED;
2105
51.5k
          (yyval.cmndspec) = cs;
2106
51.5k
      }
2107
0
#line 2107 "gram.c"
2108
0
    break;
2109
2110
991
  case 45: /* digestspec: SHA224_TOK ':' DIGEST  */
2111
991
#line 513 "gram.y"
2112
991
                                              {
2113
991
          (yyval.digest) = new_digest(SUDO_DIGEST_SHA224, (yyvsp[0].string));
2114
991
          if ((yyval.digest) == NULL) {
2115
0
        sudoerserror(N_("unable to allocate memory"));
2116
0
        YYERROR;
2117
0
          }
2118
991
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2119
991
          parser_leak_add(LEAK_DIGEST, (yyval.digest));
2120
991
      }
2121
0
#line 2121 "gram.c"
2122
0
    break;
2123
2124
1.24k
  case 46: /* digestspec: SHA256_TOK ':' DIGEST  */
2125
1.24k
#line 522 "gram.y"
2126
1.24k
                                              {
2127
1.24k
          (yyval.digest) = new_digest(SUDO_DIGEST_SHA256, (yyvsp[0].string));
2128
1.24k
          if ((yyval.digest) == NULL) {
2129
0
        sudoerserror(N_("unable to allocate memory"));
2130
0
        YYERROR;
2131
0
          }
2132
1.24k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2133
1.24k
          parser_leak_add(LEAK_DIGEST, (yyval.digest));
2134
1.24k
      }
2135
0
#line 2135 "gram.c"
2136
0
    break;
2137
2138
396
  case 47: /* digestspec: SHA384_TOK ':' DIGEST  */
2139
396
#line 531 "gram.y"
2140
396
                                              {
2141
396
          (yyval.digest) = new_digest(SUDO_DIGEST_SHA384, (yyvsp[0].string));
2142
396
          if ((yyval.digest) == NULL) {
2143
0
        sudoerserror(N_("unable to allocate memory"));
2144
0
        YYERROR;
2145
0
          }
2146
396
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2147
396
          parser_leak_add(LEAK_DIGEST, (yyval.digest));
2148
396
      }
2149
0
#line 2149 "gram.c"
2150
0
    break;
2151
2152
205
  case 48: /* digestspec: SHA512_TOK ':' DIGEST  */
2153
205
#line 540 "gram.y"
2154
205
                                              {
2155
205
          (yyval.digest) = new_digest(SUDO_DIGEST_SHA512, (yyvsp[0].string));
2156
205
          if ((yyval.digest) == NULL) {
2157
0
        sudoerserror(N_("unable to allocate memory"));
2158
0
        YYERROR;
2159
0
          }
2160
205
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2161
205
          parser_leak_add(LEAK_DIGEST, (yyval.digest));
2162
205
      }
2163
0
#line 2163 "gram.c"
2164
0
    break;
2165
2166
715
  case 50: /* digestlist: digestlist ',' digestspec  */
2167
715
#line 552 "gram.y"
2168
715
                                                  {
2169
715
          parser_leak_remove(LEAK_DIGEST, (yyvsp[0].digest));
2170
715
          HLTQ_CONCAT((yyvsp[-2].digest), (yyvsp[0].digest), entries);
2171
715
          (yyval.digest) = (yyvsp[-2].digest);
2172
715
      }
2173
715
#line 2173 "gram.c"
2174
715
    break;
2175
2176
59.2k
  case 51: /* digcmnd: opcmnd  */
2177
59.2k
#line 559 "gram.y"
2178
59.2k
                               {
2179
59.2k
          (yyval.member) = (yyvsp[0].member);
2180
59.2k
      }
2181
59.2k
#line 2181 "gram.c"
2182
59.2k
    break;
2183
2184
1.80k
  case 52: /* digcmnd: digestlist opcmnd  */
2185
1.80k
#line 562 "gram.y"
2186
1.80k
                                          {
2187
1.80k
          struct sudo_command *c =
2188
1.80k
        (struct sudo_command *) (yyvsp[0].member)->name;
2189
2190
1.80k
          if ((yyvsp[0].member)->type != COMMAND && (yyvsp[0].member)->type != ALL) {
2191
195
        sudoerserror(N_("a digest requires a path name"));
2192
195
        YYERROR;
2193
195
          }
2194
1.60k
          parser_leak_remove(LEAK_DIGEST, (yyvsp[-1].digest));
2195
1.60k
          HLTQ_TO_TAILQ(&c->digests, (yyvsp[-1].digest), entries);
2196
1.60k
          (yyval.member) = (yyvsp[0].member);
2197
1.60k
      }
2198
0
#line 2198 "gram.c"
2199
0
    break;
2200
2201
57.7k
  case 53: /* opcmnd: cmnd  */
2202
57.7k
#line 576 "gram.y"
2203
57.7k
                             {
2204
57.7k
          (yyval.member) = (yyvsp[0].member);
2205
57.7k
          (yyval.member)->negated = false;
2206
57.7k
      }
2207
57.7k
#line 2207 "gram.c"
2208
57.7k
    break;
2209
2210
3.21k
  case 54: /* opcmnd: '!' cmnd  */
2211
3.21k
#line 580 "gram.y"
2212
3.21k
                                 {
2213
3.21k
          (yyval.member) = (yyvsp[0].member);
2214
3.21k
          (yyval.member)->negated = true;
2215
3.21k
      }
2216
3.21k
#line 2216 "gram.c"
2217
3.21k
    break;
2218
2219
2.89k
  case 55: /* chdirspec: CWD '=' WORD  */
2220
2.89k
#line 586 "gram.y"
2221
2.89k
                                     {
2222
2.89k
          if ((yyvsp[0].string)[0] != '/' && (yyvsp[0].string)[0] != '~') {
2223
822
        if (strcmp((yyvsp[0].string), "*") != 0) {
2224
407
            sudoerserror(N_("values for \"CWD\" must"
2225
407
          " start with a '/', '~', or '*'"));
2226
407
            YYERROR;
2227
407
        }
2228
822
          }
2229
2.48k
          if (strlen((yyvsp[0].string)) >= PATH_MAX) {
2230
197
        sudoerserror(N_("\"CWD\" path too long"));
2231
197
        YYERROR;
2232
197
          }
2233
2.28k
          (yyval.string) = (yyvsp[0].string);
2234
2.28k
      }
2235
0
#line 2235 "gram.c"
2236
0
    break;
2237
2238
1.76k
  case 56: /* chrootspec: CHROOT '=' WORD  */
2239
1.76k
#line 602 "gram.y"
2240
1.76k
                                        {
2241
1.76k
          if ((yyvsp[0].string)[0] != '/' && (yyvsp[0].string)[0] != '~') {
2242
411
        if (strcmp((yyvsp[0].string), "*") != 0) {
2243
211
            sudoerserror(N_("values for \"CHROOT\" must"
2244
211
          " start with a '/', '~', or '*'"));
2245
211
            YYERROR;
2246
211
        }
2247
411
          }
2248
1.55k
          if (strlen((yyvsp[0].string)) >= PATH_MAX) {
2249
67
        sudoerserror(N_("\"CHROOT\" path too long"));
2250
67
        YYERROR;
2251
67
          }
2252
1.48k
          if (parser_conf.strict > 2) {
2253
0
        sudoerserror(N_("\"CHROOT\" is deprecated"));
2254
0
        YYERROR;
2255
1.48k
          } else if (parser_conf.verbose > 0) {
2256
0
        parser_warnx(parsed_policy.ctx, sudoers, this_lineno, (int)(sudolinebuf.toke_start + 1), false, false, N_("\"CHROOT\" is deprecated"));
2257
0
          }
2258
1.48k
          (yyval.string) = (yyvsp[0].string);
2259
1.48k
      }
2260
0
#line 2260 "gram.c"
2261
0
    break;
2262
2263
4.68k
  case 57: /* timeoutspec: CMND_TIMEOUT '=' WORD  */
2264
4.68k
#line 624 "gram.y"
2265
4.68k
                                              {
2266
4.68k
          (yyval.string) = (yyvsp[0].string);
2267
4.68k
      }
2268
4.68k
#line 2268 "gram.c"
2269
4.68k
    break;
2270
2271
3.18k
  case 58: /* notbeforespec: NOTBEFORE '=' WORD  */
2272
3.18k
#line 629 "gram.y"
2273
3.18k
                                           {
2274
3.18k
          (yyval.string) = (yyvsp[0].string);
2275
3.18k
      }
2276
3.18k
#line 2276 "gram.c"
2277
3.18k
    break;
2278
2279
19.0k
  case 59: /* notafterspec: NOTAFTER '=' WORD  */
2280
19.0k
#line 633 "gram.y"
2281
19.0k
                                          {
2282
19.0k
          (yyval.string) = (yyvsp[0].string);
2283
19.0k
      }
2284
19.0k
#line 2284 "gram.c"
2285
19.0k
    break;
2286
2287
684
  case 60: /* rolespec: ROLE '=' WORD  */
2288
684
#line 638 "gram.y"
2289
684
                                      {
2290
684
          (yyval.string) = (yyvsp[0].string);
2291
684
      }
2292
684
#line 2292 "gram.c"
2293
684
    break;
2294
2295
576
  case 61: /* typespec: TYPE '=' WORD  */
2296
576
#line 643 "gram.y"
2297
576
                                      {
2298
576
          (yyval.string) = (yyvsp[0].string);
2299
576
      }
2300
576
#line 2300 "gram.c"
2301
576
    break;
2302
2303
729
  case 62: /* apparmor_profilespec: APPARMOR_PROFILE '=' WORD  */
2304
729
#line 648 "gram.y"
2305
729
                                                          {
2306
729
        (yyval.string) = (yyvsp[0].string);
2307
729
      }
2308
729
#line 2308 "gram.c"
2309
729
    break;
2310
2311
927
  case 63: /* privsspec: PRIVS '=' WORD  */
2312
927
#line 653 "gram.y"
2313
927
                                       {
2314
927
          (yyval.string) = (yyvsp[0].string);
2315
927
      }
2316
927
#line 2316 "gram.c"
2317
927
    break;
2318
2319
983
  case 64: /* limitprivsspec: LIMITPRIVS '=' WORD  */
2320
983
#line 657 "gram.y"
2321
983
                                            {
2322
983
          (yyval.string) = (yyvsp[0].string);
2323
983
      }
2324
983
#line 2324 "gram.c"
2325
983
    break;
2326
2327
81.9k
  case 65: /* runasspec: %empty  */
2328
81.9k
#line 662 "gram.y"
2329
81.9k
                                    {
2330
81.9k
          (yyval.runas) = NULL;
2331
81.9k
      }
2332
81.9k
#line 2332 "gram.c"
2333
81.9k
    break;
2334
2335
8.99k
  case 66: /* runasspec: '(' runaslist ')'  */
2336
8.99k
#line 665 "gram.y"
2337
8.99k
                                          {
2338
8.99k
          (yyval.runas) = (yyvsp[-1].runas);
2339
8.99k
      }
2340
8.99k
#line 2340 "gram.c"
2341
8.99k
    break;
2342
2343
6.90k
  case 67: /* runaslist: %empty  */
2344
6.90k
#line 670 "gram.y"
2345
6.90k
                                    {
2346
          /* User may run command as themselves. */
2347
6.90k
          (yyval.runas) = calloc(1, sizeof(struct runascontainer));
2348
6.90k
          if ((yyval.runas) != NULL) {
2349
6.90k
        (yyval.runas)->runasusers = new_member(NULL, MYSELF);
2350
        /* $$->runasgroups = NULL; */
2351
6.90k
        if ((yyval.runas)->runasusers == NULL) {
2352
0
            free((yyval.runas));
2353
0
            (yyval.runas) = NULL;
2354
0
        }
2355
6.90k
          }
2356
6.90k
          if ((yyval.runas) == NULL) {
2357
0
        sudoerserror(N_("unable to allocate memory"));
2358
0
        YYERROR;
2359
0
          }
2360
6.90k
          parser_leak_add(LEAK_RUNAS, (yyval.runas));
2361
6.90k
      }
2362
0
#line 2362 "gram.c"
2363
0
    break;
2364
2365
1.34k
  case 68: /* runaslist: userlist  */
2366
1.34k
#line 687 "gram.y"
2367
1.34k
                                 {
2368
          /* User may run command as a user in userlist. */
2369
1.34k
          (yyval.runas) = calloc(1, sizeof(struct runascontainer));
2370
1.34k
          if ((yyval.runas) == NULL) {
2371
0
        sudoerserror(N_("unable to allocate memory"));
2372
0
        YYERROR;
2373
0
          }
2374
1.34k
          parser_leak_add(LEAK_RUNAS, (yyval.runas));
2375
1.34k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2376
1.34k
          (yyval.runas)->runasusers = (yyvsp[0].member);
2377
          /* $$->runasgroups = NULL; */
2378
1.34k
      }
2379
0
#line 2379 "gram.c"
2380
0
    break;
2381
2382
754
  case 69: /* runaslist: userlist ':' grouplist  */
2383
754
#line 699 "gram.y"
2384
754
                                               {
2385
          /*
2386
           * User may run command as a user in userlist
2387
           * and optionally as a group in grouplist.
2388
           */
2389
754
          (yyval.runas) = calloc(1, sizeof(struct runascontainer));
2390
754
          if ((yyval.runas) == NULL) {
2391
0
        sudoerserror(N_("unable to allocate memory"));
2392
0
        YYERROR;
2393
0
          }
2394
754
          parser_leak_add(LEAK_RUNAS, (yyval.runas));
2395
754
          parser_leak_remove(LEAK_MEMBER, (yyvsp[-2].member));
2396
754
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2397
754
          (yyval.runas)->runasusers = (yyvsp[-2].member);
2398
754
          (yyval.runas)->runasgroups = (yyvsp[0].member);
2399
754
      }
2400
0
#line 2400 "gram.c"
2401
0
    break;
2402
2403
4.91k
  case 70: /* runaslist: ':' grouplist  */
2404
4.91k
#line 715 "gram.y"
2405
4.91k
                                      {
2406
          /* User may run command as a group in grouplist. */
2407
4.91k
          (yyval.runas) = calloc(1, sizeof(struct runascontainer));
2408
4.91k
          if ((yyval.runas) != NULL) {
2409
4.91k
        (yyval.runas)->runasusers = new_member(NULL, MYSELF);
2410
4.91k
        if ((yyval.runas)->runasusers == NULL) {
2411
0
            free((yyval.runas));
2412
0
            (yyval.runas) = NULL;
2413
0
        }
2414
4.91k
          }
2415
4.91k
          if ((yyval.runas) == NULL) {
2416
0
        sudoerserror(N_("unable to allocate memory"));
2417
0
        YYERROR;
2418
0
          }
2419
4.91k
          parser_leak_add(LEAK_RUNAS, (yyval.runas));
2420
4.91k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2421
4.91k
          (yyval.runas)->runasgroups = (yyvsp[0].member);
2422
4.91k
      }
2423
0
#line 2423 "gram.c"
2424
0
    break;
2425
2426
5.47k
  case 71: /* runaslist: ':'  */
2427
5.47k
#line 733 "gram.y"
2428
5.47k
                            {
2429
          /* User may run command as themselves. */
2430
5.47k
          (yyval.runas) = calloc(1, sizeof(struct runascontainer));
2431
5.47k
          if ((yyval.runas) != NULL) {
2432
5.47k
        (yyval.runas)->runasusers = new_member(NULL, MYSELF);
2433
        /* $$->runasgroups = NULL; */
2434
5.47k
        if ((yyval.runas)->runasusers == NULL) {
2435
0
            free((yyval.runas));
2436
0
            (yyval.runas) = NULL;
2437
0
        }
2438
5.47k
          }
2439
5.47k
          if ((yyval.runas) == NULL) {
2440
0
        sudoerserror(N_("unable to allocate memory"));
2441
0
        YYERROR;
2442
0
          }
2443
5.47k
          parser_leak_add(LEAK_RUNAS, (yyval.runas));
2444
5.47k
      }
2445
0
#line 2445 "gram.c"
2446
0
    break;
2447
2448
194
  case 72: /* reserved_word: ALL  */
2449
194
#line 752 "gram.y"
2450
194
                                        { (yyval.cstring) = "ALL"; }
2451
194
#line 2451 "gram.c"
2452
194
    break;
2453
2454
194
  case 73: /* reserved_word: CHROOT  */
2455
194
#line 753 "gram.y"
2456
194
                                        { (yyval.cstring) = "CHROOT"; }
2457
194
#line 2457 "gram.c"
2458
194
    break;
2459
2460
194
  case 74: /* reserved_word: CWD  */
2461
194
#line 754 "gram.y"
2462
194
                                        { (yyval.cstring) = "CWD"; }
2463
194
#line 2463 "gram.c"
2464
194
    break;
2465
2466
195
  case 75: /* reserved_word: CMND_TIMEOUT  */
2467
195
#line 755 "gram.y"
2468
195
                                        { (yyval.cstring) = "CMND_TIMEOUT"; }
2469
195
#line 2469 "gram.c"
2470
195
    break;
2471
2472
204
  case 76: /* reserved_word: NOTBEFORE  */
2473
204
#line 756 "gram.y"
2474
204
                                        { (yyval.cstring) = "NOTBEFORE"; }
2475
204
#line 2475 "gram.c"
2476
204
    break;
2477
2478
195
  case 77: /* reserved_word: NOTAFTER  */
2479
195
#line 757 "gram.y"
2480
195
                                        { (yyval.cstring) = "NOTAFTER"; }
2481
195
#line 2481 "gram.c"
2482
195
    break;
2483
2484
194
  case 78: /* reserved_word: ROLE  */
2485
194
#line 758 "gram.y"
2486
194
                                        { (yyval.cstring) = "ROLE"; }
2487
194
#line 2487 "gram.c"
2488
194
    break;
2489
2490
201
  case 79: /* reserved_word: TYPE  */
2491
201
#line 759 "gram.y"
2492
201
                                        { (yyval.cstring) = "TYPE"; }
2493
201
#line 2493 "gram.c"
2494
201
    break;
2495
2496
195
  case 80: /* reserved_word: PRIVS  */
2497
195
#line 760 "gram.y"
2498
195
                                        { (yyval.cstring) = "PRIVS"; }
2499
195
#line 2499 "gram.c"
2500
195
    break;
2501
2502
215
  case 81: /* reserved_word: LIMITPRIVS  */
2503
215
#line 761 "gram.y"
2504
215
                                        { (yyval.cstring) = "LIMITPRIVS"; }
2505
215
#line 2505 "gram.c"
2506
215
    break;
2507
2508
194
  case 82: /* reserved_word: APPARMOR_PROFILE  */
2509
194
#line 762 "gram.y"
2510
194
                                         { (yyval.cstring) = "APPARMOR_PROFILE"; }
2511
194
#line 2511 "gram.c"
2512
194
    break;
2513
2514
2.17k
  case 83: /* reserved_alias: reserved_word  */
2515
2.17k
#line 765 "gram.y"
2516
2.17k
                                      {
2517
2.17k
          sudoerserrorf(U_("syntax error, reserved word %s used as an alias name"), (yyvsp[0].cstring));
2518
2.17k
          YYERROR;
2519
5.47k
      }
2520
0
#line 2520 "gram.c"
2521
0
    break;
2522
2523
90.9k
  case 84: /* options: %empty  */
2524
90.9k
#line 771 "gram.y"
2525
90.9k
                                    {
2526
90.9k
          init_options(&(yyval.options));
2527
90.9k
      }
2528
90.9k
#line 2528 "gram.c"
2529
90.9k
    break;
2530
2531
2.28k
  case 85: /* options: options chdirspec  */
2532
2.28k
#line 774 "gram.y"
2533
2.28k
                                          {
2534
2.28k
          parser_leak_remove(LEAK_PTR, (yyval.options).runcwd);
2535
2.28k
          free((yyval.options).runcwd);
2536
2.28k
          (yyval.options).runcwd = (yyvsp[0].string);
2537
2.28k
      }
2538
2.28k
#line 2538 "gram.c"
2539
2.28k
    break;
2540
2541
1.48k
  case 86: /* options: options chrootspec  */
2542
1.48k
#line 779 "gram.y"
2543
1.48k
                                           {
2544
1.48k
          parser_leak_remove(LEAK_PTR, (yyval.options).runchroot);
2545
1.48k
          free((yyval.options).runchroot);
2546
1.48k
          (yyval.options).runchroot = (yyvsp[0].string);
2547
1.48k
      }
2548
1.48k
#line 2548 "gram.c"
2549
1.48k
    break;
2550
2551
3.18k
  case 87: /* options: options notbeforespec  */
2552
3.18k
#line 784 "gram.y"
2553
3.18k
                                              {
2554
3.18k
          (yyval.options).notbefore = parse_gentime((yyvsp[0].string));
2555
3.18k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2556
3.18k
          free((yyvsp[0].string));
2557
3.18k
          if ((yyval.options).notbefore == -1) {
2558
2.02k
        sudoerserror(N_("invalid notbefore value"));
2559
2.02k
        YYERROR;
2560
2.02k
          }
2561
3.18k
      }
2562
1.16k
#line 2562 "gram.c"
2563
1.16k
    break;
2564
2565
19.0k
  case 88: /* options: options notafterspec  */
2566
19.0k
#line 793 "gram.y"
2567
19.0k
                                             {
2568
19.0k
          (yyval.options).notafter = parse_gentime((yyvsp[0].string));
2569
19.0k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2570
19.0k
          free((yyvsp[0].string));
2571
19.0k
          if ((yyval.options).notafter == -1) {
2572
17.1k
        sudoerserror(N_("invalid notafter value"));
2573
17.1k
        YYERROR;
2574
17.1k
          }
2575
19.0k
      }
2576
1.84k
#line 2576 "gram.c"
2577
1.84k
    break;
2578
2579
4.68k
  case 89: /* options: options timeoutspec  */
2580
4.68k
#line 802 "gram.y"
2581
4.68k
                                            {
2582
4.68k
          (yyval.options).timeout = parse_timeout((yyvsp[0].string));
2583
4.68k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2584
4.68k
          free((yyvsp[0].string));
2585
4.68k
          if ((yyval.options).timeout == -1) {
2586
2.80k
        if (errno == ERANGE)
2587
2.28k
            sudoerserror(N_("timeout value too large"));
2588
527
        else
2589
527
            sudoerserror(N_("invalid timeout value"));
2590
2.80k
        YYERROR;
2591
2.80k
          }
2592
4.68k
      }
2593
1.87k
#line 2593 "gram.c"
2594
1.87k
    break;
2595
2596
1.87k
  case 90: /* options: options rolespec  */
2597
684
#line 814 "gram.y"
2598
684
                                         {
2599
684
          parser_leak_remove(LEAK_PTR, (yyval.options).role);
2600
684
          free((yyval.options).role);
2601
684
          (yyval.options).role = (yyvsp[0].string);
2602
684
      }
2603
684
#line 2603 "gram.c"
2604
684
    break;
2605
2606
576
  case 91: /* options: options typespec  */
2607
576
#line 819 "gram.y"
2608
576
                                         {
2609
576
          parser_leak_remove(LEAK_PTR, (yyval.options).type);
2610
576
          free((yyval.options).type);
2611
576
          (yyval.options).type = (yyvsp[0].string);
2612
576
      }
2613
576
#line 2613 "gram.c"
2614
576
    break;
2615
2616
729
  case 92: /* options: options apparmor_profilespec  */
2617
729
#line 824 "gram.y"
2618
729
                                                     {
2619
729
          parser_leak_remove(LEAK_PTR, (yyval.options).apparmor_profile);
2620
729
          free((yyval.options).apparmor_profile);
2621
729
          (yyval.options).apparmor_profile = (yyvsp[0].string);
2622
729
      }
2623
729
#line 2623 "gram.c"
2624
729
    break;
2625
2626
927
  case 93: /* options: options privsspec  */
2627
927
#line 829 "gram.y"
2628
927
                                          {
2629
927
          parser_leak_remove(LEAK_PTR, (yyval.options).privs);
2630
927
          free((yyval.options).privs);
2631
927
          (yyval.options).privs = (yyvsp[0].string);
2632
927
      }
2633
927
#line 2633 "gram.c"
2634
927
    break;
2635
2636
983
  case 94: /* options: options limitprivsspec  */
2637
983
#line 834 "gram.y"
2638
983
                                               {
2639
983
          parser_leak_remove(LEAK_PTR, (yyval.options).limitprivs);
2640
983
          free((yyval.options).limitprivs);
2641
983
          (yyval.options).limitprivs = (yyvsp[0].string);
2642
983
      }
2643
983
#line 2643 "gram.c"
2644
983
    break;
2645
2646
68.0k
  case 95: /* cmndtag: %empty  */
2647
68.0k
#line 841 "gram.y"
2648
68.0k
                                    {
2649
68.0k
          TAGS_INIT(&(yyval.tag));
2650
68.0k
      }
2651
68.0k
#line 2651 "gram.c"
2652
68.0k
    break;
2653
2654
347
  case 96: /* cmndtag: cmndtag NOPASSWD  */
2655
347
#line 844 "gram.y"
2656
347
                                         {
2657
347
          (yyval.tag).nopasswd = true;
2658
347
      }
2659
347
#line 2659 "gram.c"
2660
347
    break;
2661
2662
461
  case 97: /* cmndtag: cmndtag PASSWD  */
2663
461
#line 847 "gram.y"
2664
461
                                       {
2665
461
          (yyval.tag).nopasswd = false;
2666
461
      }
2667
461
#line 2667 "gram.c"
2668
461
    break;
2669
2670
318
  case 98: /* cmndtag: cmndtag NOEXEC  */
2671
318
#line 850 "gram.y"
2672
318
                                       {
2673
318
          (yyval.tag).noexec = true;
2674
318
      }
2675
318
#line 2675 "gram.c"
2676
318
    break;
2677
2678
512
  case 99: /* cmndtag: cmndtag EXEC  */
2679
512
#line 853 "gram.y"
2680
512
                                     {
2681
512
          (yyval.tag).noexec = false;
2682
512
      }
2683
512
#line 2683 "gram.c"
2684
512
    break;
2685
2686
0
  case 100: /* cmndtag: cmndtag INTERCEPT  */
2687
0
#line 856 "gram.y"
2688
0
                                          {
2689
0
          (yyval.tag).intercept = true;
2690
0
      }
2691
0
#line 2691 "gram.c"
2692
0
    break;
2693
2694
0
  case 101: /* cmndtag: cmndtag NOINTERCEPT  */
2695
0
#line 859 "gram.y"
2696
0
                                            {
2697
0
          (yyval.tag).intercept = false;
2698
0
      }
2699
0
#line 2699 "gram.c"
2700
0
    break;
2701
2702
621
  case 102: /* cmndtag: cmndtag SETENV  */
2703
621
#line 862 "gram.y"
2704
621
                                       {
2705
621
          (yyval.tag).setenv = true;
2706
621
      }
2707
621
#line 2707 "gram.c"
2708
621
    break;
2709
2710
344
  case 103: /* cmndtag: cmndtag NOSETENV  */
2711
344
#line 865 "gram.y"
2712
344
                                         {
2713
344
          (yyval.tag).setenv = false;
2714
344
      }
2715
344
#line 2715 "gram.c"
2716
344
    break;
2717
2718
409
  case 104: /* cmndtag: cmndtag LOG_INPUT  */
2719
409
#line 868 "gram.y"
2720
409
                                          {
2721
409
          (yyval.tag).log_input = true;
2722
409
      }
2723
409
#line 2723 "gram.c"
2724
409
    break;
2725
2726
400
  case 105: /* cmndtag: cmndtag NOLOG_INPUT  */
2727
400
#line 871 "gram.y"
2728
400
                                            {
2729
400
          (yyval.tag).log_input = false;
2730
400
      }
2731
400
#line 2731 "gram.c"
2732
400
    break;
2733
2734
322
  case 106: /* cmndtag: cmndtag LOG_OUTPUT  */
2735
322
#line 874 "gram.y"
2736
322
                                           {
2737
322
          (yyval.tag).log_output = true;
2738
322
      }
2739
322
#line 2739 "gram.c"
2740
322
    break;
2741
2742
270
  case 107: /* cmndtag: cmndtag NOLOG_OUTPUT  */
2743
270
#line 877 "gram.y"
2744
270
                                             {
2745
270
          (yyval.tag).log_output = false;
2746
270
      }
2747
270
#line 2747 "gram.c"
2748
270
    break;
2749
2750
623
  case 108: /* cmndtag: cmndtag FOLLOWLNK  */
2751
623
#line 880 "gram.y"
2752
623
                                          {
2753
623
          (yyval.tag).follow = true;
2754
623
      }
2755
623
#line 2755 "gram.c"
2756
623
    break;
2757
2758
392
  case 109: /* cmndtag: cmndtag NOFOLLOWLNK  */
2759
392
#line 883 "gram.y"
2760
392
                                            {
2761
392
          (yyval.tag).follow = false;
2762
392
      }
2763
392
#line 2763 "gram.c"
2764
392
    break;
2765
2766
434
  case 110: /* cmndtag: cmndtag MAIL  */
2767
434
#line 886 "gram.y"
2768
434
                                     {
2769
434
          (yyval.tag).send_mail = true;
2770
434
      }
2771
434
#line 2771 "gram.c"
2772
434
    break;
2773
2774
316
  case 111: /* cmndtag: cmndtag NOMAIL  */
2775
316
#line 889 "gram.y"
2776
316
                                       {
2777
316
          (yyval.tag).send_mail = false;
2778
316
      }
2779
316
#line 2779 "gram.c"
2780
316
    break;
2781
2782
3.10k
  case 112: /* cmnd: ALL  */
2783
3.10k
#line 894 "gram.y"
2784
3.10k
                            {
2785
3.10k
          struct sudo_command *c;
2786
2787
3.10k
          if ((c = new_command(NULL, NULL)) == NULL) {
2788
0
        sudoerserror(N_("unable to allocate memory"));
2789
0
        YYERROR;
2790
0
          }
2791
3.10k
          (yyval.member) = new_member((char *)c, ALL);
2792
3.10k
          if ((yyval.member) == NULL) {
2793
0
        sudoerserror(N_("unable to allocate memory"));
2794
0
        YYERROR;
2795
0
          }
2796
3.10k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
2797
3.10k
      }
2798
0
#line 2798 "gram.c"
2799
0
    break;
2800
2801
45.3k
  case 113: /* cmnd: ALIAS  */
2802
45.3k
#line 908 "gram.y"
2803
45.3k
                              {
2804
45.3k
          (yyval.member) = new_member((yyvsp[0].string), ALIAS);
2805
45.3k
          if ((yyval.member) == NULL) {
2806
0
        sudoerserror(N_("unable to allocate memory"));
2807
0
        YYERROR;
2808
0
          }
2809
45.3k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2810
45.3k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
2811
45.3k
      }
2812
0
#line 2812 "gram.c"
2813
0
    break;
2814
2815
12.5k
  case 114: /* cmnd: COMMAND  */
2816
12.5k
#line 917 "gram.y"
2817
12.5k
                                {
2818
12.5k
          struct sudo_command *c;
2819
2820
12.5k
          if (strlen((yyvsp[0].command).cmnd) >= PATH_MAX) {
2821
212
        sudoerserror(N_("command too long"));
2822
212
        YYERROR;
2823
212
          }
2824
12.3k
          if ((c = new_command((yyvsp[0].command).cmnd, (yyvsp[0].command).args)) == NULL) {
2825
0
        sudoerserror(N_("unable to allocate memory"));
2826
0
        YYERROR;
2827
0
          }
2828
12.3k
          (yyval.member) = new_member((char *)c, COMMAND);
2829
12.3k
          if ((yyval.member) == NULL) {
2830
0
        free(c);
2831
0
        sudoerserror(N_("unable to allocate memory"));
2832
0
        YYERROR;
2833
0
          }
2834
12.3k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].command).cmnd);
2835
12.3k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].command).args);
2836
12.3k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
2837
12.3k
      }
2838
0
#line 2838 "gram.c"
2839
0
    break;
2840
2841
9.10k
  case 115: /* cmnd: WORD  */
2842
9.10k
#line 938 "gram.y"
2843
9.10k
                             {
2844
9.10k
          if (strcmp((yyvsp[0].string), "list") == 0) {
2845
209
        struct sudo_command *c;
2846
2847
209
        if ((c = new_command((yyvsp[0].string), NULL)) == NULL) {
2848
0
            sudoerserror(N_("unable to allocate memory"));
2849
0
            YYERROR;
2850
0
        }
2851
209
        (yyval.member) = new_member((char *)c, COMMAND);
2852
209
        if ((yyval.member) == NULL) {
2853
0
            free(c);
2854
0
            sudoerserror(N_("unable to allocate memory"));
2855
0
            YYERROR;
2856
0
        }
2857
209
        parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
2858
209
        parser_leak_add(LEAK_MEMBER, (yyval.member));
2859
8.89k
          } else {
2860
8.89k
        sudoerserror(N_("expected a fully-qualified path name"));
2861
8.89k
        YYERROR;
2862
8.89k
          }
2863
9.10k
      }
2864
209
#line 2864 "gram.c"
2865
209
    break;
2866
2867
1.05k
  case 118: /* $@1: %empty  */
2868
1.05k
#line 965 "gram.y"
2869
1.05k
                              {
2870
1.05k
          alias_line = this_lineno;
2871
1.05k
          alias_column = (int)sudolinebuf.toke_start + 1;
2872
1.05k
      }
2873
1.05k
#line 2873 "gram.c"
2874
1.05k
    break;
2875
2876
1.03k
  case 119: /* hostalias: ALIAS $@1 '=' hostlist  */
2877
1.03k
#line 968 "gram.y"
2878
1.03k
                                       {
2879
1.03k
          if (!alias_add(&parsed_policy, (yyvsp[-3].string), HOSTALIAS,
2880
1.03k
        sudoers, alias_line, alias_column, (yyvsp[0].member))) {
2881
199
        alias_error((yyvsp[-3].string), HOSTALIAS, errno);
2882
199
        YYERROR;
2883
199
          }
2884
840
          parser_leak_remove(LEAK_PTR, (yyvsp[-3].string));
2885
840
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2886
840
      }
2887
0
#line 2887 "gram.c"
2888
0
    break;
2889
2890
2.60k
  case 122: /* hostlist: hostlist ',' ophost  */
2891
2.60k
#line 981 "gram.y"
2892
2.60k
                                            {
2893
2.60k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2894
2.60k
          HLTQ_CONCAT((yyvsp[-2].member), (yyvsp[0].member), entries);
2895
2.60k
          (yyval.member) = (yyvsp[-2].member);
2896
2.60k
      }
2897
2.60k
#line 2897 "gram.c"
2898
2.60k
    break;
2899
2900
3.39k
  case 125: /* $@2: %empty  */
2901
3.39k
#line 992 "gram.y"
2902
3.39k
                              {
2903
3.39k
          alias_line = this_lineno;
2904
3.39k
          alias_column = (int)sudolinebuf.toke_start + 1;
2905
3.39k
      }
2906
3.39k
#line 2906 "gram.c"
2907
3.39k
    break;
2908
2909
3.19k
  case 126: /* cmndalias: ALIAS $@2 '=' cmndlist  */
2910
3.19k
#line 995 "gram.y"
2911
3.19k
                                       {
2912
3.19k
          if (!alias_add(&parsed_policy, (yyvsp[-3].string), CMNDALIAS,
2913
3.19k
        sudoers, alias_line, alias_column, (yyvsp[0].member))) {
2914
2.12k
        alias_error((yyvsp[-3].string), CMNDALIAS, errno);
2915
2.12k
        YYERROR;
2916
2.12k
          }
2917
1.06k
          parser_leak_remove(LEAK_PTR, (yyvsp[-3].string));
2918
1.06k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2919
1.06k
      }
2920
0
#line 2920 "gram.c"
2921
0
    break;
2922
2923
3.94k
  case 129: /* cmndlist: cmndlist ',' digcmnd  */
2924
3.94k
#line 1008 "gram.y"
2925
3.94k
                                             {
2926
3.94k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2927
3.94k
          HLTQ_CONCAT((yyvsp[-2].member), (yyvsp[0].member), entries);
2928
3.94k
          (yyval.member) = (yyvsp[-2].member);
2929
3.94k
      }
2930
3.94k
#line 2930 "gram.c"
2931
3.94k
    break;
2932
2933
958
  case 132: /* $@3: %empty  */
2934
958
#line 1019 "gram.y"
2935
958
                              {
2936
958
          alias_line = this_lineno;
2937
958
          alias_column = (int)sudolinebuf.toke_start + 1;
2938
958
      }
2939
958
#line 2939 "gram.c"
2940
958
    break;
2941
2942
953
  case 133: /* runasalias: ALIAS $@3 '=' userlist  */
2943
953
#line 1022 "gram.y"
2944
953
                                       {
2945
953
          if (!alias_add(&parsed_policy, (yyvsp[-3].string), RUNASALIAS,
2946
953
        sudoers, alias_line, alias_column, (yyvsp[0].member))) {
2947
566
        alias_error((yyvsp[-3].string), RUNASALIAS, errno);
2948
566
        YYERROR;
2949
566
          }
2950
387
          parser_leak_remove(LEAK_PTR, (yyvsp[-3].string));
2951
387
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2952
387
      }
2953
0
#line 2953 "gram.c"
2954
0
    break;
2955
2956
743
  case 137: /* $@4: %empty  */
2957
743
#line 1038 "gram.y"
2958
743
                              {
2959
743
          alias_line = this_lineno;
2960
743
          alias_column = (int)sudolinebuf.toke_start + 1;
2961
743
      }
2962
743
#line 2962 "gram.c"
2963
743
    break;
2964
2965
737
  case 138: /* useralias: ALIAS $@4 '=' userlist  */
2966
737
#line 1041 "gram.y"
2967
737
                                       {
2968
737
          if (!alias_add(&parsed_policy, (yyvsp[-3].string), USERALIAS,
2969
737
        sudoers, alias_line, alias_column, (yyvsp[0].member))) {
2970
561
        alias_error((yyvsp[-3].string), USERALIAS, errno);
2971
561
        YYERROR;
2972
561
          }
2973
176
          parser_leak_remove(LEAK_PTR, (yyvsp[-3].string));
2974
176
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2975
176
      }
2976
0
#line 2976 "gram.c"
2977
0
    break;
2978
2979
62.4k
  case 141: /* userlist: userlist ',' opuser  */
2980
62.4k
#line 1054 "gram.y"
2981
62.4k
                                            {
2982
62.4k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
2983
62.4k
          HLTQ_CONCAT((yyvsp[-2].member), (yyvsp[0].member), entries);
2984
62.4k
          (yyval.member) = (yyvsp[-2].member);
2985
62.4k
      }
2986
62.4k
#line 2986 "gram.c"
2987
62.4k
    break;
2988
2989
161k
  case 142: /* opuser: user  */
2990
161k
#line 1061 "gram.y"
2991
161k
                             {
2992
161k
          (yyval.member) = (yyvsp[0].member);
2993
161k
          (yyval.member)->negated = false;
2994
161k
      }
2995
161k
#line 2995 "gram.c"
2996
161k
    break;
2997
2998
860
  case 143: /* opuser: '!' user  */
2999
860
#line 1065 "gram.y"
3000
860
                                 {
3001
860
          (yyval.member) = (yyvsp[0].member);
3002
860
          (yyval.member)->negated = true;
3003
860
      }
3004
860
#line 3004 "gram.c"
3005
860
    break;
3006
3007
17.0k
  case 144: /* user: ALIAS  */
3008
17.0k
#line 1071 "gram.y"
3009
17.0k
                              {
3010
17.0k
          (yyval.member) = new_member((yyvsp[0].string), ALIAS);
3011
17.0k
          if ((yyval.member) == NULL) {
3012
0
        sudoerserror(N_("unable to allocate memory"));
3013
0
        YYERROR;
3014
0
          }
3015
17.0k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
3016
17.0k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3017
17.0k
      }
3018
0
#line 3018 "gram.c"
3019
0
    break;
3020
3021
1.77k
  case 145: /* user: ALL  */
3022
1.77k
#line 1080 "gram.y"
3023
1.77k
                            {
3024
1.77k
          (yyval.member) = new_member(NULL, ALL);
3025
1.77k
          if ((yyval.member) == NULL) {
3026
0
        sudoerserror(N_("unable to allocate memory"));
3027
0
        YYERROR;
3028
0
          }
3029
1.77k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3030
1.77k
      }
3031
0
#line 3031 "gram.c"
3032
0
    break;
3033
3034
383
  case 146: /* user: NETGROUP  */
3035
383
#line 1088 "gram.y"
3036
383
                                 {
3037
383
          (yyval.member) = new_member((yyvsp[0].string), NETGROUP);
3038
383
          if ((yyval.member) == NULL) {
3039
0
        sudoerserror(N_("unable to allocate memory"));
3040
0
        YYERROR;
3041
0
          }
3042
383
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
3043
383
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3044
383
      }
3045
0
#line 3045 "gram.c"
3046
0
    break;
3047
3048
47.3k
  case 147: /* user: USERGROUP  */
3049
47.3k
#line 1097 "gram.y"
3050
47.3k
                                  {
3051
47.3k
          (yyval.member) = new_member((yyvsp[0].string), USERGROUP);
3052
47.3k
          if ((yyval.member) == NULL) {
3053
0
        sudoerserror(N_("unable to allocate memory"));
3054
0
        YYERROR;
3055
0
          }
3056
47.3k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
3057
47.3k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3058
47.3k
      }
3059
0
#line 3059 "gram.c"
3060
0
    break;
3061
3062
95.8k
  case 148: /* user: WORD  */
3063
95.8k
#line 1106 "gram.y"
3064
95.8k
                             {
3065
95.8k
          (yyval.member) = new_member((yyvsp[0].string), WORD);
3066
95.8k
          if ((yyval.member) == NULL) {
3067
0
        sudoerserror(N_("unable to allocate memory"));
3068
0
        YYERROR;
3069
0
          }
3070
95.8k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
3071
95.8k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3072
95.8k
      }
3073
0
#line 3073 "gram.c"
3074
0
    break;
3075
3076
1.40k
  case 150: /* grouplist: grouplist ',' opgroup  */
3077
1.40k
#line 1118 "gram.y"
3078
1.40k
                                              {
3079
1.40k
          parser_leak_remove(LEAK_MEMBER, (yyvsp[0].member));
3080
1.40k
          HLTQ_CONCAT((yyvsp[-2].member), (yyvsp[0].member), entries);
3081
1.40k
          (yyval.member) = (yyvsp[-2].member);
3082
1.40k
      }
3083
1.40k
#line 3083 "gram.c"
3084
1.40k
    break;
3085
3086
6.65k
  case 151: /* opgroup: group  */
3087
6.65k
#line 1125 "gram.y"
3088
6.65k
                              {
3089
6.65k
          (yyval.member) = (yyvsp[0].member);
3090
6.65k
          (yyval.member)->negated = false;
3091
6.65k
      }
3092
6.65k
#line 3092 "gram.c"
3093
6.65k
    break;
3094
3095
424
  case 152: /* opgroup: '!' group  */
3096
424
#line 1129 "gram.y"
3097
424
                                  {
3098
424
          (yyval.member) = (yyvsp[0].member);
3099
424
          (yyval.member)->negated = true;
3100
424
      }
3101
424
#line 3101 "gram.c"
3102
424
    break;
3103
3104
4.13k
  case 153: /* group: ALIAS  */
3105
4.13k
#line 1135 "gram.y"
3106
4.13k
                              {
3107
4.13k
          (yyval.member) = new_member((yyvsp[0].string), ALIAS);
3108
4.13k
          if ((yyval.member) == NULL) {
3109
0
        sudoerserror(N_("unable to allocate memory"));
3110
0
        YYERROR;
3111
0
          }
3112
4.13k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
3113
4.13k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3114
4.13k
      }
3115
0
#line 3115 "gram.c"
3116
0
    break;
3117
3118
223
  case 154: /* group: ALL  */
3119
223
#line 1144 "gram.y"
3120
223
                            {
3121
223
          (yyval.member) = new_member(NULL, ALL);
3122
223
          if ((yyval.member) == NULL) {
3123
0
        sudoerserror(N_("unable to allocate memory"));
3124
0
        YYERROR;
3125
0
          }
3126
223
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3127
223
      }
3128
0
#line 3128 "gram.c"
3129
0
    break;
3130
3131
2.72k
  case 155: /* group: WORD  */
3132
2.72k
#line 1152 "gram.y"
3133
2.72k
                             {
3134
2.72k
          (yyval.member) = new_member((yyvsp[0].string), WORD);
3135
2.72k
          if ((yyval.member) == NULL) {
3136
0
        sudoerserror(N_("unable to allocate memory"));
3137
0
        YYERROR;
3138
0
          }
3139
2.72k
          parser_leak_remove(LEAK_PTR, (yyvsp[0].string));
3140
2.72k
          parser_leak_add(LEAK_MEMBER, (yyval.member));
3141
2.72k
      }
3142
0
#line 3142 "gram.c"
3143
0
    break;
3144
3145
3146
0
#line 3146 "gram.c"
3147
3148
430k
      default: break;
3149
2.55M
    }
3150
  /* User semantic actions sometimes alter yychar, and that requires
3151
     that yytoken be updated with the new translation.  We take the
3152
     approach of translating immediately before every use of yytoken.
3153
     One alternative is translating here after every semantic action,
3154
     but that translation would be missed if the semantic action invokes
3155
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3156
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
3157
     incorrect destructor might then be invoked immediately.  In the
3158
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
3159
     to an incorrect destructor call or verbose syntax error message
3160
     before the lookahead is translated.  */
3161
2.51M
  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
3162
3163
2.51M
  YYPOPSTACK (yylen);
3164
2.51M
  yylen = 0;
3165
3166
2.51M
  *++yyvsp = yyval;
3167
3168
  /* Now 'shift' the result of the reduction.  Determine what state
3169
     that goes to, based on the state we popped back to and the rule
3170
     number reduced by.  */
3171
2.51M
  {
3172
2.51M
    const int yylhs = yyr1[yyn] - YYNTOKENS;
3173
2.51M
    const int yyi = yypgoto[yylhs] + *yyssp;
3174
2.51M
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
3175
2.51M
               ? yytable[yyi]
3176
2.51M
               : yydefgoto[yylhs]);
3177
2.51M
  }
3178
3179
2.51M
  goto yynewstate;
3180
3181
3182
/*--------------------------------------.
3183
| yyerrlab -- here on detecting error.  |
3184
`--------------------------------------*/
3185
404k
yyerrlab:
3186
  /* Make sure we have latest lookahead translation.  See comments at
3187
     user semantic actions for why this is necessary.  */
3188
404k
  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
3189
  /* If not already recovering from an error, report this error.  */
3190
404k
  if (!yyerrstatus)
3191
65.4k
    {
3192
65.4k
      ++yynerrs;
3193
65.4k
      yyerror (YY_("syntax error"));
3194
65.4k
    }
3195
3196
404k
  if (yyerrstatus == 3)
3197
338k
    {
3198
      /* If just tried and failed to reuse lookahead token after an
3199
         error, discard it.  */
3200
3201
338k
      if (yychar <= YYEOF)
3202
294
        {
3203
          /* Return failure if at end of input.  */
3204
294
          if (yychar == YYEOF)
3205
294
            YYABORT;
3206
294
        }
3207
338k
      else
3208
338k
        {
3209
338k
          yydestruct ("Error: discarding",
3210
338k
                      yytoken, &yylval);
3211
338k
          yychar = YYEMPTY;
3212
338k
        }
3213
338k
    }
3214
3215
  /* Else will try to reuse lookahead token after shifting the error
3216
     token.  */
3217
403k
  goto yyerrlab1;
3218
3219
3220
/*---------------------------------------------------.
3221
| yyerrorlab -- error raised explicitly by YYERROR.  |
3222
`---------------------------------------------------*/
3223
403k
yyerrorlab:
3224
  /* Pacify compilers when the user code never invokes YYERROR and the
3225
     label yyerrorlab therefore never appears in user code.  */
3226
40.1k
  if (0)
3227
0
    YYERROR;
3228
40.1k
  ++yynerrs;
3229
3230
  /* Do not reclaim the symbols of the rule whose action triggered
3231
     this YYERROR.  */
3232
40.1k
  YYPOPSTACK (yylen);
3233
40.1k
  yylen = 0;
3234
40.1k
  YY_STACK_PRINT (yyss, yyssp);
3235
40.1k
  yystate = *yyssp;
3236
40.1k
  goto yyerrlab1;
3237
3238
3239
/*-------------------------------------------------------------.
3240
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
3241
`-------------------------------------------------------------*/
3242
443k
yyerrlab1:
3243
443k
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
3244
3245
  /* Pop stack until we find a state that shifts the error token.  */
3246
443k
  for (;;)
3247
1.07M
    {
3248
1.07M
      yyn = yypact[yystate];
3249
1.07M
      if (!yypact_value_is_default (yyn))
3250
1.03M
        {
3251
1.03M
          yyn += YYSYMBOL_YYerror;
3252
1.03M
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
3253
443k
            {
3254
443k
              yyn = yytable[yyn];
3255
443k
              if (0 < yyn)
3256
443k
                break;
3257
443k
            }
3258
1.03M
        }
3259
3260
      /* Pop the current state because it cannot handle the error token.  */
3261
635k
      if (yyssp == yyss)
3262
0
        YYABORT;
3263
3264
3265
635k
      yydestruct ("Error: popping",
3266
635k
                  YY_ACCESSING_SYMBOL (yystate), yyvsp);
3267
635k
      YYPOPSTACK (1);
3268
635k
      yystate = *yyssp;
3269
635k
      YY_STACK_PRINT (yyss, yyssp);
3270
635k
    }
3271
3272
443k
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
3273
443k
  *++yyvsp = yylval;
3274
443k
  YY_IGNORE_MAYBE_UNINITIALIZED_END
3275
3276
3277
  /* Shift the error token.  */
3278
443k
  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
3279
3280
443k
  yystate = yyn;
3281
443k
  goto yynewstate;
3282
3283
3284
/*-------------------------------------.
3285
| yyacceptlab -- YYACCEPT comes here.  |
3286
`-------------------------------------*/
3287
12.4k
yyacceptlab:
3288
12.4k
  yyresult = 0;
3289
12.4k
  goto yyreturnlab;
3290
3291
3292
/*-----------------------------------.
3293
| yyabortlab -- YYABORT comes here.  |
3294
`-----------------------------------*/
3295
294
yyabortlab:
3296
294
  yyresult = 1;
3297
294
  goto yyreturnlab;
3298
3299
3300
/*-----------------------------------------------------------.
3301
| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
3302
`-----------------------------------------------------------*/
3303
0
yyexhaustedlab:
3304
0
  yyerror (YY_("memory exhausted"));
3305
0
  yyresult = 2;
3306
0
  goto yyreturnlab;
3307
3308
3309
/*----------------------------------------------------------.
3310
| yyreturnlab -- parsing is finished, clean up and return.  |
3311
`----------------------------------------------------------*/
3312
12.7k
yyreturnlab:
3313
12.7k
  if (yychar != YYEMPTY)
3314
294
    {
3315
      /* Make sure we have latest lookahead translation.  See comments at
3316
         user semantic actions for why this is necessary.  */
3317
294
      yytoken = YYTRANSLATE (yychar);
3318
294
      yydestruct ("Cleanup: discarding lookahead",
3319
294
                  yytoken, &yylval);
3320
294
    }
3321
  /* Do not reclaim the symbols of the rule whose action triggered
3322
     this YYABORT or YYACCEPT.  */
3323
12.7k
  YYPOPSTACK (yylen);
3324
12.7k
  YY_STACK_PRINT (yyss, yyssp);
3325
38.0k
  while (yyssp != yyss)
3326
25.2k
    {
3327
25.2k
      yydestruct ("Cleanup: popping",
3328
25.2k
                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
3329
25.2k
      YYPOPSTACK (1);
3330
25.2k
    }
3331
12.7k
#ifndef yyoverflow
3332
12.7k
  if (yyss != yyssa)
3333
0
    YYSTACK_FREE (yyss);
3334
12.7k
#endif
3335
3336
12.7k
  return yyresult;
3337
443k
}
3338
3339
#line 1162 "gram.y"
3340
3341
/* Like yyerror() but takes a printf-style format string. */
3342
void
3343
sudoerserrorf(const char * restrict fmt, ...)
3344
105k
{
3345
105k
    const int column = (int)(sudolinebuf.toke_start + 1);
3346
105k
    va_list ap;
3347
105k
    debug_decl(sudoerserrorf, SUDOERS_DEBUG_PARSER);
3348
3349
105k
    if (sudoers_error_hook != NULL) {
3350
0
  va_start(ap, fmt);
3351
0
  sudoers_error_hook(parsed_policy.ctx, sudoers, this_lineno, column,
3352
0
      fmt, ap);
3353
0
  va_end(ap);
3354
0
    }
3355
105k
    if (parser_conf.verbose > 0 && fmt != NULL) {
3356
0
  LEXTRACE("<*> ");
3357
0
#ifndef TRACELEXER
3358
0
  if (trace_print == NULL || trace_print == sudoers_trace_print) {
3359
0
      char *tofree = NULL;
3360
0
      const char *s;
3361
0
      int oldlocale;
3362
3363
      /* Warnings are displayed in the user's locale. */
3364
0
      sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
3365
3366
0
      va_start(ap, fmt);
3367
0
      if (strcmp(fmt, "%s") == 0) {
3368
    /* Optimize common case, a single string. */
3369
0
    s = _(va_arg(ap, char *));
3370
0
      } else {
3371
0
    if (vasprintf(&tofree, _(fmt), ap) != -1) {
3372
0
        s = tofree;
3373
0
    } else {
3374
0
        s = _("syntax error");
3375
0
        tofree = NULL;
3376
0
    }
3377
0
      }
3378
0
      sudo_printf(SUDO_CONV_ERROR_MSG, _("%s:%d:%zu: %s\n"), sudoers,
3379
0
    this_lineno, sudolinebuf.toke_start + 1, s);
3380
0
      free(tofree);
3381
0
      va_end(ap);
3382
0
      sudoers_setlocale(oldlocale, NULL);
3383
3384
      /* Display the offending line and token if possible. */
3385
0
      if (sudolinebuf.len != 0) {
3386
0
    char tildes[128];
3387
0
    size_t tlen = 0;
3388
3389
0
    sudo_printf(SUDO_CONV_ERROR_MSG, "%s%s", sudolinebuf.buf,
3390
0
        sudolinebuf.buf[sudolinebuf.len - 1] == '\n' ? "" : "\n");
3391
0
    if (sudolinebuf.toke_end > sudolinebuf.toke_start) {
3392
0
        tlen = sudolinebuf.toke_end - sudolinebuf.toke_start - 1;
3393
0
        if (tlen >= sizeof(tildes))
3394
0
      tlen = sizeof(tildes) - 1;
3395
0
        memset(tildes, '~', tlen);
3396
0
    }
3397
0
    tildes[tlen] = '\0';
3398
0
    sudo_printf(SUDO_CONV_ERROR_MSG, "%*s^%s\n",
3399
0
        (int)sudolinebuf.toke_start, "", tildes);
3400
0
      }
3401
0
  }
3402
0
#endif
3403
0
    }
3404
105k
    parse_error = true;
3405
105k
    debug_return;
3406
105k
}
3407
3408
void
3409
sudoerserror(const char *s)
3410
99.5k
{
3411
99.5k
    if (sudoerschar == ERROR) {
3412
  /* Use error string from lexer. */
3413
2.45k
  s = sudoers_errstr;
3414
2.45k
  sudoers_errstr = NULL;
3415
2.45k
    }
3416
3417
99.5k
#pragma pvs(push)
3418
99.5k
#pragma pvs(disable: 575, 618)
3419
3420
99.5k
    if (s == NULL)
3421
2.21k
  sudoerserrorf(NULL);
3422
97.3k
    else
3423
97.3k
  sudoerserrorf("%s", s);
3424
3425
99.5k
#pragma pvs(pop)
3426
99.5k
}
3427
3428
static void
3429
alias_error(const char *name, short type, int errnum)
3430
3.45k
{
3431
3.45k
    if (errnum == EEXIST) {
3432
3.45k
  struct alias *a = alias_get(&parsed_policy, name, type);
3433
3.45k
  if (a != NULL) {
3434
3.45k
      sudoerserrorf(
3435
3.45k
    U_("duplicate %s \"%s\", previously defined at %s:%d:%d"),
3436
3.45k
    alias_type_to_string(type), name, a->file, a->line, a->column);
3437
3.45k
      alias_put(a);
3438
3.45k
  } else {
3439
0
      if (errno == ELOOP) {
3440
0
    sudoerserrorf(U_("cycle in %s \"%s\""),
3441
0
        alias_type_to_string(type), name);
3442
0
      } else {
3443
0
    sudoerserrorf(U_("duplicate %s \"%s\""),
3444
0
        alias_type_to_string(type), name);
3445
0
      }
3446
0
  }
3447
3.45k
    } else {
3448
0
  sudoerserror(N_("unable to allocate memory"));
3449
0
    }
3450
3.45k
}
3451
3452
static struct defaults *
3453
new_default(char *var, char *val, short op)
3454
354k
{
3455
354k
    struct defaults *d;
3456
354k
    debug_decl(new_default, SUDOERS_DEBUG_PARSER);
3457
3458
354k
    if ((d = calloc(1, sizeof(struct defaults))) == NULL) {
3459
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3460
0
      "unable to allocate memory");
3461
0
  debug_return_ptr(NULL);
3462
0
    }
3463
3464
354k
    d->var = var;
3465
354k
    d->val = val;
3466
    /* d->type = 0; */
3467
354k
    d->op = op;
3468
    /* d->binding = NULL; */
3469
354k
    d->line = this_lineno;
3470
354k
    d->column = (int)(sudolinebuf.toke_start + 1);
3471
354k
    d->file = sudo_rcstr_addref(sudoers);
3472
354k
    HLTQ_INIT(d, entries);
3473
3474
354k
    debug_return_ptr(d);
3475
354k
}
3476
3477
static struct member *
3478
new_member(char *name, short type)
3479
327k
{
3480
327k
    struct member *m;
3481
327k
    debug_decl(new_member, SUDOERS_DEBUG_PARSER);
3482
3483
327k
    if ((m = calloc(1, sizeof(struct member))) == NULL) {
3484
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3485
0
      "unable to allocate memory");
3486
0
  debug_return_ptr(NULL);
3487
0
    }
3488
3489
327k
    m->name = name;
3490
327k
    m->type = type;
3491
327k
    HLTQ_INIT(m, entries);
3492
3493
327k
    debug_return_ptr(m);
3494
327k
}
3495
3496
static struct sudo_command *
3497
new_command(char *cmnd, char *args)
3498
15.6k
{
3499
15.6k
    struct sudo_command *c;
3500
15.6k
    debug_decl(new_command, SUDOERS_DEBUG_PARSER);
3501
3502
15.6k
    if ((c = calloc(1, sizeof(*c))) == NULL) {
3503
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3504
0
      "unable to allocate memory");
3505
0
  debug_return_ptr(NULL);
3506
0
    }
3507
    /* garbage collected as part of struct member */
3508
3509
15.6k
    c->cmnd = cmnd;
3510
15.6k
    c->args = args;
3511
15.6k
    TAILQ_INIT(&c->digests);
3512
3513
15.6k
    debug_return_ptr(c);
3514
15.6k
}
3515
3516
static struct command_digest *
3517
new_digest(unsigned int digest_type, char *digest_str)
3518
2.83k
{
3519
2.83k
    struct command_digest *digest;
3520
2.83k
    debug_decl(new_digest, SUDOERS_DEBUG_PARSER);
3521
3522
2.83k
    if ((digest = malloc(sizeof(*digest))) == NULL) {
3523
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3524
0
      "unable to allocate memory");
3525
0
  debug_return_ptr(NULL);
3526
0
    }
3527
3528
2.83k
    HLTQ_INIT(digest, entries);
3529
2.83k
    digest->digest_type = digest_type;
3530
2.83k
    digest->digest_str = digest_str;
3531
2.83k
    if (digest->digest_str == NULL) {
3532
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3533
0
      "unable to allocate memory");
3534
0
  free(digest);
3535
0
  digest = NULL;
3536
0
    }
3537
3538
2.83k
    debug_return_ptr(digest);
3539
2.83k
}
3540
3541
static void
3542
free_defaults_binding(struct defaults_binding *binding)
3543
492k
{
3544
492k
    debug_decl(free_defaults_binding, SUDOERS_DEBUG_PARSER);
3545
3546
    /* Bindings may be shared among multiple Defaults entries. */
3547
492k
    if (binding != NULL) {
3548
356k
  if (--binding->refcnt == 0) {
3549
9.23k
      free_members(&binding->members);
3550
9.23k
      free(binding);
3551
9.23k
  }
3552
356k
    }
3553
3554
492k
    debug_return;
3555
492k
}
3556
3557
/*
3558
 * Add a list of defaults structures to the defaults list.
3559
 * The bmem argument, if non-NULL, specifies a list of hosts, users,
3560
 * or runas users the entries apply to (determined by the type).
3561
 */
3562
static bool
3563
add_defaults(short type, struct member *bmem, struct defaults *defs)
3564
7.21k
{
3565
7.21k
    struct defaults *d, *next;
3566
7.21k
    struct defaults_binding *binding;
3567
7.21k
    bool ret = true;
3568
7.21k
    debug_decl(add_defaults, SUDOERS_DEBUG_PARSER);
3569
3570
7.21k
    if (defs == NULL)
3571
0
  debug_return_bool(false);
3572
3573
    /*
3574
     * We use a single binding for each entry in defs.
3575
     */
3576
7.21k
    if ((binding = malloc(sizeof(*binding))) == NULL) {
3577
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3578
0
      "unable to allocate memory");
3579
0
  sudoerserror(N_("unable to allocate memory"));
3580
0
  debug_return_bool(false);
3581
0
    }
3582
7.21k
    if (bmem != NULL) {
3583
3.52k
  parser_leak_remove(LEAK_MEMBER, bmem);
3584
3.52k
  HLTQ_TO_TAILQ(&binding->members, bmem, entries);
3585
3.69k
    } else {
3586
3.69k
  TAILQ_INIT(&binding->members);
3587
3.69k
    }
3588
7.21k
    binding->refcnt = 0;
3589
3590
    /*
3591
     * Set type and binding (who it applies to) for new entries.
3592
     * Then add to the global defaults list.
3593
     */
3594
7.21k
    parser_leak_remove(LEAK_DEFAULTS, defs);
3595
354k
    HLTQ_FOREACH_SAFE(d, defs, entries, next) {
3596
354k
  d->type = type;
3597
354k
  d->binding = binding;
3598
354k
  binding->refcnt++;
3599
354k
  TAILQ_INSERT_TAIL(&parsed_policy.defaults, d, entries);
3600
354k
    }
3601
3602
7.21k
    debug_return_bool(ret);
3603
7.21k
}
3604
3605
/*
3606
 * Allocate a new struct userspec, populate it, and insert it at the
3607
 * end of the userspecs list.
3608
 */
3609
static bool
3610
add_userspec(struct member *members, struct privilege *privs)
3611
15.0k
{
3612
15.0k
    struct userspec *u;
3613
15.0k
    debug_decl(add_userspec, SUDOERS_DEBUG_PARSER);
3614
3615
15.0k
    if ((u = calloc(1, sizeof(*u))) == NULL) {
3616
0
  sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
3617
0
      "unable to allocate memory");
3618
0
  debug_return_bool(false);
3619
0
    }
3620
    /* We already parsed the newline so sudolineno is off by one. */
3621
15.0k
    u->line = sudolineno - 1;
3622
15.0k
    u->column = (int)(sudolinebuf.toke_start + 1);
3623
15.0k
    u->file = sudo_rcstr_addref(sudoers);
3624
15.0k
    parser_leak_remove(LEAK_MEMBER, members);
3625
15.0k
    HLTQ_TO_TAILQ(&u->users, members, entries);
3626
15.0k
    parser_leak_remove(LEAK_PRIVILEGE, privs);
3627
15.0k
    HLTQ_TO_TAILQ(&u->privileges, privs, entries);
3628
15.0k
    STAILQ_INIT(&u->comments);
3629
15.0k
    TAILQ_INSERT_TAIL(&parsed_policy.userspecs, u, entries);
3630
3631
15.0k
    debug_return_bool(true);
3632
15.0k
}
3633
3634
/*
3635
 * Free a member struct and its contents.
3636
 */
3637
void
3638
free_member(struct member *m)
3639
427k
{
3640
427k
    debug_decl(free_member, SUDOERS_DEBUG_PARSER);
3641
3642
427k
    if (m->type == COMMAND || (m->type == ALL && m->name != NULL)) {
3643
50.3k
  struct command_digest *digest;
3644
50.3k
  struct sudo_command *c = (struct sudo_command *)m->name;
3645
50.3k
  free(c->cmnd);
3646
50.3k
  free(c->args);
3647
54.4k
  while ((digest = TAILQ_FIRST(&c->digests)) != NULL) {
3648
4.16k
      TAILQ_REMOVE(&c->digests, digest, entries);
3649
4.16k
      free(digest->digest_str);
3650
4.16k
      free(digest);
3651
4.16k
  }
3652
50.3k
    }
3653
427k
    free(m->name);
3654
427k
    free(m);
3655
3656
427k
    debug_return;
3657
427k
}
3658
3659
/*
3660
 * Free a tailq of members but not the struct member_list container itself.
3661
 */
3662
void
3663
free_members(struct member_list *members)
3664
107k
{
3665
107k
    struct member *m;
3666
107k
    debug_decl(free_members, SUDOERS_DEBUG_PARSER);
3667
3668
286k
    while ((m = TAILQ_FIRST(members)) != NULL) {
3669
178k
  TAILQ_REMOVE(members, m, entries);
3670
178k
  free_member(m);
3671
178k
    }
3672
3673
107k
    debug_return;
3674
107k
}
3675
3676
void
3677
free_defaults(struct defaults_list *defs)
3678
100k
{
3679
100k
    struct defaults *def;
3680
100k
    debug_decl(free_defaults, SUDOERS_DEBUG_PARSER);
3681
3682
457k
    while ((def = TAILQ_FIRST(defs)) != NULL) {
3683
356k
  TAILQ_REMOVE(defs, def, entries);
3684
356k
  free_default(def);
3685
356k
    }
3686
3687
100k
    debug_return;
3688
100k
}
3689
3690
void
3691
free_default(struct defaults *def)
3692
492k
{
3693
492k
    debug_decl(free_default, SUDOERS_DEBUG_PARSER);
3694
3695
492k
    free_defaults_binding(def->binding);
3696
492k
    sudo_rcstr_delref(def->file);
3697
492k
    free(def->var);
3698
492k
    free(def->val);
3699
492k
    free(def);
3700
3701
492k
    debug_return;
3702
492k
}
3703
3704
void
3705
free_cmndspec(struct cmndspec *cs, struct cmndspec_list *csl)
3706
0
{
3707
0
    struct cmndspec *prev, *next;
3708
0
    debug_decl(free_cmndspec, SUDOERS_DEBUG_PARSER);
3709
3710
0
    prev = TAILQ_PREV(cs, cmndspec_list, entries);
3711
0
    next = TAILQ_NEXT(cs, entries);
3712
0
    TAILQ_REMOVE(csl, cs, entries);
3713
3714
    /* Don't free runcwd/runchroot that are in use by other entries. */
3715
0
    if ((prev == NULL || cs->runcwd != prev->runcwd) &&
3716
0
  (next == NULL || cs->runcwd != next->runcwd)) {
3717
0
  free(cs->runcwd);
3718
0
    }
3719
0
    if ((prev == NULL || cs->runchroot != prev->runchroot) &&
3720
0
  (next == NULL || cs->runchroot != next->runchroot)) {
3721
0
  free(cs->runchroot);
3722
0
    }
3723
    /* Don't free root/type that are in use by other entries. */
3724
0
    if ((prev == NULL || cs->role != prev->role) &&
3725
0
  (next == NULL || cs->role != next->role)) {
3726
0
  free(cs->role);
3727
0
    }
3728
0
    if ((prev == NULL || cs->type != prev->type) &&
3729
0
  (next == NULL || cs->type != next->type)) {
3730
0
  free(cs->type);
3731
0
    }
3732
    /* Don't free apparmor_profile that is in use by other entries. */
3733
0
    if ((prev == NULL || cs->apparmor_profile != prev->apparmor_profile) &&
3734
0
  (next == NULL || cs->apparmor_profile != next->apparmor_profile)) {
3735
0
  free(cs->apparmor_profile);
3736
0
    }
3737
    /* Don't free privs/limitprivs that are in use by other entries. */
3738
0
    if ((prev == NULL || cs->privs != prev->privs) &&
3739
0
  (next == NULL || cs->privs != next->privs)) {
3740
0
  free(cs->privs);
3741
0
    }
3742
0
    if ((prev == NULL || cs->limitprivs != prev->limitprivs) &&
3743
0
  (next == NULL || cs->limitprivs != next->limitprivs)) {
3744
0
  free(cs->limitprivs);
3745
0
    }
3746
    /* Don't free user/group lists that are in use by other entries. */
3747
0
    if (cs->runasuserlist != NULL) {
3748
0
  if ((prev == NULL || cs->runasuserlist != prev->runasuserlist) &&
3749
0
      (next == NULL || cs->runasuserlist != next->runasuserlist)) {
3750
0
      free_members(cs->runasuserlist);
3751
0
      free(cs->runasuserlist);
3752
0
  }
3753
0
    }
3754
0
    if (cs->runasgrouplist != NULL) {
3755
0
  if ((prev == NULL || cs->runasgrouplist != prev->runasgrouplist) &&
3756
0
      (next == NULL || cs->runasgrouplist != next->runasgrouplist)) {
3757
0
      free_members(cs->runasgrouplist);
3758
0
      free(cs->runasgrouplist);
3759
0
  }
3760
0
    }
3761
0
    free_member(cs->cmnd);
3762
0
    free(cs);
3763
3764
0
    debug_return;
3765
0
}
3766
3767
void
3768
free_cmndspecs(struct cmndspec_list *csl)
3769
46.7k
{
3770
46.7k
    struct member_list *runasuserlist = NULL, *runasgrouplist = NULL;
3771
46.7k
    char *runcwd = NULL, *runchroot = NULL;
3772
46.7k
    char *role = NULL, *type = NULL;
3773
46.7k
    char *apparmor_profile = NULL;
3774
46.7k
    char *privs = NULL, *limitprivs = NULL;
3775
46.7k
    struct cmndspec *cs;
3776
46.7k
    debug_decl(free_cmndspecs, SUDOERS_DEBUG_PARSER);
3777
3778
133k
    while ((cs = TAILQ_FIRST(csl)) != NULL) {
3779
86.4k
  TAILQ_REMOVE(csl, cs, entries);
3780
3781
  /* Only free the first instance of runcwd/runchroot. */
3782
86.4k
  if (cs->runcwd != runcwd) {
3783
1.86k
      runcwd = cs->runcwd;
3784
1.86k
      free(cs->runcwd);
3785
1.86k
  }
3786
86.4k
  if (cs->runchroot != runchroot) {
3787
1.24k
      runchroot = cs->runchroot;
3788
1.24k
      free(cs->runchroot);
3789
1.24k
  }
3790
  /* Only free the first instance of a role/type. */
3791
86.4k
  if (cs->role != role) {
3792
1.12k
      role = cs->role;
3793
1.12k
      free(cs->role);
3794
1.12k
  }
3795
86.4k
  if (cs->type != type) {
3796
909
      type = cs->type;
3797
909
      free(cs->type);
3798
909
  }
3799
  /* Only free the first instance of apparmor_profile. */
3800
86.4k
  if (cs->apparmor_profile != apparmor_profile) {
3801
1.09k
      apparmor_profile = cs->apparmor_profile;
3802
1.09k
      free(cs->apparmor_profile);
3803
1.09k
  }
3804
  /* Only free the first instance of privs/limitprivs. */
3805
86.4k
  if (cs->privs != privs) {
3806
1.48k
      privs = cs->privs;
3807
1.48k
      free(cs->privs);
3808
1.48k
  }
3809
86.4k
  if (cs->limitprivs != limitprivs) {
3810
1.49k
      limitprivs = cs->limitprivs;
3811
1.49k
      free(cs->limitprivs);
3812
1.49k
  }
3813
  /* Only free the first instance of runas user/group lists. */
3814
86.4k
  if (cs->runasuserlist && cs->runasuserlist != runasuserlist) {
3815
13.3k
      runasuserlist = cs->runasuserlist;
3816
13.3k
      free_members(runasuserlist);
3817
13.3k
      free(runasuserlist);
3818
13.3k
  }
3819
86.4k
  if (cs->runasgrouplist && cs->runasgrouplist != runasgrouplist) {
3820
2.83k
      runasgrouplist = cs->runasgrouplist;
3821
2.83k
      free_members(runasgrouplist);
3822
2.83k
      free(runasgrouplist);
3823
2.83k
  }
3824
86.4k
  free_member(cs->cmnd);
3825
86.4k
  free(cs);
3826
86.4k
    }
3827
3828
46.7k
    debug_return;
3829
46.7k
}
3830
3831
void
3832
free_privilege(struct privilege *priv)
3833
45.7k
{
3834
45.7k
    struct defaults *def;
3835
45.7k
    debug_decl(free_privilege, SUDOERS_DEBUG_PARSER);
3836
3837
45.7k
    free(priv->ldap_role);
3838
45.7k
    free_members(&priv->hostlist);
3839
45.7k
    free_cmndspecs(&priv->cmndlist);
3840
181k
    while ((def = TAILQ_FIRST(&priv->defaults)) != NULL) {
3841
135k
  TAILQ_REMOVE(&priv->defaults, def, entries);
3842
135k
  free_default(def);
3843
135k
    }
3844
45.7k
    free(priv);
3845
3846
45.7k
    debug_return;
3847
45.7k
}
3848
3849
void
3850
free_userspecs(struct userspec_list *usl)
3851
100k
{
3852
100k
    struct userspec *us;
3853
100k
    debug_decl(free_userspecs, SUDOERS_DEBUG_PARSER);
3854
3855
133k
    while ((us = TAILQ_FIRST(usl)) != NULL) {
3856
33.5k
  TAILQ_REMOVE(usl, us, entries);
3857
33.5k
  free_userspec(us);
3858
33.5k
    }
3859
3860
100k
    debug_return;
3861
100k
}
3862
3863
void
3864
free_userspec(struct userspec *us)
3865
33.8k
{
3866
33.8k
    struct privilege *priv;
3867
33.8k
    struct sudoers_comment *comment;
3868
33.8k
    debug_decl(free_userspec, SUDOERS_DEBUG_PARSER);
3869
3870
33.8k
    free_members(&us->users);
3871
75.8k
    while ((priv = TAILQ_FIRST(&us->privileges)) != NULL) {
3872
41.9k
  TAILQ_REMOVE(&us->privileges, priv, entries);
3873
41.9k
  free_privilege(priv);
3874
41.9k
    }
3875
35.4k
    while ((comment = STAILQ_FIRST(&us->comments)) != NULL) {
3876
1.56k
  STAILQ_REMOVE_HEAD(&us->comments, entries);
3877
1.56k
  free(comment->str);
3878
1.56k
  free(comment);
3879
1.56k
    }
3880
33.8k
    sudo_rcstr_delref(us->file);
3881
33.8k
    free(us);
3882
3883
33.8k
    debug_return;
3884
33.8k
}
3885
3886
/*
3887
 * Initialized a sudoers parse tree.
3888
 * Takes ownership of lhost and shost.
3889
 */
3890
void
3891
init_parse_tree(struct sudoers_parse_tree *parse_tree, char *lhost, char *shost,
3892
    struct sudoers_context *ctx, struct sudo_nss *nss)
3893
17.9k
{
3894
17.9k
    TAILQ_INIT(&parse_tree->userspecs);
3895
17.9k
    TAILQ_INIT(&parse_tree->defaults);
3896
17.9k
    parse_tree->aliases = NULL;
3897
17.9k
    parse_tree->shost = shost;
3898
17.9k
    parse_tree->lhost = lhost;
3899
17.9k
    parse_tree->ctx = ctx;
3900
17.9k
    parse_tree->nss = nss;
3901
17.9k
}
3902
3903
/*
3904
 * Move the contents of parsed_policy to new_tree.
3905
 */
3906
void
3907
reparent_parse_tree(struct sudoers_parse_tree *new_tree)
3908
12.7k
{
3909
12.7k
    TAILQ_CONCAT(&new_tree->userspecs, &parsed_policy.userspecs, entries);
3910
12.7k
    TAILQ_CONCAT(&new_tree->defaults, &parsed_policy.defaults, entries);
3911
12.7k
    new_tree->aliases = parsed_policy.aliases;
3912
12.7k
    parsed_policy.aliases = NULL;
3913
12.7k
}
3914
3915
/*
3916
 * Free the contents of a sudoers parse tree and initialize it.
3917
 */
3918
void
3919
free_parse_tree(struct sudoers_parse_tree *parse_tree)
3920
100k
{
3921
100k
    free_userspecs(&parse_tree->userspecs);
3922
100k
    free_defaults(&parse_tree->defaults);
3923
100k
    free_aliases(parse_tree->aliases);
3924
100k
    parse_tree->aliases = NULL;
3925
100k
    free(parse_tree->lhost);
3926
100k
    if (parse_tree->shost != parse_tree->lhost)
3927
0
  free(parse_tree->shost);
3928
100k
    parse_tree->lhost = parse_tree->shost = NULL;
3929
100k
    parse_tree->nss = NULL;
3930
100k
    parse_tree->ctx = NULL;
3931
100k
}
3932
3933
/*
3934
 * Free up space used by data structures from a previous parser run and sets
3935
 * the current sudoers file to path.
3936
 */
3937
bool
3938
init_parser(struct sudoers_context *ctx, const char *file)
3939
82.4k
{
3940
82.4k
    bool ret = true;
3941
82.4k
    debug_decl(init_parser, SUDOERS_DEBUG_PARSER);
3942
3943
82.4k
    free_parse_tree(&parsed_policy);
3944
82.4k
    parsed_policy.ctx = ctx;
3945
82.4k
    parser_leak_init();
3946
82.4k
    init_lexer();
3947
82.4k
    parse_error = false;
3948
3949
82.4k
    if (ctx != NULL) {
3950
12.7k
  parser_conf = ctx->parser_conf;
3951
69.6k
    } else {
3952
69.6k
  const struct sudoers_parser_config def_conf =
3953
69.6k
      SUDOERS_PARSER_CONFIG_INITIALIZER;
3954
69.6k
  parser_conf = def_conf;
3955
69.6k
    }
3956
3957
82.4k
    sudo_rcstr_delref(sudoers);
3958
82.4k
    if (file != NULL) {
3959
12.7k
  if ((sudoers = sudo_rcstr_dup(file)) == NULL) {
3960
0
      sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
3961
0
      ret = false;
3962
0
  }
3963
69.6k
    } else {
3964
69.6k
  sudoers = NULL;
3965
69.6k
    }
3966
3967
82.4k
    sudo_rcstr_delref(sudoers_search_path);
3968
82.4k
    if (parser_conf.sudoers_path != NULL) {
3969
0
  sudoers_search_path = sudo_rcstr_dup(parser_conf.sudoers_path);
3970
0
  if (sudoers_search_path == NULL) {
3971
0
      sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
3972
0
      ret = false;
3973
0
  }
3974
82.4k
    } else {
3975
82.4k
  sudoers_search_path = NULL;
3976
82.4k
    }
3977
3978
82.4k
    debug_return_bool(ret);
3979
82.4k
}
3980
3981
bool
3982
reset_parser(void)
3983
69.6k
{
3984
69.6k
    return init_parser(NULL, NULL);
3985
69.6k
}
3986
3987
/*
3988
 * Initialize all options in a cmndspec.
3989
 */
3990
static void
3991
init_options(struct command_options *opts)
3992
90.9k
{
3993
90.9k
    opts->notbefore = UNSPEC;
3994
90.9k
    opts->notafter = UNSPEC;
3995
90.9k
    opts->timeout = UNSPEC;
3996
90.9k
    opts->runchroot = NULL;
3997
90.9k
    opts->runcwd = NULL;
3998
90.9k
    opts->role = NULL;
3999
90.9k
    opts->type = NULL;
4000
90.9k
    opts->apparmor_profile = NULL;
4001
90.9k
    opts->privs = NULL;
4002
90.9k
    opts->limitprivs = NULL;
4003
90.9k
}
4004
4005
/*
4006
 * Propagate inheritable settings and tags from prev to cs.
4007
 */
4008
static void
4009
propagate_cmndspec(struct cmndspec *cs, const struct cmndspec *prev)
4010
31.3k
{
4011
    /* propagate runcwd and runchroot */
4012
31.3k
    if (cs->runcwd == NULL)
4013
30.3k
  cs->runcwd = prev->runcwd;
4014
31.3k
    if (cs->runchroot == NULL)
4015
30.6k
  cs->runchroot = prev->runchroot;
4016
    /* propagate role and type */
4017
31.3k
    if (cs->role == NULL && cs->type == NULL) {
4018
30.4k
  cs->role = prev->role;
4019
30.4k
  cs->type = prev->type;
4020
30.4k
    }
4021
    /* propagate apparmor_profile */
4022
31.3k
    if (cs->apparmor_profile == NULL)
4023
30.7k
  cs->apparmor_profile = prev->apparmor_profile;
4024
    /* propagate privs & limitprivs */
4025
31.3k
    if (cs->privs == NULL && cs->limitprivs == NULL) {
4026
29.7k
  cs->privs = prev->privs;
4027
29.7k
  cs->limitprivs = prev->limitprivs;
4028
29.7k
    }
4029
    /* propagate command time restrictions */
4030
31.3k
    if (cs->notbefore == UNSPEC)
4031
30.9k
  cs->notbefore = prev->notbefore;
4032
31.3k
    if (cs->notafter == UNSPEC)
4033
31.0k
  cs->notafter = prev->notafter;
4034
    /* propagate command timeout */
4035
31.3k
    if (cs->timeout == UNSPEC)
4036
30.7k
  cs->timeout = prev->timeout;
4037
    /* propagate tags and runas list */
4038
31.3k
    if (cs->tags.nopasswd == UNSPEC)
4039
31.0k
  cs->tags.nopasswd = prev->tags.nopasswd;
4040
31.3k
    if (cs->tags.noexec == UNSPEC)
4041
30.8k
  cs->tags.noexec = prev->tags.noexec;
4042
31.3k
    if (cs->tags.intercept == UNSPEC)
4043
31.3k
  cs->tags.intercept = prev->tags.intercept;
4044
    /* Need to handle IMPLIED setting for SETENV tag specially. */
4045
31.3k
    if (!TAG_SET(cs->tags.setenv) && TAG_SET(prev->tags.setenv))
4046
2.11k
  cs->tags.setenv = prev->tags.setenv;
4047
31.3k
    if (cs->tags.log_input == UNSPEC)
4048
30.7k
  cs->tags.log_input = prev->tags.log_input;
4049
31.3k
    if (cs->tags.log_output == UNSPEC)
4050
31.0k
  cs->tags.log_output = prev->tags.log_output;
4051
31.3k
    if (cs->tags.send_mail == UNSPEC)
4052
31.0k
  cs->tags.send_mail = prev->tags.send_mail;
4053
31.3k
    if (cs->tags.follow == UNSPEC)
4054
30.4k
  cs->tags.follow = prev->tags.follow;
4055
31.3k
    if ((cs->runasuserlist == NULL &&
4056
23.8k
   cs->runasgrouplist == NULL) &&
4057
23.8k
  (prev->runasuserlist != NULL ||
4058
17.3k
   prev->runasgrouplist != NULL)) {
4059
6.49k
  cs->runasuserlist = prev->runasuserlist;
4060
6.49k
  cs->runasgrouplist = prev->runasgrouplist;
4061
6.49k
    }
4062
31.3k
}
4063
4064
uid_t
4065
sudoers_file_uid(void)
4066
7.82k
{
4067
7.82k
    return parser_conf.sudoers_uid;
4068
7.82k
}
4069
4070
gid_t
4071
sudoers_file_gid(void)
4072
7.82k
{
4073
7.82k
    return parser_conf.sudoers_gid;
4074
7.82k
}
4075
4076
mode_t
4077
sudoers_file_mode(void)
4078
0
{
4079
0
    return parser_conf.sudoers_mode;
4080
0
}
4081
4082
bool
4083
sudoers_error_recovery(void)
4084
0
{
4085
0
    return parser_conf.recovery;
4086
0
}
4087
4088
bool
4089
sudoers_strict(void)
4090
2.81k
{
4091
2.81k
    return parser_conf.strict;
4092
2.81k
}
4093
4094
bool
4095
parser_leak_add(enum parser_leak_types type, void *v)
4096
1.61M
{
4097
1.61M
#ifdef NO_LEAKS
4098
1.61M
    struct parser_leak_entry *entry;
4099
1.61M
    debug_decl(parser_leak_add, SUDOERS_DEBUG_PARSER);
4100
4101
1.61M
    if (v == NULL)
4102
0
  debug_return_bool(false);
4103
4104
1.61M
    entry = calloc(1, sizeof(*entry));
4105
1.61M
    if (entry == NULL) {
4106
0
  sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
4107
0
  debug_return_bool(false);
4108
0
    }
4109
1.61M
    switch (type) {
4110
19.2k
    case LEAK_PRIVILEGE:
4111
19.2k
  entry->u.p = v;
4112
19.2k
  break;
4113
51.5k
    case LEAK_CMNDSPEC:
4114
51.5k
  entry->u.cs = v;
4115
51.5k
  break;
4116
354k
    case LEAK_DEFAULTS:
4117
354k
  entry->u.d = v;
4118
354k
  break;
4119
309k
    case LEAK_MEMBER:
4120
309k
  entry->u.m = v;
4121
309k
  break;
4122
2.83k
    case LEAK_DIGEST:
4123
2.83k
  entry->u.dig = v;
4124
2.83k
  break;
4125
19.3k
    case LEAK_RUNAS:
4126
19.3k
  entry->u.rc = v;
4127
19.3k
  break;
4128
857k
    case LEAK_PTR:
4129
857k
  entry->u.ptr = v;
4130
857k
  break;
4131
0
    default:
4132
0
  free(entry);
4133
0
  sudo_warnx("unexpected leak type %d", type);
4134
0
  debug_return_bool(false);
4135
1.61M
    }
4136
1.61M
    entry->type = type;
4137
1.61M
    SLIST_INSERT_HEAD(&parser_leak_list, entry, entries);
4138
1.61M
    debug_return_bool(true);
4139
#else
4140
    return true;
4141
#endif /* NO_LEAKS */
4142
1.61M
}
4143
4144
bool
4145
parser_leak_remove(enum parser_leak_types type, void *v)
4146
1.71M
{
4147
1.71M
#ifdef NO_LEAKS
4148
1.71M
    struct parser_leak_entry *entry, *prev = NULL;
4149
1.71M
    debug_decl(parser_leak_remove, SUDOERS_DEBUG_PARSER);
4150
4151
1.71M
    if (v == NULL)
4152
386k
  debug_return_bool(false);
4153
4154
1.52M
    SLIST_FOREACH(entry, &parser_leak_list, entries) {
4155
1.52M
  switch (entry->type) {
4156
69.3k
  case LEAK_PRIVILEGE:
4157
69.3k
      if (entry->u.p == v)
4158
15.9k
        goto found;
4159
53.4k
      break;
4160
137k
  case LEAK_CMNDSPEC:
4161
137k
      if (entry->u.cs == v)
4162
50.5k
        goto found;
4163
86.4k
      break;
4164
357k
  case LEAK_DEFAULTS:
4165
357k
      if (entry->u.d == v)
4166
354k
        goto found;
4167
3.52k
      break;
4168
192k
  case LEAK_MEMBER:
4169
192k
      if (entry->u.m == v)
4170
169k
        goto found;
4171
23.0k
      break;
4172
23.0k
  case LEAK_DIGEST:
4173
2.51k
      if (entry->u.dig == v)
4174
2.32k
        goto found;
4175
190
      break;
4176
17.4k
  case LEAK_RUNAS:
4177
17.4k
      if (entry->u.rc == v)
4178
8.73k
        goto found;
4179
8.74k
      break;
4180
743k
  case LEAK_PTR:
4181
743k
      if (entry->u.ptr == v)
4182
727k
        goto found;
4183
16.4k
      break;
4184
16.4k
  default:
4185
0
      sudo_warnx("unexpected leak type %d in %p", entry->type, entry);
4186
1.52M
  }
4187
191k
  prev = entry;
4188
191k
    }
4189
    /* If this happens, there is a bug in the leak tracking code. */
4190
0
    sudo_warnx("%s: unable to find %p, type %d", __func__, v, type);
4191
0
    debug_return_bool(false);
4192
1.32M
found:
4193
1.32M
    if (prev == NULL)
4194
1.18M
  SLIST_REMOVE_HEAD(&parser_leak_list, entries);
4195
148k
    else
4196
148k
  SLIST_REMOVE_AFTER(prev, entries);
4197
1.32M
    free(entry);
4198
1.32M
    debug_return_bool(true);
4199
#else
4200
    return true;
4201
#endif /* NO_LEAKS */
4202
1.32M
}
4203
4204
#ifdef NO_LEAKS
4205
static void
4206
parser_leak_free(void)
4207
82.4k
{
4208
82.4k
    struct parser_leak_entry *entry;
4209
82.4k
    void *next;
4210
82.4k
    debug_decl(parser_leak_run, SUDOERS_DEBUG_PARSER);
4211
4212
    /* Free the leaks. */
4213
368k
    while ((entry = SLIST_FIRST(&parser_leak_list))) {
4214
286k
  SLIST_REMOVE_HEAD(&parser_leak_list, entries);
4215
286k
  switch (entry->type) {
4216
3.29k
  case LEAK_PRIVILEGE:
4217
3.29k
      {
4218
3.29k
    struct privilege *priv;
4219
4220
3.29k
    HLTQ_FOREACH_SAFE(priv, entry->u.p, entries, next)
4221
3.49k
        free_privilege(priv);
4222
3.29k
    free(entry);
4223
3.29k
      }
4224
3.29k
      break;
4225
977
  case LEAK_CMNDSPEC:
4226
977
      {
4227
977
    struct cmndspec_list specs;
4228
4229
977
    HLTQ_TO_TAILQ(&specs, entry->u.cs, entries);
4230
977
    free_cmndspecs(&specs);
4231
977
    free(entry);
4232
977
      }
4233
977
      break;
4234
380
  case LEAK_DEFAULTS:
4235
380
      {
4236
380
    struct defaults_list defs;
4237
4238
380
    HLTQ_TO_TAILQ(&defs, entry->u.d, entries);
4239
380
    free_defaults(&defs);
4240
380
    free(entry);
4241
380
      }
4242
380
      break;
4243
140k
  case LEAK_MEMBER:
4244
140k
      {
4245
140k
    struct member *m;
4246
4247
140k
    HLTQ_FOREACH_SAFE(m, entry->u.m, entries, next)
4248
145k
        free_member(m);
4249
140k
    free(entry);
4250
140k
      }
4251
140k
      break;
4252
516
  case LEAK_DIGEST:
4253
516
      {
4254
516
    struct command_digest *dig;
4255
4256
587
    HLTQ_FOREACH_SAFE(dig, entry->u.dig, entries, next) {
4257
587
        free(dig->digest_str);
4258
587
        free(dig);
4259
587
    }
4260
516
    free(entry);
4261
516
      }
4262
516
      break;
4263
10.6k
  case LEAK_RUNAS:
4264
10.6k
      {
4265
10.6k
    struct member *m;
4266
4267
10.6k
    if (entry->u.rc->runasusers != NULL) {
4268
10.6k
        HLTQ_FOREACH_SAFE(m, entry->u.rc->runasusers, entries, next)
4269
11.5k
      free_member(m);
4270
10.6k
    }
4271
10.6k
    if (entry->u.rc->runasgroups != NULL) {
4272
4.44k
        HLTQ_FOREACH_SAFE(m, entry->u.rc->runasgroups, entries, next)
4273
5.31k
      free_member(m);
4274
4.44k
    }
4275
10.6k
    free(entry->u.rc);
4276
10.6k
    free(entry);
4277
10.6k
    break;
4278
0
      }
4279
130k
  case LEAK_PTR:
4280
130k
      free(entry->u.ptr);
4281
130k
      free(entry);
4282
130k
      break;
4283
0
  default:
4284
0
      sudo_warnx("unexpected garbage type %d", entry->type);
4285
286k
  }
4286
286k
    }
4287
4288
82.4k
    debug_return;
4289
82.4k
}
4290
#endif /* NO_LEAKS */
4291
4292
void
4293
parser_leak_init(void)
4294
82.4k
{
4295
82.4k
#ifdef NO_LEAKS
4296
82.4k
    static bool initialized;
4297
82.4k
    debug_decl(parser_leak_init, SUDOERS_DEBUG_PARSER);
4298
4299
82.4k
    if (!initialized) {
4300
2
  atexit(parser_leak_free);
4301
2
  initialized = true;
4302
2
  debug_return;
4303
2
    }
4304
4305
    /* Already initialized, free existing leaks. */
4306
82.4k
    parser_leak_free();
4307
82.4k
    debug_return;
4308
82.4k
#endif /* NO_LEAKS */
4309
82.4k
}