# include <ndir.h>
# endif
#endif
+#include <errno.h>
#include <ctype.h>
#include "sudoers.h"
#include "parse.h"
#define INSTR 5
-#line 1509 "lex.yy.c"
+#line 1510 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 118 "toke.l"
+#line 119 "toke.l"
-#line 1665 "lex.yy.c"
+#line 1666 "lex.yy.c"
if ( yy_init )
{
case 1:
YY_RULE_SETUP
-#line 119 "toke.l"
+#line 120 "toke.l"
{
LEXTRACE(", ");
return ',';
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 124 "toke.l"
+#line 125 "toke.l"
BEGIN STARTDEFS;
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 126 "toke.l"
+#line 127 "toke.l"
{
BEGIN INDEFS;
LEXTRACE("DEFVAR ");
case 4:
YY_RULE_SETUP
-#line 135 "toke.l"
+#line 136 "toke.l"
{
BEGIN STARTDEFS;
LEXTRACE(", ");
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 141 "toke.l"
+#line 142 "toke.l"
{
LEXTRACE("= ");
return '=';
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 146 "toke.l"
+#line 147 "toke.l"
{
LEXTRACE("+= ");
return '+';
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 151 "toke.l"
+#line 152 "toke.l"
{
LEXTRACE("-= ");
return '-';
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 156 "toke.l"
+#line 157 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 163 "toke.l"
+#line 164 "toke.l"
{
LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng))
case 10:
YY_RULE_SETUP
-#line 172 "toke.l"
+#line 173 "toke.l"
{
/* Line continuation char followed by newline. */
++sudolineno;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 178 "toke.l"
+#line 179 "toke.l"
{
LEXTRACE("ENDSTR ");
BEGIN prev_state;
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 210 "toke.l"
+#line 211 "toke.l"
{
LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng))
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 216 "toke.l"
+#line 217 "toke.l"
{
LEXTRACE("STRBODY ");
if (!append(yytext, yyleng))
case 14:
YY_RULE_SETUP
-#line 224 "toke.l"
+#line 225 "toke.l"
{
/* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 232 "toke.l"
+#line 233 "toke.l"
{
/* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 240 "toke.l"
+#line 241 "toke.l"
{
BEGIN INITIAL;
yyless(0);
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 246 "toke.l"
+#line 247 "toke.l"
{
LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace))
case 18:
YY_RULE_SETUP
-#line 254 "toke.l"
+#line 255 "toke.l"
{
char *path;
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 272 "toke.l"
+#line 273 "toke.l"
{
char *path;
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 293 "toke.l"
+#line 294 "toke.l"
{
char deftype;
int n;
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 333 "toke.l"
+#line 334 "toke.l"
{
int n;
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 359 "toke.l"
+#line 360 "toke.l"
{
/* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD ");
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 365 "toke.l"
+#line 366 "toke.l"
{
/* cmnd requires passwd for this user */
LEXTRACE("PASSWD ");
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 371 "toke.l"
+#line 372 "toke.l"
{
LEXTRACE("NOEXEC ");
return NOEXEC;
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 376 "toke.l"
+#line 377 "toke.l"
{
LEXTRACE("EXEC ");
return EXEC;
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 381 "toke.l"
+#line 382 "toke.l"
{
LEXTRACE("SETENV ");
return SETENV;
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 386 "toke.l"
+#line 387 "toke.l"
{
LEXTRACE("NOSETENV ");
return NOSETENV;
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 391 "toke.l"
+#line 392 "toke.l"
{
LEXTRACE("LOG_OUTPUT ");
return LOG_OUTPUT;
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 396 "toke.l"
+#line 397 "toke.l"
{
LEXTRACE("NOLOG_OUTPUT ");
return NOLOG_OUTPUT;
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 401 "toke.l"
+#line 402 "toke.l"
{
LEXTRACE("LOG_INPUT ");
return LOG_INPUT;
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 406 "toke.l"
+#line 407 "toke.l"
{
LEXTRACE("NOLOG_INPUT ");
return NOLOG_INPUT;
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 411 "toke.l"
+#line 412 "toke.l"
{
/* empty group or netgroup */
LEXTRACE("ERROR ");
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 417 "toke.l"
+#line 418 "toke.l"
{
/* netgroup */
if (!fill(yytext, yyleng))
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 425 "toke.l"
+#line 426 "toke.l"
{
/* group */
if (!fill(yytext, yyleng))
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 433 "toke.l"
+#line 434 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 440 "toke.l"
+#line 441 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 447 "toke.l"
+#line 448 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 458 "toke.l"
+#line 459 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 469 "toke.l"
+#line 470 "toke.l"
{
if (strcmp(yytext, "ALL") == 0) {
LEXTRACE("ALL ");
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 491 "toke.l"
+#line 492 "toke.l"
{
/* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng))
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 499 "toke.l"
+#line 500 "toke.l"
{
BEGIN GOTCMND;
LEXTRACE("COMMAND ");
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 506 "toke.l"
+#line 507 "toke.l"
{
/* directories can't have args... */
if (yytext[yyleng - 1] == '/') {
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 521 "toke.l"
+#line 522 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 528 "toke.l"
+#line 529 "toke.l"
{
/* a word */
if (!fill(yytext, yyleng))
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 536 "toke.l"
+#line 537 "toke.l"
{
LEXTRACE("( ");
return '(';
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 541 "toke.l"
+#line 542 "toke.l"
{
LEXTRACE(") ");
return ')';
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 546 "toke.l"
+#line 547 "toke.l"
{
LEXTRACE(", ");
return ',';
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 551 "toke.l"
+#line 552 "toke.l"
{
LEXTRACE("= ");
return '=';
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 556 "toke.l"
+#line 557 "toke.l"
{
LEXTRACE(": ");
return ':';
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 561 "toke.l"
+#line 562 "toke.l"
{
if (yyleng & 1) {
LEXTRACE("!");
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 568 "toke.l"
+#line 569 "toke.l"
{
if (YY_START == INSTR) {
LEXTRACE("ERROR ");
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 580 "toke.l"
+#line 581 "toke.l"
{ /* throw away space/tabs */
sawspace = TRUE; /* but remember for fill_args */
}
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 584 "toke.l"
+#line 585 "toke.l"
{
sawspace = TRUE; /* remember for fill_args */
++sudolineno;
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 590 "toke.l"
+#line 591 "toke.l"
{
BEGIN INITIAL;
++sudolineno;
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 598 "toke.l"
+#line 599 "toke.l"
{
LEXTRACE("ERROR ");
return ERROR;
case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR):
-#line 603 "toke.l"
+#line 604 "toke.l"
{
if (YY_START != INITIAL) {
BEGIN INITIAL;
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 613 "toke.l"
+#line 614 "toke.l"
ECHO;
YY_BREAK
-#line 2420 "lex.yy.c"
+#line 2421 "lex.yy.c"
case YY_END_OF_BUFFER:
{
return 0;
}
#endif
-#line 613 "toke.l"
+#line 614 "toke.l"
struct path_list {
char *path;
struct path_list **sorted = NULL;
if (!(dir = opendir(dirpath))) {
- yyerror(dirpath);
- return NULL;
+ if (errno != ENOENT) {
+ char *errbuf;
+ if (asprintf(&errbuf, "%s: %s", dirpath, strerror(errno)) != -1) {
+ yyerror(errbuf);
+ free(errbuf);
+ } else {
+ yyerror("unable to allocate memory");
+ }
+ }
+ goto done;
}
while ((dent = readdir(dir))) {
/* Ignore files that end in '~' or have a '.' in them. */
}
} else {
if ((fp = open_sudoers(path, TRUE, &keepopen)) == NULL) {
- yyerror(path);
+ char *errbuf;
+ if (asprintf(&errbuf, "%s: %s", path, strerror(errno)) != -1) {
+ yyerror(errbuf);
+ free(errbuf);
+ } else {
+ yyerror("unable to allocate memory");
+ }
return FALSE;
}
istack[idepth].more = NULL;
# include <ndir.h>
# endif
#endif
+#include <errno.h>
#include <ctype.h>
#include "sudoers.h"
#include "parse.h"
struct path_list **sorted = NULL;
if (!(dir = opendir(dirpath))) {
- yyerror(dirpath);
- return NULL;
+ if (errno != ENOENT) {
+ char *errbuf;
+ if (asprintf(&errbuf, "%s: %s", dirpath, strerror(errno)) != -1) {
+ yyerror(errbuf);
+ free(errbuf);
+ } else {
+ yyerror("unable to allocate memory");
+ }
+ }
+ goto done;
}
while ((dent = readdir(dir))) {
/* Ignore files that end in '~' or have a '.' in them. */
}
} else {
if ((fp = open_sudoers(path, TRUE, &keepopen)) == NULL) {
- yyerror(path);
+ char *errbuf;
+ if (asprintf(&errbuf, "%s: %s", path, strerror(errno)) != -1) {
+ yyerror(errbuf);
+ free(errbuf);
+ } else {
+ yyerror("unable to allocate memory");
+ }
return FALSE;
}
istack[idepth].more = NULL;