/* A lexical scanner generated by flex */
/* Scanner skeleton version:
- * $Header: /home/cvs/courtesan/sudo/toke.c,v 1.36 2009/05/27 00:47:17 millert Exp $
+ * $Header: /home/cvs/openbsd/src/usr.bin/lex/flex.skl,v 1.10 2007/01/26 14:38:19 tsi Exp $
*/
#define FLEX_SCANNER
#include "parse.h"
#include <gram.h>
-#ifndef lint
-__unused static const char rcsid[] = "$Sudo: toke.c,v 1.36 2009/05/27 00:47:17 millert Exp $";
-#endif /* lint */
-
extern YYSTYPE yylval;
+extern int parse_error;
int sudolineno = 1;
char *sudoers;
static int sawspace = 0;
#define INSTR 5
-#line 1465 "lex.yy.c"
+#line 1462 "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 131 "toke.l"
+#line 128 "toke.l"
-#line 1621 "lex.yy.c"
+#line 1618 "lex.yy.c"
if ( yy_init )
{
case 1:
YY_RULE_SETUP
-#line 132 "toke.l"
+#line 129 "toke.l"
BEGIN STARTDEFS;
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 134 "toke.l"
+#line 131 "toke.l"
{
BEGIN INDEFS;
LEXTRACE("DEFVAR ");
case 3:
YY_RULE_SETUP
-#line 143 "toke.l"
+#line 140 "toke.l"
{
BEGIN STARTDEFS;
LEXTRACE(", ");
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 149 "toke.l"
+#line 146 "toke.l"
{
LEXTRACE("= ");
return('=');
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 154 "toke.l"
+#line 151 "toke.l"
{
LEXTRACE("+= ");
return('+');
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 159 "toke.l"
+#line 156 "toke.l"
{
LEXTRACE("-= ");
return('-');
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 164 "toke.l"
+#line 161 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 170 "toke.l"
+#line 167 "toke.l"
{
LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng))
case 9:
YY_RULE_SETUP
-#line 179 "toke.l"
+#line 176 "toke.l"
{
/* Line continuation char followed by newline. */
++sudolineno;
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 185 "toke.l"
+#line 182 "toke.l"
{
LEXTRACE("ENDSTR ");
BEGIN INDEFS;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 191 "toke.l"
+#line 188 "toke.l"
{
LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng))
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 197 "toke.l"
+#line 194 "toke.l"
{
LEXTRACE("STRBODY ");
if (!append(yytext, yyleng))
case 13:
YY_RULE_SETUP
-#line 205 "toke.l"
+#line 202 "toke.l"
{
/* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 213 "toke.l"
+#line 210 "toke.l"
{
/* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 221 "toke.l"
+#line 218 "toke.l"
{
BEGIN INITIAL;
yyless(0);
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 227 "toke.l"
+#line 224 "toke.l"
{
LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace))
case 17:
YY_RULE_SETUP
-#line 235 "toke.l"
+#line 232 "toke.l"
{
char *path;
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 248 "toke.l"
+#line 245 "toke.l"
{
char *path;
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();
}
YY_BREAK
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++;
}