struct rule **rules;
int nrules, maxrules;
int parse_errors = 0;
+int obsolete_warned = 0;
void yyerror(const char *, ...);
int yylex(void);
%}
%token TPERMIT TDENY TAS TCMD TARGS
-%token TNOPASS TKEEPENV
+%token TNOPASS TPERSIST TKEEPENV TSETENV
%token TSTRING
%%
$$.envlist = $2.envlist;
} | TDENY {
$$.action = DENY;
+ $$.options = 0;
+ $$.envlist = NULL;
} ;
-options: /* none */
- | options option {
+options: /* none */ {
+ $$.options = 0;
+ $$.envlist = NULL;
+ } | options option {
$$.options = $1.options | $2.options;
$$.envlist = $1.envlist;
if ($2.envlist) {
if ($$.envlist) {
- yyerror("can't have two keepenv sections");
+ yyerror("can't have two setenv sections");
YYERROR;
} else
$$.envlist = $2.envlist;
} ;
option: TNOPASS {
$$.options = NOPASS;
+ $$.envlist = NULL;
+ } | TPERSIST {
+ $$.options = PERSIST;
+ $$.envlist = NULL;
} | TKEEPENV {
$$.options = KEEPENV;
+ $$.envlist = NULL;
} | TKEEPENV '{' envlist '}' {
- $$.options = KEEPENV;
+ $$.options = 0;
+ if (!obsolete_warned) {
+ warnx("keepenv with list is obsolete");
+ obsolete_warned = 1;
+ }
+ $$.envlist = $3.envlist;
+ } | TSETENV '{' envlist '}' {
+ $$.options = 0;
$$.envlist = $3.envlist;
} ;
envlist: /* empty */ {
- if (!($$.envlist = calloc(1, sizeof(char *))))
- errx(1, "can't allocate envlist");
+ $$.envlist = NULL;
} | envlist TSTRING {
int nenv = arraylen($1.envlist);
if (!($$.envlist = reallocarray($1.envlist, nenv + 2,
} ;
argslist: /* empty */ {
- if (!($$.cmdargs = calloc(1, sizeof(char *))))
- errx(1, "can't allocate args");
+ $$.cmdargs = NULL;
} | argslist TSTRING {
int nargs = arraylen($1.cmdargs);
if (!($$.cmdargs = reallocarray($1.cmdargs, nargs + 2,
{ "cmd", TCMD },
{ "args", TARGS },
{ "nopass", TNOPASS },
+ { "persist", TPERSIST },
{ "keepenv", TKEEPENV },
+ { "setenv", TSETENV },
};
int
goto repeat;
}
if (!nonkw) {
- unsigned i;
+ size_t i;
for (i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) {
if (strcmp(buf, keywords[i].word) == 0)
return keywords[i].token;