]> git.armaanb.net Git - opendoas.git/blobdiff - parse.y
don't allow combining nopass and persist in a single rule
[opendoas.git] / parse.y
diff --git a/parse.y b/parse.y
index 506eb686bf2fcffc284755185ac548a09db9113d..8a333642200c0c0a5f094edae977d03f78019274 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -60,7 +60,7 @@ int yyparse(void);
 %}
 
 %token TPERMIT TDENY TAS TCMD TARGS
-%token TNOPASS TKEEPENV TSETENV
+%token TNOPASS TPERSIST TKEEPENV TSETENV
 %token TSTRING
 
 %%
@@ -111,6 +111,10 @@ 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 setenv sections");
@@ -122,6 +126,9 @@ options:    /* none */ {
 option:                TNOPASS {
                        $$.options = NOPASS;
                        $$.envlist = NULL;
+               } | TPERSIST {
+                       $$.options = PERSIST;
+                       $$.envlist = NULL;
                } | TKEEPENV {
                        $$.options = KEEPENV;
                        $$.envlist = NULL;
@@ -208,6 +215,7 @@ struct keyword {
        { "cmd", TCMD },
        { "args", TARGS },
        { "nopass", TNOPASS },
+       { "persist", TPERSIST },
        { "keepenv", TKEEPENV },
        { "setenv", TSETENV },
 };