stop touching the wrong stamp filename after configuring
[debian/sudo] / toke.l
diff --git a/toke.l b/toke.l
index d5fc72400dc176cb8afc936802d9820bcf69b5f5..263693e3519305e2f5b809ca5638b32cc3e42d7a 100644 (file)
--- a/toke.l
+++ b/toke.l
@@ -1,6 +1,6 @@
 %{
 /*
- * Copyright (c) 1996, 1998-2005, 2007-2009
+ * Copyright (c) 1996, 1998-2005, 2007-2010
  *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
 #endif /* STDC_HEADERS */
 #ifdef HAVE_STRING_H
 # include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-#  include <strings.h>
-# endif
 #endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif /* HAVE_STRINGS_H */
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif /* HAVE_UNISTD_H */
@@ -221,7 +220,7 @@ DEFVAR                      [a-z_]+
                            return(COMMAND);
                        }                       /* end of command line args */
 
-    [^\\:, \t\n]+      {
+    [^#\\:, \t\n]+     {
                            LEXTRACE("ARG ");
                            if (!fill_args(yytext, yyleng, sawspace))
                                yyterminate();
@@ -258,7 +257,7 @@ DEFVAR                      [a-z_]+
                                yyterminate();
                        }
 
-<INITIAL>^[[:blank:]]*Defaults([:@>\!]{WORD})? {
+<INITIAL>^[[:blank:]]*Defaults([:@>\!]\!?{WORD})? {
                            int n;
                            for (n = 0; isblank((unsigned char)yytext[n]); n++)
                                continue;
@@ -339,6 +338,26 @@ NOSETENV[[:blank:]]*:      {
                                return(NOSETENV);
                        }
 
+LOG_OUTPUT[[:blank:]]*:        {
+                               LEXTRACE("LOG_OUTPUT ");
+                               return(LOG_OUTPUT);
+                       }
+
+NOLOG_OUTPUT[[:blank:]]*:      {
+                               LEXTRACE("NOLOG_OUTPUT ");
+                               return(NOLOG_OUTPUT);
+                       }
+
+LOG_INPUT[[:blank:]]*: {
+                               LEXTRACE("LOG_INPUT ");
+                               return(LOG_INPUT);
+                       }
+
+NOLOG_INPUT[[:blank:]]*:       {
+                               LEXTRACE("NOLOG_INPUT ");
+                               return(NOLOG_INPUT);
+                       }
+
 \+{WORD}               {
                            /* netgroup */
                            if (!fill(yytext, yyleng))
@@ -855,6 +874,7 @@ _push_include(path, isdir)
     char *path;
     int isdir;
 {
+    struct path_list *pl;
     FILE *fp;
 
     /* push current state onto stack */
@@ -876,9 +896,14 @@ _push_include(path, isdir)
            /* 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 */
+       while ((fp = open_sudoers(path, FALSE, &keepopen)) == NULL) {
+           /* Unable to open path in includedir, go to next one, if any. */
+           efree(path);
+           if ((pl = istack[idepth].more) == NULL)
+               return(FALSE);
+           path = pl->path;
+           istack[idepth].more = pl->next;
+           efree(pl);
        }
     } else {
        if ((fp = open_sudoers(path, TRUE, &keepopen)) == NULL) {
@@ -912,25 +937,31 @@ pop_include()
     if (!keepopen)
        fclose(YY_CURRENT_BUFFER->yy_input_file);
     yy_delete_buffer(YY_CURRENT_BUFFER);
-    keepopen = FALSE;
-    if ((pl = istack[idepth - 1].more) != NULL) {
-       /* Move to next file in the dir. */
-       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 */
+    /* If we are in an include dir, move to the next file. */
+    while ((pl = istack[idepth - 1].more) != NULL) {
+       fp = open_sudoers(pl->path, FALSE, &keepopen);
+       if (fp != NULL) {
+           istack[idepth - 1].more = pl->next;
+           efree(sudoers);
+           sudoers = pl->path;
+           sudolineno = 1;
+           yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE));
+           efree(pl);
+           break;
        }
-       efree(sudoers);
-       sudoers = pl->path;
-       sudolineno = 1;
-       yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE));
+       /* Unable to open path in include dir, go to next one. */
+       istack[idepth - 1].more = pl->next;
+       efree(pl->path);
        efree(pl);
-    } else {
+    }
+    /* If no path list, just pop the last dir on the stack. */
+    if (pl == NULL) {
        idepth--;
        yy_switch_to_buffer(istack[idepth].bs);
        efree(sudoers);
        sudoers = istack[idepth].path;
        sudolineno = istack[idepth].lineno;
+       keepopen = istack[idepth].keepopen;
     }
     return(TRUE);
 }