xref: /freebsd/contrib/unbound/util/configlexer.lex (revision e86b9096262054dbb4228fb94def3728edcc8a37)
1 %{
2 /*
3  * configlexer.lex - lexical analyzer for unbound config file
4  *
5  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved
6  *
7  * See LICENSE for the license.
8  *
9  */
10 #include "config.h"
11 
12 /* because flex keeps having sign-unsigned compare problems that are unfixed*/
13 #if defined(__clang__)||(defined(__GNUC__)&&((__GNUC__ >4)||(defined(__GNUC_MINOR__)&&(__GNUC__ ==4)&&(__GNUC_MINOR__ >=2))))
14 #pragma GCC diagnostic ignored "-Wsign-compare"
15 #endif
16 
17 #include <ctype.h>
18 #include <strings.h>
19 #ifdef HAVE_GLOB_H
20 # include <glob.h>
21 #endif
22 
23 #include "util/config_file.h"
24 #include "configparser.h"
25 void ub_c_error(const char *message);
26 
27 #if 0
28 #define LEXOUT(s)  printf s /* used ONLY when debugging */
29 #else
30 #define LEXOUT(s)
31 #endif
32 
33 /** avoid warning in about fwrite return value */
34 #define ECHO ub_c_error_msg("syntax error at text: %s", ub_c_text)
35 
36 /** A parser variable, this is a statement in the config file which is
37  * of the form variable: value1 value2 ...  nargs is the number of values. */
38 #define YDVAR(nargs, var) \
39 	num_args=(nargs); \
40 	LEXOUT(("v(%s%d) ", ub_c_text, num_args)); \
41 	if(num_args > 0) { BEGIN(val); } \
42 	return (var);
43 
44 struct inc_state {
45 	char* filename;
46 	int line;
47 	YY_BUFFER_STATE buffer;
48 	struct inc_state* next;
49 };
50 static struct inc_state* config_include_stack = NULL;
51 static int inc_depth = 0;
52 static int inc_prev = 0;
53 static int num_args = 0;
54 
55 void init_cfg_parse(void)
56 {
57 	config_include_stack = NULL;
58 	inc_depth = 0;
59 	inc_prev = 0;
60 	num_args = 0;
61 }
62 
63 static void config_start_include(const char* filename)
64 {
65 	FILE *input;
66 	struct inc_state* s;
67 	char* nm;
68 	if(inc_depth++ > 100000) {
69 		ub_c_error_msg("too many include files");
70 		return;
71 	}
72 	if(*filename == '\0') {
73 		ub_c_error_msg("empty include file name");
74 		return;
75 	}
76 	s = (struct inc_state*)malloc(sizeof(*s));
77 	if(!s) {
78 		ub_c_error_msg("include %s: malloc failure", filename);
79 		return;
80 	}
81 	if(cfg_parser->chroot && strncmp(filename, cfg_parser->chroot,
82 		strlen(cfg_parser->chroot)) == 0) {
83 		filename += strlen(cfg_parser->chroot);
84 	}
85 	nm = strdup(filename);
86 	if(!nm) {
87 		ub_c_error_msg("include %s: strdup failure", filename);
88 		free(s);
89 		return;
90 	}
91 	input = fopen(filename, "r");
92 	if(!input) {
93 		ub_c_error_msg("cannot open include file '%s': %s",
94 			filename, strerror(errno));
95 		free(s);
96 		free(nm);
97 		return;
98 	}
99 	LEXOUT(("switch_to_include_file(%s)\n", filename));
100 	s->filename = cfg_parser->filename;
101 	s->line = cfg_parser->line;
102 	s->buffer = YY_CURRENT_BUFFER;
103 	s->next = config_include_stack;
104 	config_include_stack = s;
105 	cfg_parser->filename = nm;
106 	cfg_parser->line = 1;
107 	yy_switch_to_buffer(yy_create_buffer(input, YY_BUF_SIZE));
108 }
109 
110 static void config_start_include_glob(const char* filename)
111 {
112 
113 	/* check for wildcards */
114 #ifdef HAVE_GLOB
115 	glob_t g;
116 	size_t i;
117 	int r, flags;
118 	if(!(!strchr(filename, '*') && !strchr(filename, '?') && !strchr(filename, '[') &&
119 		!strchr(filename, '{') && !strchr(filename, '~'))) {
120 		flags = 0
121 #ifdef GLOB_ERR
122 			| GLOB_ERR
123 #endif
124 			 /* do not set GLOB_NOSORT so the results are sorted
125 			    and in a predictable order. */
126 #ifdef GLOB_BRACE
127 			| GLOB_BRACE
128 #endif
129 #ifdef GLOB_TILDE
130 			| GLOB_TILDE
131 #endif
132 		;
133 		memset(&g, 0, sizeof(g));
134 		if(cfg_parser->chroot && strncmp(filename, cfg_parser->chroot,
135 			strlen(cfg_parser->chroot)) == 0) {
136 			filename += strlen(cfg_parser->chroot);
137 		}
138 		r = glob(filename, flags, NULL, &g);
139 		if(r) {
140 			/* some error */
141 			globfree(&g);
142 			if(r == GLOB_NOMATCH)
143 				return; /* no matches for pattern */
144 			config_start_include(filename); /* let original deal with it */
145 			return;
146 		}
147 		/* process files found, if any */
148 		for(i=0; i<(size_t)g.gl_pathc; i++) {
149 			config_start_include(g.gl_pathv[i]);
150 		}
151 		globfree(&g);
152 		return;
153 	}
154 #endif /* HAVE_GLOB */
155 
156 	config_start_include(filename);
157 }
158 
159 static void config_end_include(void)
160 {
161 	struct inc_state* s = config_include_stack;
162 	--inc_depth;
163 	if(!s) return;
164 	free(cfg_parser->filename);
165 	cfg_parser->filename = s->filename;
166 	cfg_parser->line = s->line;
167 	yy_delete_buffer(YY_CURRENT_BUFFER);
168 	yy_switch_to_buffer(s->buffer);
169 	config_include_stack = s->next;
170 	free(s);
171 }
172 
173 #ifndef yy_set_bol /* compat definition, for flex 2.4.6 */
174 #define yy_set_bol(at_bol) \
175         { \
176 	        if ( ! yy_current_buffer ) \
177 	                yy_current_buffer = yy_create_buffer( ub_c_in, YY_BUF_SIZE ); \
178 	        yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \
179         }
180 #endif
181 
182 %}
183 %option noinput
184 %option nounput
185 %{
186 #ifndef YY_NO_UNPUT
187 #define YY_NO_UNPUT 1
188 #endif
189 #ifndef YY_NO_INPUT
190 #define YY_NO_INPUT 1
191 #endif
192 %}
193 
194 SPACE   [ \t]
195 LETTER  [a-zA-Z]
196 UNQUOTEDLETTER [^\'\"\n\r \t\\]|\\.
197 UNQUOTEDLETTER_NOCOLON [^\:\'\"\n\r \t\\]|\\.
198 NEWLINE [\r\n]
199 COMMENT \#
200 COLON 	\:
201 DQANY     [^\"\n\r\\]|\\.
202 SQANY     [^\'\n\r\\]|\\.
203 
204 %x	quotedstring singlequotedstr include include_quoted val
205 
206 %%
207 <INITIAL,val>{SPACE}*	{
208 	LEXOUT(("SP ")); /* ignore */ }
209 <INITIAL,val>{SPACE}*{COMMENT}.*	{
210 	/* note that flex makes the longest match and '.' is any but not nl */
211 	LEXOUT(("comment(%s) ", ub_c_text)); /* ignore */ }
212 server{COLON}			{ YDVAR(0, VAR_SERVER) }
213 qname-minimisation{COLON}	{ YDVAR(1, VAR_QNAME_MINIMISATION) }
214 qname-minimisation-strict{COLON} { YDVAR(1, VAR_QNAME_MINIMISATION_STRICT) }
215 num-threads{COLON}		{ YDVAR(1, VAR_NUM_THREADS) }
216 verbosity{COLON}		{ YDVAR(1, VAR_VERBOSITY) }
217 port{COLON}			{ YDVAR(1, VAR_PORT) }
218 outgoing-range{COLON}		{ YDVAR(1, VAR_OUTGOING_RANGE) }
219 outgoing-port-permit{COLON}	{ YDVAR(1, VAR_OUTGOING_PORT_PERMIT) }
220 outgoing-port-avoid{COLON}	{ YDVAR(1, VAR_OUTGOING_PORT_AVOID) }
221 outgoing-num-tcp{COLON}		{ YDVAR(1, VAR_OUTGOING_NUM_TCP) }
222 incoming-num-tcp{COLON}		{ YDVAR(1, VAR_INCOMING_NUM_TCP) }
223 do-ip4{COLON}			{ YDVAR(1, VAR_DO_IP4) }
224 do-ip6{COLON}			{ YDVAR(1, VAR_DO_IP6) }
225 prefer-ip6{COLON}		{ YDVAR(1, VAR_PREFER_IP6) }
226 do-udp{COLON}			{ YDVAR(1, VAR_DO_UDP) }
227 do-tcp{COLON}			{ YDVAR(1, VAR_DO_TCP) }
228 tcp-upstream{COLON}		{ YDVAR(1, VAR_TCP_UPSTREAM) }
229 tcp-mss{COLON}			{ YDVAR(1, VAR_TCP_MSS) }
230 outgoing-tcp-mss{COLON}		{ YDVAR(1, VAR_OUTGOING_TCP_MSS) }
231 tcp-idle-timeout{COLON}		{ YDVAR(1, VAR_TCP_IDLE_TIMEOUT) }
232 edns-tcp-keepalive{COLON}	{ YDVAR(1, VAR_EDNS_TCP_KEEPALIVE) }
233 edns-tcp-keepalive-timeout{COLON} { YDVAR(1, VAR_EDNS_TCP_KEEPALIVE_TIMEOUT) }
234 ssl-upstream{COLON}		{ YDVAR(1, VAR_SSL_UPSTREAM) }
235 tls-upstream{COLON}		{ YDVAR(1, VAR_SSL_UPSTREAM) }
236 ssl-service-key{COLON}		{ YDVAR(1, VAR_SSL_SERVICE_KEY) }
237 tls-service-key{COLON}		{ YDVAR(1, VAR_SSL_SERVICE_KEY) }
238 ssl-service-pem{COLON}		{ YDVAR(1, VAR_SSL_SERVICE_PEM) }
239 tls-service-pem{COLON}		{ YDVAR(1, VAR_SSL_SERVICE_PEM) }
240 ssl-port{COLON}			{ YDVAR(1, VAR_SSL_PORT) }
241 tls-port{COLON}			{ YDVAR(1, VAR_SSL_PORT) }
242 ssl-cert-bundle{COLON}		{ YDVAR(1, VAR_TLS_CERT_BUNDLE) }
243 tls-cert-bundle{COLON}		{ YDVAR(1, VAR_TLS_CERT_BUNDLE) }
244 tls-win-cert{COLON}		{ YDVAR(1, VAR_TLS_WIN_CERT) }
245 additional-ssl-port{COLON}	{ YDVAR(1, VAR_TLS_ADDITIONAL_PORT) }
246 additional-tls-port{COLON}	{ YDVAR(1, VAR_TLS_ADDITIONAL_PORT) }
247 tls-additional-ports{COLON}	{ YDVAR(1, VAR_TLS_ADDITIONAL_PORT) }
248 tls-additional-port{COLON}	{ YDVAR(1, VAR_TLS_ADDITIONAL_PORT) }
249 tls-session-ticket-keys{COLON}	{ YDVAR(1, VAR_TLS_SESSION_TICKET_KEYS) }
250 tls-ciphers{COLON}		{ YDVAR(1, VAR_TLS_CIPHERS) }
251 tls-ciphersuites{COLON}		{ YDVAR(1, VAR_TLS_CIPHERSUITES) }
252 use-systemd{COLON}		{ YDVAR(1, VAR_USE_SYSTEMD) }
253 do-daemonize{COLON}		{ YDVAR(1, VAR_DO_DAEMONIZE) }
254 interface{COLON}		{ YDVAR(1, VAR_INTERFACE) }
255 ip-address{COLON}		{ YDVAR(1, VAR_INTERFACE) }
256 outgoing-interface{COLON}	{ YDVAR(1, VAR_OUTGOING_INTERFACE) }
257 interface-automatic{COLON}	{ YDVAR(1, VAR_INTERFACE_AUTOMATIC) }
258 so-rcvbuf{COLON}		{ YDVAR(1, VAR_SO_RCVBUF) }
259 so-sndbuf{COLON}		{ YDVAR(1, VAR_SO_SNDBUF) }
260 so-reuseport{COLON}		{ YDVAR(1, VAR_SO_REUSEPORT) }
261 ip-transparent{COLON}		{ YDVAR(1, VAR_IP_TRANSPARENT) }
262 ip-freebind{COLON}		{ YDVAR(1, VAR_IP_FREEBIND) }
263 chroot{COLON}			{ YDVAR(1, VAR_CHROOT) }
264 username{COLON}			{ YDVAR(1, VAR_USERNAME) }
265 directory{COLON}		{ YDVAR(1, VAR_DIRECTORY) }
266 logfile{COLON}			{ YDVAR(1, VAR_LOGFILE) }
267 pidfile{COLON}			{ YDVAR(1, VAR_PIDFILE) }
268 root-hints{COLON}		{ YDVAR(1, VAR_ROOT_HINTS) }
269 stream-wait-size{COLON}		{ YDVAR(1, VAR_STREAM_WAIT_SIZE) }
270 edns-buffer-size{COLON}		{ YDVAR(1, VAR_EDNS_BUFFER_SIZE) }
271 msg-buffer-size{COLON}		{ YDVAR(1, VAR_MSG_BUFFER_SIZE) }
272 msg-cache-size{COLON}		{ YDVAR(1, VAR_MSG_CACHE_SIZE) }
273 msg-cache-slabs{COLON}		{ YDVAR(1, VAR_MSG_CACHE_SLABS) }
274 rrset-cache-size{COLON}		{ YDVAR(1, VAR_RRSET_CACHE_SIZE) }
275 rrset-cache-slabs{COLON}	{ YDVAR(1, VAR_RRSET_CACHE_SLABS) }
276 cache-max-ttl{COLON}     	{ YDVAR(1, VAR_CACHE_MAX_TTL) }
277 cache-max-negative-ttl{COLON}   { YDVAR(1, VAR_CACHE_MAX_NEGATIVE_TTL) }
278 cache-min-ttl{COLON}     	{ YDVAR(1, VAR_CACHE_MIN_TTL) }
279 infra-host-ttl{COLON}		{ YDVAR(1, VAR_INFRA_HOST_TTL) }
280 infra-lame-ttl{COLON}		{ YDVAR(1, VAR_INFRA_LAME_TTL) }
281 infra-cache-slabs{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_SLABS) }
282 infra-cache-numhosts{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_NUMHOSTS) }
283 infra-cache-lame-size{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_LAME_SIZE) }
284 infra-cache-min-rtt{COLON}	{ YDVAR(1, VAR_INFRA_CACHE_MIN_RTT) }
285 num-queries-per-thread{COLON}	{ YDVAR(1, VAR_NUM_QUERIES_PER_THREAD) }
286 jostle-timeout{COLON}		{ YDVAR(1, VAR_JOSTLE_TIMEOUT) }
287 delay-close{COLON}		{ YDVAR(1, VAR_DELAY_CLOSE) }
288 target-fetch-policy{COLON}	{ YDVAR(1, VAR_TARGET_FETCH_POLICY) }
289 harden-short-bufsize{COLON}	{ YDVAR(1, VAR_HARDEN_SHORT_BUFSIZE) }
290 harden-large-queries{COLON}	{ YDVAR(1, VAR_HARDEN_LARGE_QUERIES) }
291 harden-glue{COLON}		{ YDVAR(1, VAR_HARDEN_GLUE) }
292 harden-dnssec-stripped{COLON}	{ YDVAR(1, VAR_HARDEN_DNSSEC_STRIPPED) }
293 harden-below-nxdomain{COLON}	{ YDVAR(1, VAR_HARDEN_BELOW_NXDOMAIN) }
294 harden-referral-path{COLON}	{ YDVAR(1, VAR_HARDEN_REFERRAL_PATH) }
295 harden-algo-downgrade{COLON}	{ YDVAR(1, VAR_HARDEN_ALGO_DOWNGRADE) }
296 use-caps-for-id{COLON}		{ YDVAR(1, VAR_USE_CAPS_FOR_ID) }
297 caps-whitelist{COLON}		{ YDVAR(1, VAR_CAPS_WHITELIST) }
298 unwanted-reply-threshold{COLON}	{ YDVAR(1, VAR_UNWANTED_REPLY_THRESHOLD) }
299 private-address{COLON}		{ YDVAR(1, VAR_PRIVATE_ADDRESS) }
300 private-domain{COLON}		{ YDVAR(1, VAR_PRIVATE_DOMAIN) }
301 prefetch-key{COLON}		{ YDVAR(1, VAR_PREFETCH_KEY) }
302 prefetch{COLON}			{ YDVAR(1, VAR_PREFETCH) }
303 deny-any{COLON}			{ YDVAR(1, VAR_DENY_ANY) }
304 stub-zone{COLON}		{ YDVAR(0, VAR_STUB_ZONE) }
305 name{COLON}			{ YDVAR(1, VAR_NAME) }
306 stub-addr{COLON}		{ YDVAR(1, VAR_STUB_ADDR) }
307 stub-host{COLON}		{ YDVAR(1, VAR_STUB_HOST) }
308 stub-prime{COLON}		{ YDVAR(1, VAR_STUB_PRIME) }
309 stub-first{COLON}		{ YDVAR(1, VAR_STUB_FIRST) }
310 stub-no-cache{COLON}		{ YDVAR(1, VAR_STUB_NO_CACHE) }
311 stub-ssl-upstream{COLON}	{ YDVAR(1, VAR_STUB_SSL_UPSTREAM) }
312 stub-tls-upstream{COLON}	{ YDVAR(1, VAR_STUB_SSL_UPSTREAM) }
313 forward-zone{COLON}		{ YDVAR(0, VAR_FORWARD_ZONE) }
314 forward-addr{COLON}		{ YDVAR(1, VAR_FORWARD_ADDR) }
315 forward-host{COLON}		{ YDVAR(1, VAR_FORWARD_HOST) }
316 forward-first{COLON}		{ YDVAR(1, VAR_FORWARD_FIRST) }
317 forward-no-cache{COLON}		{ YDVAR(1, VAR_FORWARD_NO_CACHE) }
318 forward-ssl-upstream{COLON}	{ YDVAR(1, VAR_FORWARD_SSL_UPSTREAM) }
319 forward-tls-upstream{COLON}	{ YDVAR(1, VAR_FORWARD_SSL_UPSTREAM) }
320 auth-zone{COLON}		{ YDVAR(0, VAR_AUTH_ZONE) }
321 zonefile{COLON}			{ YDVAR(1, VAR_ZONEFILE) }
322 master{COLON}			{ YDVAR(1, VAR_MASTER) }
323 url{COLON}			{ YDVAR(1, VAR_URL) }
324 allow-notify{COLON}		{ YDVAR(1, VAR_ALLOW_NOTIFY) }
325 for-downstream{COLON}		{ YDVAR(1, VAR_FOR_DOWNSTREAM) }
326 for-upstream{COLON}		{ YDVAR(1, VAR_FOR_UPSTREAM) }
327 fallback-enabled{COLON}		{ YDVAR(1, VAR_FALLBACK_ENABLED) }
328 view{COLON}			{ YDVAR(0, VAR_VIEW) }
329 view-first{COLON}		{ YDVAR(1, VAR_VIEW_FIRST) }
330 do-not-query-address{COLON}	{ YDVAR(1, VAR_DO_NOT_QUERY_ADDRESS) }
331 do-not-query-localhost{COLON}	{ YDVAR(1, VAR_DO_NOT_QUERY_LOCALHOST) }
332 access-control{COLON}		{ YDVAR(2, VAR_ACCESS_CONTROL) }
333 send-client-subnet{COLON}	{ YDVAR(1, VAR_SEND_CLIENT_SUBNET) }
334 client-subnet-zone{COLON}	{ YDVAR(1, VAR_CLIENT_SUBNET_ZONE) }
335 client-subnet-always-forward{COLON} { YDVAR(1, VAR_CLIENT_SUBNET_ALWAYS_FORWARD) }
336 client-subnet-opcode{COLON}	{ YDVAR(1, VAR_CLIENT_SUBNET_OPCODE) }
337 max-client-subnet-ipv4{COLON}	{ YDVAR(1, VAR_MAX_CLIENT_SUBNET_IPV4) }
338 max-client-subnet-ipv6{COLON}	{ YDVAR(1, VAR_MAX_CLIENT_SUBNET_IPV6) }
339 min-client-subnet-ipv4{COLON}	{ YDVAR(1, VAR_MIN_CLIENT_SUBNET_IPV4) }
340 min-client-subnet-ipv6{COLON}	{ YDVAR(1, VAR_MIN_CLIENT_SUBNET_IPV6) }
341 max-ecs-tree-size-ipv4{COLON}	{ YDVAR(1, VAR_MAX_ECS_TREE_SIZE_IPV4) }
342 max-ecs-tree-size-ipv6{COLON}	{ YDVAR(1, VAR_MAX_ECS_TREE_SIZE_IPV6) }
343 hide-identity{COLON}		{ YDVAR(1, VAR_HIDE_IDENTITY) }
344 hide-version{COLON}		{ YDVAR(1, VAR_HIDE_VERSION) }
345 hide-trustanchor{COLON}		{ YDVAR(1, VAR_HIDE_TRUSTANCHOR) }
346 identity{COLON}			{ YDVAR(1, VAR_IDENTITY) }
347 version{COLON}			{ YDVAR(1, VAR_VERSION) }
348 module-config{COLON}     	{ YDVAR(1, VAR_MODULE_CONF) }
349 dlv-anchor{COLON}		{ YDVAR(1, VAR_DLV_ANCHOR) }
350 dlv-anchor-file{COLON}		{ YDVAR(1, VAR_DLV_ANCHOR_FILE) }
351 trust-anchor-file{COLON}	{ YDVAR(1, VAR_TRUST_ANCHOR_FILE) }
352 auto-trust-anchor-file{COLON}	{ YDVAR(1, VAR_AUTO_TRUST_ANCHOR_FILE) }
353 trusted-keys-file{COLON}	{ YDVAR(1, VAR_TRUSTED_KEYS_FILE) }
354 trust-anchor{COLON}		{ YDVAR(1, VAR_TRUST_ANCHOR) }
355 trust-anchor-signaling{COLON}	{ YDVAR(1, VAR_TRUST_ANCHOR_SIGNALING) }
356 root-key-sentinel{COLON}	{ YDVAR(1, VAR_ROOT_KEY_SENTINEL) }
357 val-override-date{COLON}	{ YDVAR(1, VAR_VAL_OVERRIDE_DATE) }
358 val-sig-skew-min{COLON}		{ YDVAR(1, VAR_VAL_SIG_SKEW_MIN) }
359 val-sig-skew-max{COLON}		{ YDVAR(1, VAR_VAL_SIG_SKEW_MAX) }
360 val-bogus-ttl{COLON}		{ YDVAR(1, VAR_BOGUS_TTL) }
361 val-clean-additional{COLON}	{ YDVAR(1, VAR_VAL_CLEAN_ADDITIONAL) }
362 val-permissive-mode{COLON}	{ YDVAR(1, VAR_VAL_PERMISSIVE_MODE) }
363 aggressive-nsec{COLON}		{ YDVAR(1, VAR_AGGRESSIVE_NSEC) }
364 ignore-cd-flag{COLON}		{ YDVAR(1, VAR_IGNORE_CD_FLAG) }
365 serve-expired{COLON}		{ YDVAR(1, VAR_SERVE_EXPIRED) }
366 serve-expired-ttl{COLON}	{ YDVAR(1, VAR_SERVE_EXPIRED_TTL) }
367 serve-expired-ttl-reset{COLON}	{ YDVAR(1, VAR_SERVE_EXPIRED_TTL_RESET) }
368 fake-dsa{COLON}			{ YDVAR(1, VAR_FAKE_DSA) }
369 fake-sha1{COLON}		{ YDVAR(1, VAR_FAKE_SHA1) }
370 val-log-level{COLON}		{ YDVAR(1, VAR_VAL_LOG_LEVEL) }
371 key-cache-size{COLON}		{ YDVAR(1, VAR_KEY_CACHE_SIZE) }
372 key-cache-slabs{COLON}		{ YDVAR(1, VAR_KEY_CACHE_SLABS) }
373 neg-cache-size{COLON}		{ YDVAR(1, VAR_NEG_CACHE_SIZE) }
374 val-nsec3-keysize-iterations{COLON}	{
375 				  YDVAR(1, VAR_VAL_NSEC3_KEYSIZE_ITERATIONS) }
376 add-holddown{COLON}		{ YDVAR(1, VAR_ADD_HOLDDOWN) }
377 del-holddown{COLON}		{ YDVAR(1, VAR_DEL_HOLDDOWN) }
378 keep-missing{COLON}		{ YDVAR(1, VAR_KEEP_MISSING) }
379 permit-small-holddown{COLON}	{ YDVAR(1, VAR_PERMIT_SMALL_HOLDDOWN) }
380 use-syslog{COLON}		{ YDVAR(1, VAR_USE_SYSLOG) }
381 log-identity{COLON}		{ YDVAR(1, VAR_LOG_IDENTITY) }
382 log-time-ascii{COLON}		{ YDVAR(1, VAR_LOG_TIME_ASCII) }
383 log-queries{COLON}		{ YDVAR(1, VAR_LOG_QUERIES) }
384 log-replies{COLON}		{ YDVAR(1, VAR_LOG_REPLIES) }
385 log-tag-queryreply{COLON}	{ YDVAR(1, VAR_LOG_TAG_QUERYREPLY) }
386 log-local-actions{COLON}       { YDVAR(1, VAR_LOG_LOCAL_ACTIONS) }
387 log-servfail{COLON}		{ YDVAR(1, VAR_LOG_SERVFAIL) }
388 local-zone{COLON}		{ YDVAR(2, VAR_LOCAL_ZONE) }
389 local-data{COLON}		{ YDVAR(1, VAR_LOCAL_DATA) }
390 local-data-ptr{COLON}		{ YDVAR(1, VAR_LOCAL_DATA_PTR) }
391 unblock-lan-zones{COLON}	{ YDVAR(1, VAR_UNBLOCK_LAN_ZONES) }
392 insecure-lan-zones{COLON}	{ YDVAR(1, VAR_INSECURE_LAN_ZONES) }
393 statistics-interval{COLON}	{ YDVAR(1, VAR_STATISTICS_INTERVAL) }
394 statistics-cumulative{COLON}	{ YDVAR(1, VAR_STATISTICS_CUMULATIVE) }
395 extended-statistics{COLON}	{ YDVAR(1, VAR_EXTENDED_STATISTICS) }
396 shm-enable{COLON}		{ YDVAR(1, VAR_SHM_ENABLE) }
397 shm-key{COLON}			{ YDVAR(1, VAR_SHM_KEY) }
398 remote-control{COLON}		{ YDVAR(0, VAR_REMOTE_CONTROL) }
399 control-enable{COLON}		{ YDVAR(1, VAR_CONTROL_ENABLE) }
400 control-interface{COLON}	{ YDVAR(1, VAR_CONTROL_INTERFACE) }
401 control-port{COLON}		{ YDVAR(1, VAR_CONTROL_PORT) }
402 control-use-cert{COLON}		{ YDVAR(1, VAR_CONTROL_USE_CERT) }
403 server-key-file{COLON}		{ YDVAR(1, VAR_SERVER_KEY_FILE) }
404 server-cert-file{COLON}		{ YDVAR(1, VAR_SERVER_CERT_FILE) }
405 control-key-file{COLON}		{ YDVAR(1, VAR_CONTROL_KEY_FILE) }
406 control-cert-file{COLON}	{ YDVAR(1, VAR_CONTROL_CERT_FILE) }
407 python-script{COLON}		{ YDVAR(1, VAR_PYTHON_SCRIPT) }
408 python{COLON}			{ YDVAR(0, VAR_PYTHON) }
409 domain-insecure{COLON}		{ YDVAR(1, VAR_DOMAIN_INSECURE) }
410 minimal-responses{COLON}	{ YDVAR(1, VAR_MINIMAL_RESPONSES) }
411 rrset-roundrobin{COLON}		{ YDVAR(1, VAR_RRSET_ROUNDROBIN) }
412 unknown-server-time-limit{COLON} { YDVAR(1, VAR_UNKNOWN_SERVER_TIME_LIMIT) }
413 max-udp-size{COLON}		{ YDVAR(1, VAR_MAX_UDP_SIZE) }
414 dns64-prefix{COLON}		{ YDVAR(1, VAR_DNS64_PREFIX) }
415 dns64-synthall{COLON}		{ YDVAR(1, VAR_DNS64_SYNTHALL) }
416 dns64-ignore-aaaa{COLON}	{ YDVAR(1, VAR_DNS64_IGNORE_AAAA) }
417 define-tag{COLON}		{ YDVAR(1, VAR_DEFINE_TAG) }
418 local-zone-tag{COLON}		{ YDVAR(2, VAR_LOCAL_ZONE_TAG) }
419 access-control-tag{COLON}	{ YDVAR(2, VAR_ACCESS_CONTROL_TAG) }
420 access-control-tag-action{COLON} { YDVAR(3, VAR_ACCESS_CONTROL_TAG_ACTION) }
421 access-control-tag-data{COLON}	{ YDVAR(3, VAR_ACCESS_CONTROL_TAG_DATA) }
422 access-control-view{COLON}	{ YDVAR(2, VAR_ACCESS_CONTROL_VIEW) }
423 local-zone-override{COLON}	{ YDVAR(3, VAR_LOCAL_ZONE_OVERRIDE) }
424 dnstap{COLON}			{ YDVAR(0, VAR_DNSTAP) }
425 dnstap-enable{COLON}		{ YDVAR(1, VAR_DNSTAP_ENABLE) }
426 dnstap-socket-path{COLON}	{ YDVAR(1, VAR_DNSTAP_SOCKET_PATH) }
427 dnstap-send-identity{COLON}	{ YDVAR(1, VAR_DNSTAP_SEND_IDENTITY) }
428 dnstap-send-version{COLON}	{ YDVAR(1, VAR_DNSTAP_SEND_VERSION) }
429 dnstap-identity{COLON}		{ YDVAR(1, VAR_DNSTAP_IDENTITY) }
430 dnstap-version{COLON}		{ YDVAR(1, VAR_DNSTAP_VERSION) }
431 dnstap-log-resolver-query-messages{COLON}	{
432 		YDVAR(1, VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES) }
433 dnstap-log-resolver-response-messages{COLON}	{
434 		YDVAR(1, VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES) }
435 dnstap-log-client-query-messages{COLON}		{
436 		YDVAR(1, VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES) }
437 dnstap-log-client-response-messages{COLON}	{
438 		YDVAR(1, VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES) }
439 dnstap-log-forwarder-query-messages{COLON}	{
440 		YDVAR(1, VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES) }
441 dnstap-log-forwarder-response-messages{COLON}	{
442 		YDVAR(1, VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES) }
443 disable-dnssec-lame-check{COLON} { YDVAR(1, VAR_DISABLE_DNSSEC_LAME_CHECK) }
444 ip-ratelimit{COLON}		{ YDVAR(1, VAR_IP_RATELIMIT) }
445 ratelimit{COLON}		{ YDVAR(1, VAR_RATELIMIT) }
446 ip-ratelimit-slabs{COLON}		{ YDVAR(1, VAR_IP_RATELIMIT_SLABS) }
447 ratelimit-slabs{COLON}		{ YDVAR(1, VAR_RATELIMIT_SLABS) }
448 ip-ratelimit-size{COLON}		{ YDVAR(1, VAR_IP_RATELIMIT_SIZE) }
449 ratelimit-size{COLON}		{ YDVAR(1, VAR_RATELIMIT_SIZE) }
450 ratelimit-for-domain{COLON}	{ YDVAR(2, VAR_RATELIMIT_FOR_DOMAIN) }
451 ratelimit-below-domain{COLON}	{ YDVAR(2, VAR_RATELIMIT_BELOW_DOMAIN) }
452 ip-ratelimit-factor{COLON}		{ YDVAR(1, VAR_IP_RATELIMIT_FACTOR) }
453 ratelimit-factor{COLON}		{ YDVAR(1, VAR_RATELIMIT_FACTOR) }
454 low-rtt{COLON}			{ YDVAR(1, VAR_LOW_RTT) }
455 fast-server-num{COLON}		{ YDVAR(1, VAR_FAST_SERVER_NUM) }
456 low-rtt-pct{COLON}		{ YDVAR(1, VAR_FAST_SERVER_PERMIL) }
457 low-rtt-permil{COLON}		{ YDVAR(1, VAR_FAST_SERVER_PERMIL) }
458 fast-server-permil{COLON}	{ YDVAR(1, VAR_FAST_SERVER_PERMIL) }
459 response-ip-tag{COLON}		{ YDVAR(2, VAR_RESPONSE_IP_TAG) }
460 response-ip{COLON}		{ YDVAR(2, VAR_RESPONSE_IP) }
461 response-ip-data{COLON}		{ YDVAR(2, VAR_RESPONSE_IP_DATA) }
462 dnscrypt{COLON}			{ YDVAR(0, VAR_DNSCRYPT) }
463 dnscrypt-enable{COLON}		{ YDVAR(1, VAR_DNSCRYPT_ENABLE) }
464 dnscrypt-port{COLON}		{ YDVAR(1, VAR_DNSCRYPT_PORT) }
465 dnscrypt-provider{COLON}	{ YDVAR(1, VAR_DNSCRYPT_PROVIDER) }
466 dnscrypt-secret-key{COLON}	{ YDVAR(1, VAR_DNSCRYPT_SECRET_KEY) }
467 dnscrypt-provider-cert{COLON}	{ YDVAR(1, VAR_DNSCRYPT_PROVIDER_CERT) }
468 dnscrypt-provider-cert-rotated{COLON}	{ YDVAR(1, VAR_DNSCRYPT_PROVIDER_CERT_ROTATED) }
469 dnscrypt-shared-secret-cache-size{COLON}	{
470 		YDVAR(1, VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE) }
471 dnscrypt-shared-secret-cache-slabs{COLON}	{
472 		YDVAR(1, VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS) }
473 dnscrypt-nonce-cache-size{COLON}	{ YDVAR(1, VAR_DNSCRYPT_NONCE_CACHE_SIZE) }
474 dnscrypt-nonce-cache-slabs{COLON}	{ YDVAR(1, VAR_DNSCRYPT_NONCE_CACHE_SLABS) }
475 ipsecmod-enabled{COLON}		{ YDVAR(1, VAR_IPSECMOD_ENABLED) }
476 ipsecmod-ignore-bogus{COLON}	{ YDVAR(1, VAR_IPSECMOD_IGNORE_BOGUS) }
477 ipsecmod-hook{COLON}		{ YDVAR(1, VAR_IPSECMOD_HOOK) }
478 ipsecmod-max-ttl{COLON}		{ YDVAR(1, VAR_IPSECMOD_MAX_TTL) }
479 ipsecmod-whitelist{COLON}	{ YDVAR(1, VAR_IPSECMOD_WHITELIST) }
480 ipsecmod-strict{COLON}		{ YDVAR(1, VAR_IPSECMOD_STRICT) }
481 cachedb{COLON}			{ YDVAR(0, VAR_CACHEDB) }
482 backend{COLON}			{ YDVAR(1, VAR_CACHEDB_BACKEND) }
483 secret-seed{COLON}		{ YDVAR(1, VAR_CACHEDB_SECRETSEED) }
484 redis-server-host{COLON}	{ YDVAR(1, VAR_CACHEDB_REDISHOST) }
485 redis-server-port{COLON}	{ YDVAR(1, VAR_CACHEDB_REDISPORT) }
486 redis-timeout{COLON}		{ YDVAR(1, VAR_CACHEDB_REDISTIMEOUT) }
487 udp-upstream-without-downstream{COLON} { YDVAR(1, VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM) }
488 tcp-connection-limit{COLON}	{ YDVAR(2, VAR_TCP_CONNECTION_LIMIT) }
489 <INITIAL,val>{NEWLINE}		{ LEXOUT(("NL\n")); cfg_parser->line++; }
490 
491 	/* Quoted strings. Strip leading and ending quotes */
492 <val>\"			{ BEGIN(quotedstring); LEXOUT(("QS ")); }
493 <quotedstring><<EOF>>   {
494         ub_c_error("EOF inside quoted string");
495 	if(--num_args == 0) { BEGIN(INITIAL); }
496 	else		    { BEGIN(val); }
497 }
498 <quotedstring>{DQANY}*  { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
499 <quotedstring>{NEWLINE} { ub_c_error("newline inside quoted string, no end \"");
500 			  cfg_parser->line++; BEGIN(INITIAL); }
501 <quotedstring>\" {
502         LEXOUT(("QE "));
503 	if(--num_args == 0) { BEGIN(INITIAL); }
504 	else		    { BEGIN(val); }
505         ub_c_text[ub_c_leng - 1] = '\0';
506 	ub_c_lval.str = strdup(ub_c_text);
507 	if(!ub_c_lval.str)
508 		ub_c_error("out of memory");
509         return STRING_ARG;
510 }
511 
512 	/* Single Quoted strings. Strip leading and ending quotes */
513 <val>\'			{ BEGIN(singlequotedstr); LEXOUT(("SQS ")); }
514 <singlequotedstr><<EOF>>   {
515         ub_c_error("EOF inside quoted string");
516 	if(--num_args == 0) { BEGIN(INITIAL); }
517 	else		    { BEGIN(val); }
518 }
519 <singlequotedstr>{SQANY}*  { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
520 <singlequotedstr>{NEWLINE} { ub_c_error("newline inside quoted string, no end '");
521 			     cfg_parser->line++; BEGIN(INITIAL); }
522 <singlequotedstr>\' {
523         LEXOUT(("SQE "));
524 	if(--num_args == 0) { BEGIN(INITIAL); }
525 	else		    { BEGIN(val); }
526         ub_c_text[ub_c_leng - 1] = '\0';
527 	ub_c_lval.str = strdup(ub_c_text);
528 	if(!ub_c_lval.str)
529 		ub_c_error("out of memory");
530         return STRING_ARG;
531 }
532 
533 	/* include: directive */
534 <INITIAL,val>include{COLON}	{
535 	LEXOUT(("v(%s) ", ub_c_text)); inc_prev = YYSTATE; BEGIN(include); }
536 <include><<EOF>>	{
537         ub_c_error("EOF inside include directive");
538         BEGIN(inc_prev);
539 }
540 <include>{SPACE}*	{ LEXOUT(("ISP ")); /* ignore */ }
541 <include>{NEWLINE}	{ LEXOUT(("NL\n")); cfg_parser->line++;}
542 <include>\"		{ LEXOUT(("IQS ")); BEGIN(include_quoted); }
543 <include>{UNQUOTEDLETTER}*	{
544 	LEXOUT(("Iunquotedstr(%s) ", ub_c_text));
545 	config_start_include_glob(ub_c_text);
546 	BEGIN(inc_prev);
547 }
548 <include_quoted><<EOF>>	{
549         ub_c_error("EOF inside quoted string");
550         BEGIN(inc_prev);
551 }
552 <include_quoted>{DQANY}*	{ LEXOUT(("ISTR(%s) ", ub_c_text)); yymore(); }
553 <include_quoted>{NEWLINE}	{ ub_c_error("newline before \" in include name");
554 				  cfg_parser->line++; BEGIN(inc_prev); }
555 <include_quoted>\"	{
556 	LEXOUT(("IQE "));
557 	ub_c_text[ub_c_leng - 1] = '\0';
558 	config_start_include_glob(ub_c_text);
559 	BEGIN(inc_prev);
560 }
561 <INITIAL,val><<EOF>>	{
562 	LEXOUT(("LEXEOF "));
563 	yy_set_bol(1); /* Set beginning of line, so "^" rules match.  */
564 	if (!config_include_stack) {
565 		yyterminate();
566 	} else {
567 		fclose(ub_c_in);
568 		config_end_include();
569 	}
570 }
571 
572 <val>{UNQUOTEDLETTER}*	{ LEXOUT(("unquotedstr(%s) ", ub_c_text));
573 			if(--num_args == 0) { BEGIN(INITIAL); }
574 			ub_c_lval.str = strdup(ub_c_text); return STRING_ARG; }
575 
576 {UNQUOTEDLETTER_NOCOLON}*	{
577 	ub_c_error_msg("unknown keyword '%s'", ub_c_text);
578 	}
579 
580 <*>.	{
581 	ub_c_error_msg("stray '%s'", ub_c_text);
582 	}
583 
584 %%
585