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