]> git.armaanb.net Git - opendoas.git/blobdiff - parse.y
use static in the right places to seperate modules better ok tedu
[opendoas.git] / parse.y
diff --git a/parse.y b/parse.y
index 0307b0f39be9d909c10351f894396a3046919546..5e776794069eec005906ef20f6c65eabde3222a5 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -49,17 +49,19 @@ typedef struct {
 FILE *yyfp;
 
 struct rule **rules;
-int nrules, maxrules;
+int nrules;
+static int maxrules;
+
 int parse_errors = 0;
+static int obsolete_warned = 0;
 
-void yyerror(const char *, ...);
-int yylex(void);
-int yyparse(void);
+static void yyerror(const char *, ...);
+static int yylex(void);
 
 %}
 
 %token TPERMIT TDENY TAS TCMD TARGS
-%token TNOPASS TKEEPENV
+%token TNOPASS TPERSIST TKEEPENV TSETENV
 %token TSTRING
 
 %%
@@ -100,6 +102,8 @@ action:             TPERMIT options {
                        $$.envlist = $2.envlist;
                } | TDENY {
                        $$.action = DENY;
+                       $$.options = 0;
+                       $$.envlist = NULL;
                } ;
 
 options:       /* none */ {
@@ -108,9 +112,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 +127,21 @@ options:  /* none */ {
 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;
                } ;
 
@@ -188,7 +206,7 @@ yyerror(const char *fmt, ...)
        parse_errors++;
 }
 
-struct keyword {
+static struct keyword {
        const char *word;
        int token;
 } keywords[] = {
@@ -198,7 +216,9 @@ struct keyword {
        { "cmd", TCMD },
        { "args", TARGS },
        { "nopass", TNOPASS },
+       { "persist", TPERSIST },
        { "keepenv", TKEEPENV },
+       { "setenv", TSETENV },
 };
 
 int