#include "parse.h"
#include <gram.h>
-#ifndef lint
-__unused static const char rcsid[] = "$Sudo: toke.l,v 1.37 2009/05/27 00:46:51 millert Exp $";
-#endif /* lint */
-
extern YYSTYPE yylval;
+extern int parse_error;
int sudolineno = 1;
char *sudoers;
static int sawspace = 0;
LEXTRACE("INCLUDEDIR\n");
- /* Push current buffer and switch to include file */
- if (!push_includedir(path))
+ /*
+ * Push current buffer and switch to include file.
+ * We simply ignore empty directories.
+ */
+ if (!push_includedir(path) && parse_error)
yyterminate();
}
if (!(dir = opendir(dirpath))) {
yyerror(dirpath);
- return(FALSE);
+ return(NULL);
}
while ((dent = readdir(dir))) {
/* Ignore files that end in '~' or have a '.' in them. */
efree(pl);
}
efree(istack[idepth].path);
- if (!istack[idepth].keepopen)
+ if (idepth && !istack[idepth].keepopen)
fclose(istack[idepth].bs->yy_input_file);
yy_delete_buffer(istack[idepth].bs);
}
}
istacksize += SUDOERS_STACK_INCREMENT;
istack = (struct include_stack *) realloc(istack,
- sizeof(istack) * istacksize);
+ sizeof(*istack) * istacksize);
if (istack == NULL) {
yyerror("unable to allocate memory");
return(FALSE);
}
if (isdir) {
if (!(path = switch_dir(&istack[idepth], path))) {
- yyerror(path);
+ /* switch_dir() called yyerror() for us */
return(FALSE);
}
if ((fp = open_sudoers(path, FALSE, &keepopen)) == NULL) {
yyerror(path);
- return(FALSE); /* XXX - just to go next one? */
+ return(FALSE); /* XXX - just to go next one */
}
} else {
if ((fp = open_sudoers(path, TRUE, &keepopen)) == NULL) {
istack[idepth - 1].more = pl->next;
if ((fp = open_sudoers(pl->path, FALSE, &keepopen)) == NULL) {
yyerror(pl->path);
- return(FALSE); /* XXX - just to go next one? */
+ return(FALSE); /* XXX - just to go next one */
}
efree(sudoers);
sudoers = pl->path;
memcpy(pp, user_shost, shost_len);
pp += shost_len;
cp += 2;
+ continue;
}
*pp++ = *cp++;
}