summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2007-10-16 19:20:28 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2007-10-16 19:20:28 +0000
commit977cef7024d99e298a46d5beceea7e06ad52c039 (patch)
tree31f76137469e3a5aa45a8607dac6125b0ed2dbb1 /sbin/pfctl
parent70d89ee009a19c17ebd72974caa0ab809d31ea04 (diff)
Allow unquoted numbers in variables.
Change 'set hostid' to NUMBER and remove unneeded converter. Add '=' to allowed_to_end_number(x) to make varsets like 4=5 illegal. OK deraadt@
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/parse.y35
1 files changed, 17 insertions, 18 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 4418a04c8e8..0200ac224b8 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.529 2007/10/16 06:06:49 deraadt Exp $ */
+/* $OpenBSD: parse.y,v 1.530 2007/10/16 19:20:27 mpf Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -435,7 +435,7 @@ typedef struct {
%token <v.number> NUMBER
%token <v.i> PORTBINARY
%type <v.interface> interface if_list if_item_not if_item
-%type <v.number> number icmptype icmp6type uid gid
+%type <v.number> icmptype icmp6type uid gid
%type <v.number> tos not yesno
%type <v.i> no dir af fragcache optimizer
%type <v.i> sourcetrack flush unaryop statelock
@@ -576,7 +576,7 @@ option : SET OPTIMIZATION STRING {
}
free($3);
}
- | SET HOSTID number {
+ | SET HOSTID NUMBER {
if ($3 == 0 || $3 > UINT_MAX) {
yyerror("hostid must be non-zero");
YYERROR;
@@ -681,6 +681,19 @@ varset : STRING '=' string {
free($1);
free($3);
}
+ | STRING '=' NUMBER {
+ char *s;
+ if (asprintf(&s, "%lld", $3) == -1) {
+ yyerror("string: asprintf");
+ YYERROR;
+ }
+ if (pf->opts & PF_OPT_VERBOSE)
+ printf("%s = \"%s\"\n", $1, s);
+ if (symset($1, s, 0) == -1)
+ err(1, "cannot store variable %s", $1);
+ free($1);
+ free(s);
+ }
;
anchorname : STRING { $$ = $1; }
@@ -2697,20 +2710,6 @@ host : STRING {
}
;
-number : NUMBER
- | STRING {
- u_long ulval;
-
- if (atoul($1, &ulval) == -1) {
- yyerror("%s is not a number", $1);
- free($1);
- YYERROR;
- } else
- $$ = ulval;
- free($1);
- }
- ;
-
dynaddr : '(' STRING ')' {
int flags = 0;
char *p, *op;
@@ -5371,7 +5370,7 @@ top:
}
#define allowed_to_end_number(x) \
- (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}')
+ (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
if (c == '-' || isdigit(c)) {
do {