Move parse.lex -> toke.l
Rename buffer_frob() -> switch_buffer() WORD no longer needs to exclude '@' kill yywrap()
This commit is contained in:
@@ -51,16 +51,13 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "sudo.h"
|
#include "sudo.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
#include <sudo.tab.h>
|
#include "gram.h"
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] = "$Sudo$";
|
static const char rcsid[] = "$Sudo$";
|
||||||
#endif /* lint */
|
#endif /* lint */
|
||||||
|
|
||||||
#undef yywrap /* guard against a yywrap macro */
|
|
||||||
|
|
||||||
extern YYSTYPE yylval;
|
extern YYSTYPE yylval;
|
||||||
extern int clearaliases;
|
|
||||||
int sudolineno = 1;
|
int sudolineno = 1;
|
||||||
char *sudoers;
|
char *sudoers;
|
||||||
static int sawspace = 0;
|
static int sawspace = 0;
|
||||||
@@ -70,12 +67,11 @@ static int arg_size = 0;
|
|||||||
static int fill __P((char *, int));
|
static int fill __P((char *, int));
|
||||||
static int fill_cmnd __P((char *, int));
|
static int fill_cmnd __P((char *, int));
|
||||||
static int fill_args __P((char *, int, int));
|
static int fill_args __P((char *, int, int));
|
||||||
static int buffer_frob __P((char *));
|
static int switch_buffer __P((char *));
|
||||||
extern void reset_aliases __P((void));
|
|
||||||
extern void yyerror __P((const char *));
|
extern void yyerror __P((const char *));
|
||||||
|
|
||||||
#define push_include(_p) (buffer_frob((_p)))
|
#define push_include(_p) (switch_buffer((_p)))
|
||||||
#define pop_include() (buffer_frob(NULL))
|
#define pop_include() (switch_buffer(NULL))
|
||||||
|
|
||||||
/* realloc() to size + COMMANDARGINC to make room for command args */
|
/* realloc() to size + COMMANDARGINC to make room for command args */
|
||||||
#define COMMANDARGINC 64
|
#define COMMANDARGINC 64
|
||||||
@@ -90,11 +86,12 @@ extern void yyerror __P((const char *));
|
|||||||
OCTET (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5])
|
OCTET (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5])
|
||||||
DOTTEDQUAD {OCTET}(\.{OCTET}){3}
|
DOTTEDQUAD {OCTET}(\.{OCTET}){3}
|
||||||
HOSTNAME [[:alnum:]_-]+
|
HOSTNAME [[:alnum:]_-]+
|
||||||
WORD ([^#>@!=:,\(\) \t\n\\]|\\[^\n])+
|
WORD ([^#>!=:,\(\) \t\n\\]|\\[^\n])+
|
||||||
ENVAR ([^#!=, \t\n\\]|\\[^\n])([^#=, \t\n\\]|\\[^\n])*
|
ENVAR ([^#!=, \t\n\\]|\\[^\n])([^#=, \t\n\\]|\\[^\n])*
|
||||||
DEFVAR [a-z_]+
|
DEFVAR [a-z_]+
|
||||||
|
|
||||||
%option nounput
|
%option nounput
|
||||||
|
%option noyywrap
|
||||||
|
|
||||||
/* XXX - convert GOTRUNAS to exclusive state (GOTDEFS cannot be) */
|
/* XXX - convert GOTRUNAS to exclusive state (GOTDEFS cannot be) */
|
||||||
%s GOTRUNAS
|
%s GOTRUNAS
|
||||||
@@ -283,7 +280,7 @@ MONITOR[[:blank:]]*: {
|
|||||||
/* UN*X group */
|
/* UN*X group */
|
||||||
if (!fill(yytext, yyleng))
|
if (!fill(yytext, yyleng))
|
||||||
yyterminate();
|
yyterminate();
|
||||||
LEXTRACE("GROUP ");
|
LEXTRACE("USERGROUP ");
|
||||||
return(USERGROUP);
|
return(USERGROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,9 +513,10 @@ struct sudoers_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_SUDOERS_DEPTH 128
|
#define MAX_SUDOERS_DEPTH 128
|
||||||
|
#define SUDOERS_STACK_INCREMENT 16
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buffer_frob(path)
|
switch_buffer(path)
|
||||||
char *path;
|
char *path;
|
||||||
{
|
{
|
||||||
static size_t stacksize, depth;
|
static size_t stacksize, depth;
|
||||||
@@ -537,8 +535,10 @@ buffer_frob(path)
|
|||||||
yyerror("too many levels of includes");
|
yyerror("too many levels of includes");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
stacksize += 16;
|
stacksize += SUDOERS_STACK_INCREMENT;
|
||||||
if ((state = realloc(state, sizeof(state) * stacksize)) == NULL) {
|
state = (struct sudoers_state *) realloc(state,
|
||||||
|
sizeof(state) * stacksize);
|
||||||
|
if (state == NULL) {
|
||||||
yyerror("unable to allocate memory");
|
yyerror("unable to allocate memory");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
@@ -570,14 +570,3 @@ buffer_frob(path)
|
|||||||
}
|
}
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
yywrap()
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Free space used by the aliases unless called by testsudoers. */
|
|
||||||
if (clearaliases)
|
|
||||||
reset_aliases();
|
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
Reference in New Issue
Block a user