[BACK]Return to parse.y CVS log [TXT][DIR] Up to [local] / src / usr.bin / doas

Diff for /src/usr.bin/doas/parse.y between version 1.15 and 1.16

version 1.15, 2016/04/27 02:35:55 version 1.16, 2016/06/05 00:46:34
Line 35 
Line 35 
                         const char *cmd;                          const char *cmd;
                         const char **cmdargs;                          const char **cmdargs;
                         const char **envlist;                          const char **envlist;
                           const char **setenvlist;
                 };                  };
                 const char *str;                  const char *str;
         };          };
Line 56 
Line 57 
 %}  %}
   
 %token TPERMIT TDENY TAS TCMD TARGS  %token TPERMIT TDENY TAS TCMD TARGS
 %token TNOPASS TKEEPENV  %token TNOPASS TKEEPENV TSETENV
 %token TSTRING  %token TSTRING
   
 %%  %%
Line 75 
Line 76 
                         r->action = $1.action;                          r->action = $1.action;
                         r->options = $1.options;                          r->options = $1.options;
                         r->envlist = $1.envlist;                          r->envlist = $1.envlist;
                           r->setenvlist = $1.setenvlist;
                         r->ident = $2.str;                          r->ident = $2.str;
                         r->target = $3.str;                          r->target = $3.str;
                         r->cmd = $4.cmd;                          r->cmd = $4.cmd;
Line 95 
Line 97 
                         $$.action = PERMIT;                          $$.action = PERMIT;
                         $$.options = $2.options;                          $$.options = $2.options;
                         $$.envlist = $2.envlist;                          $$.envlist = $2.envlist;
                           $$.setenvlist = $2.setenvlist;
                 } | TDENY {                  } | TDENY {
                         $$.action = DENY;                          $$.action = DENY;
                 } ;                  } ;
Line 110 
Line 113 
                                 } else                                  } else
                                         $$.envlist = $2.envlist;                                          $$.envlist = $2.envlist;
                         }                          }
                           $$.setenvlist = $1.setenvlist;
                           if ($2.setenvlist) {
                                   if ($$.setenvlist) {
                                           yyerror("can't have two setenv sections");
                                           YYERROR;
                                   } else
                                           $$.setenvlist = $2.setenvlist;
                           }
                 } ;                  } ;
   
 option:         TNOPASS {  option:         TNOPASS {
                         $$.options = NOPASS;                          $$.options = NOPASS;
                 } | TKEEPENV {                  } | TKEEPENV {
Line 118 
Line 130 
                 } | TKEEPENV '{' envlist '}' {                  } | TKEEPENV '{' envlist '}' {
                         $$.options = KEEPENV;                          $$.options = KEEPENV;
                         $$.envlist = $3.envlist;                          $$.envlist = $3.envlist;
                   } | TSETENV '{' setenvlist '}' {
                           $$.options = SETENV;
                           $$.setenvlist = $3.setenvlist;
                 } ;                  } ;
   
 envlist:        /* empty */ {  envlist:        /* empty */ {
Line 132 
Line 147 
                         $$.envlist[nenv + 1] = NULL;                          $$.envlist[nenv + 1] = NULL;
                 }                  }
   
   setenvlist:     /* empty */ {
                           if (!($$.setenvlist = calloc(1, sizeof(char *))))
                                   errx(1, "can't allocate setenvlist");
                   } | setenvlist TSTRING '=' TSTRING {
                           int nenv = arraylen($1.setenvlist);
                           char *cp = NULL;
   
                           if (*$2.str == '\0' || strchr($2.str, '=') != NULL) {
                                   yyerror("invalid setenv expression");
                                   YYERROR;
                           }
                           if (!($$.setenvlist = reallocarray($1.setenvlist,
                               nenv + 2, sizeof(char *))))
                                   errx(1, "can't allocate envlist");
                           $$.setenvlist[nenv] = NULL;
                           if (asprintf(&cp, "%s=%s", $2.str, $4.str) <= 0 ||
                               cp == NULL)
                                   errx(1,"asprintf failed");
                           $$.setenvlist[nenv] = cp;
                           $$.setenvlist[nenv + 1] = NULL;
                   }
   
   
 ident:          TSTRING {  ident:          TSTRING {
                         $$.str = $1.str;                          $$.str = $1.str;
                 } ;                  } ;
Line 195 
Line 232 
         { "args", TARGS },          { "args", TARGS },
         { "nopass", TNOPASS },          { "nopass", TNOPASS },
         { "keepenv", TKEEPENV },          { "keepenv", TKEEPENV },
           { "setenv", TSETENV },
 };  };
   
 int  int
Line 219 
Line 257 
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case '{':                  case '{':
                 case '}':                  case '}':
                   case '=':
                         return c;                          return c;
                 case '#':                  case '#':
                         /* skip comments; NUL is allowed; no continuation */                          /* skip comments; NUL is allowed; no continuation */
Line 271 
Line 310 
                 case '#':                  case '#':
                 case ' ':                  case ' ':
                 case '\t':                  case '\t':
                   case '=':
                         if (!escape && !quotes)                          if (!escape && !quotes)
                                 goto eow;                                  goto eow;
                         break;                          break;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16