]> git.armaanb.net Git - opendoas.git/blobdiff - parse.y
it has been six months and two days... remove keepenv { obsolete } syntax
[opendoas.git] / parse.y
diff --git a/parse.y b/parse.y
index ef5a3ef7f991bcac9e52390b85aa9062e18439ee..fd161e6efd7b8edb7d943ad685b71cc7e586fb0f 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -49,17 +49,30 @@ typedef struct {
 FILE *yyfp;
 
 struct rule **rules;
-int nrules, maxrules;
+int nrules;
+static int maxrules;
+
 int parse_errors = 0;
 
-void yyerror(const char *, ...);
-int yylex(void);
-int yyparse(void);
+static void yyerror(const char *, ...);
+static int yylex(void);
+
+static size_t
+arraylen(const char **arr)
+{
+       size_t cnt = 0;
+
+       while (*arr) {
+               cnt++;
+               arr++;
+       }
+       return cnt;
+}
 
 %}
 
 %token TPERMIT TDENY TAS TCMD TARGS
-%token TNOPASS TKEEPENV
+%token TNOPASS TPERSIST TKEEPENV TSETENV
 %token TSTRING
 
 %%
@@ -100,6 +113,8 @@ action:             TPERMIT options {
                        $$.envlist = $2.envlist;
                } | TDENY {
                        $$.action = DENY;
+                       $$.options = 0;
+                       $$.envlist = NULL;
                } ;
 
 options:       /* none */ {
@@ -108,9 +123,13 @@ options:   /* none */ {
                } | options option {
                        $$.options = $1.options | $2.options;
                        $$.envlist = $1.envlist;
+                       if (($$.options & (NOPASS|PERSIST)) == (NOPASS|PERSIST)) {
+                               yyerror("can't combine nopass and persist");
+                               YYERROR;
+                       }
                        if ($2.envlist) {
                                if ($$.envlist) {
-                                       yyerror("can't have two keepenv sections");
+                                       yyerror("can't have two setenv sections");
                                        YYERROR;
                                } else
                                        $$.envlist = $2.envlist;
@@ -119,11 +138,14 @@ options:  /* none */ {
 option:                TNOPASS {
                        $$.options = NOPASS;
                        $$.envlist = NULL;
+               } | TPERSIST {
+                       $$.options = PERSIST;
+                       $$.envlist = NULL;
                } | TKEEPENV {
                        $$.options = KEEPENV;
                        $$.envlist = NULL;
-               } | TKEEPENV '{' envlist '}' {
-                       $$.options = KEEPENV;
+               } | TSETENV '{' envlist '}' {
+                       $$.options = 0;
                        $$.envlist = $3.envlist;
                } ;
 
@@ -136,7 +158,7 @@ envlist:    /* empty */ {
                                errx(1, "can't allocate envlist");
                        $$.envlist[nenv] = $2.str;
                        $$.envlist[nenv + 1] = NULL;
-               }
+               } ;
 
 
 ident:         TSTRING {
@@ -188,7 +210,7 @@ yyerror(const char *fmt, ...)
        parse_errors++;
 }
 
-struct keyword {
+static struct keyword {
        const char *word;
        int token;
 } keywords[] = {
@@ -198,7 +220,9 @@ struct keyword {
        { "cmd", TCMD },
        { "args", TARGS },
        { "nopass", TNOPASS },
+       { "persist", TPERSIST },
        { "keepenv", TKEEPENV },
+       { "setenv", TSETENV },
 };
 
 int
@@ -308,7 +332,7 @@ eow:
                        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;