#include <ctype.h>
#include "sudo.h"
#include "parse.h"
-#include <sudo.tab.h>
+#include "gram.h"
#ifndef lint
static const char rcsid[] = "$Sudo$";
#endif /* lint */
-#undef yywrap /* guard against a yywrap macro */
-
extern YYSTYPE yylval;
-extern int clearaliases;
int sudolineno = 1;
char *sudoers;
static int sawspace = 0;
static int fill __P((char *, int));
static int fill_cmnd __P((char *, int));
static int fill_args __P((char *, int, int));
-static int buffer_frob __P((char *));
-extern void reset_aliases __P((void));
+static int switch_buffer __P((char *));
extern void yyerror __P((const char *));
-#define push_include(_p) (buffer_frob((_p)))
-#define pop_include() (buffer_frob(NULL))
+#define push_include(_p) (switch_buffer((_p)))
+#define pop_include() (switch_buffer(NULL))
/* realloc() to size + COMMANDARGINC to make room for command args */
#define COMMANDARGINC 64
OCTET (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5])
DOTTEDQUAD {OCTET}(\.{OCTET}){3}
HOSTNAME [[:alnum:]_-]+
-WORD ([^#>@!=:,\(\) \t\n\\]|\\[^\n])+
+WORD ([^#>!=:,\(\) \t\n\\]|\\[^\n])+
ENVAR ([^#!=, \t\n\\]|\\[^\n])([^#=, \t\n\\]|\\[^\n])*
DEFVAR [a-z_]+
%option nounput
+%option noyywrap
/* XXX - convert GOTRUNAS to exclusive state (GOTDEFS cannot be) */
%s GOTRUNAS
/* UN*X group */
if (!fill(yytext, yyleng))
yyterminate();
- LEXTRACE("GROUP ");
+ LEXTRACE("USERGROUP ");
return(USERGROUP);
}
};
#define MAX_SUDOERS_DEPTH 128
+#define SUDOERS_STACK_INCREMENT 16
static int
-buffer_frob(path)
+switch_buffer(path)
char *path;
{
static size_t stacksize, depth;
yyerror("too many levels of includes");
return(FALSE);
}
- stacksize += 16;
- if ((state = realloc(state, sizeof(state) * stacksize)) == NULL) {
+ stacksize += SUDOERS_STACK_INCREMENT;
+ state = (struct sudoers_state *) realloc(state,
+ sizeof(state) * stacksize);
+ if (state == NULL) {
yyerror("unable to allocate memory");
return(FALSE);
}
}
return(TRUE);
}
-
-int
-yywrap()
-{
-
- /* Free space used by the aliases unless called by testsudoers. */
- if (clearaliases)
- reset_aliases();
-
- return(TRUE);
-}