]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/unbound/util/configparser.y
Upgrade Unbound to 1.6.0. More to follow.
[FreeBSD/FreeBSD.git] / contrib / unbound / util / configparser.y
1 /*
2  * configparser.y -- yacc grammar for unbound configuration files
3  *
4  * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
5  *
6  * Copyright (c) 2007, NLnet Labs. All rights reserved.
7  * 
8  * This software is open source.
9  * 
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 
14  * Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * 
17  * Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  * 
21  * Neither the name of the NLNET LABS nor the names of its contributors may
22  * be used to endorse or promote products derived from this software without
23  * specific prior written permission.
24  * 
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37
38 %{
39 #include "config.h"
40
41 #include <stdarg.h>
42 #include <stdio.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <assert.h>
46
47 #include "util/configyyrename.h"
48 #include "util/config_file.h"
49 #include "util/net_help.h"
50
51 int ub_c_lex(void);
52 void ub_c_error(const char *message);
53
54 /* these need to be global, otherwise they cannot be used inside yacc */
55 extern struct config_parser_state* cfg_parser;
56
57 #if 0
58 #define OUTYY(s)  printf s /* used ONLY when debugging */
59 #else
60 #define OUTYY(s)
61 #endif
62
63 %}
64 %union {
65         char*   str;
66 };
67
68 %token SPACE LETTER NEWLINE COMMENT COLON ANY ZONESTR
69 %token <str> STRING_ARG
70 %token VAR_SERVER VAR_VERBOSITY VAR_NUM_THREADS VAR_PORT
71 %token VAR_OUTGOING_RANGE VAR_INTERFACE
72 %token VAR_DO_IP4 VAR_DO_IP6 VAR_PREFER_IP6 VAR_DO_UDP VAR_DO_TCP
73 %token VAR_TCP_MSS VAR_OUTGOING_TCP_MSS
74 %token VAR_CHROOT VAR_USERNAME VAR_DIRECTORY VAR_LOGFILE VAR_PIDFILE
75 %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD
76 %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP
77 %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS
78 %token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME
79 %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY
80 %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES
81 %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR
82 %token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION
83 %token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF
84 %token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE
85 %token VAR_BOGUS_TTL VAR_VAL_CLEAN_ADDITIONAL VAR_VAL_PERMISSIVE_MODE
86 %token VAR_INCOMING_NUM_TCP VAR_MSG_BUFFER_SIZE VAR_KEY_CACHE_SIZE
87 %token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE 
88 %token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG 
89 %token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST
90 %token VAR_CACHE_MAX_TTL VAR_HARDEN_DNSSEC_STRIPPED VAR_ACCESS_CONTROL
91 %token VAR_LOCAL_ZONE VAR_LOCAL_DATA VAR_INTERFACE_AUTOMATIC
92 %token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID
93 %token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT 
94 %token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR
95 %token VAR_NEG_CACHE_SIZE VAR_HARDEN_REFERRAL_PATH VAR_PRIVATE_ADDRESS
96 %token VAR_PRIVATE_DOMAIN VAR_REMOTE_CONTROL VAR_CONTROL_ENABLE
97 %token VAR_CONTROL_INTERFACE VAR_CONTROL_PORT VAR_SERVER_KEY_FILE
98 %token VAR_SERVER_CERT_FILE VAR_CONTROL_KEY_FILE VAR_CONTROL_CERT_FILE
99 %token VAR_CONTROL_USE_CERT
100 %token VAR_EXTENDED_STATISTICS VAR_LOCAL_DATA_PTR VAR_JOSTLE_TIMEOUT
101 %token VAR_STUB_PRIME VAR_UNWANTED_REPLY_THRESHOLD VAR_LOG_TIME_ASCII
102 %token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN
103 %token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL
104 %token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN 
105 %token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE VAR_PREFETCH
106 %token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_SO_REUSEPORT VAR_HARDEN_BELOW_NXDOMAIN
107 %token VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES VAR_TCP_UPSTREAM VAR_SSL_UPSTREAM
108 %token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST
109 %token VAR_STUB_SSL_UPSTREAM VAR_FORWARD_SSL_UPSTREAM
110 %token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN
111 %token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE
112 %token VAR_UNBLOCK_LAN_ZONES VAR_INSECURE_LAN_ZONES
113 %token VAR_INFRA_CACHE_MIN_RTT
114 %token VAR_DNS64_PREFIX VAR_DNS64_SYNTHALL
115 %token VAR_DNSTAP VAR_DNSTAP_ENABLE VAR_DNSTAP_SOCKET_PATH
116 %token VAR_DNSTAP_SEND_IDENTITY VAR_DNSTAP_SEND_VERSION
117 %token VAR_DNSTAP_IDENTITY VAR_DNSTAP_VERSION
118 %token VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES
119 %token VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES
120 %token VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES
121 %token VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES
122 %token VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES
123 %token VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES
124 %token VAR_HARDEN_ALGO_DOWNGRADE VAR_IP_TRANSPARENT
125 %token VAR_DISABLE_DNSSEC_LAME_CHECK
126 %token VAR_RATELIMIT VAR_RATELIMIT_SLABS VAR_RATELIMIT_SIZE
127 %token VAR_RATELIMIT_FOR_DOMAIN VAR_RATELIMIT_BELOW_DOMAIN VAR_RATELIMIT_FACTOR
128 %token VAR_CAPS_WHITELIST VAR_CACHE_MAX_NEGATIVE_TTL VAR_PERMIT_SMALL_HOLDDOWN
129 %token VAR_QNAME_MINIMISATION VAR_QNAME_MINIMISATION_STRICT VAR_IP_FREEBIND
130 %token VAR_DEFINE_TAG VAR_LOCAL_ZONE_TAG VAR_ACCESS_CONTROL_TAG
131 %token VAR_LOCAL_ZONE_OVERRIDE VAR_ACCESS_CONTROL_TAG_ACTION
132 %token VAR_ACCESS_CONTROL_TAG_DATA VAR_VIEW VAR_ACCESS_CONTROL_VIEW
133 %token VAR_VIEW_FIRST VAR_SERVE_EXPIRED VAR_FAKE_DSA
134 %token VAR_LOG_IDENTITY
135
136 %%
137 toplevelvars: /* empty */ | toplevelvars toplevelvar ;
138 toplevelvar: serverstart contents_server | stubstart contents_stub |
139         forwardstart contents_forward | pythonstart contents_py | 
140         rcstart contents_rc | dtstart contents_dt | viewstart 
141         contents_view
142         ;
143
144 /* server: declaration */
145 serverstart: VAR_SERVER
146         { 
147                 OUTYY(("\nP(server:)\n")); 
148         }
149         ;
150 contents_server: contents_server content_server 
151         | ;
152 content_server: server_num_threads | server_verbosity | server_port |
153         server_outgoing_range | server_do_ip4 |
154         server_do_ip6 | server_prefer_ip6 |
155         server_do_udp | server_do_tcp |
156         server_tcp_mss | server_outgoing_tcp_mss |
157         server_interface | server_chroot | server_username | 
158         server_directory | server_logfile | server_pidfile |
159         server_msg_cache_size | server_msg_cache_slabs |
160         server_num_queries_per_thread | server_rrset_cache_size | 
161         server_rrset_cache_slabs | server_outgoing_num_tcp | 
162         server_infra_host_ttl | server_infra_lame_ttl | 
163         server_infra_cache_slabs | server_infra_cache_numhosts |
164         server_infra_cache_lame_size | server_target_fetch_policy | 
165         server_harden_short_bufsize | server_harden_large_queries |
166         server_do_not_query_address | server_hide_identity |
167         server_hide_version | server_identity | server_version |
168         server_harden_glue | server_module_conf | server_trust_anchor_file |
169         server_trust_anchor | server_val_override_date | server_bogus_ttl |
170         server_val_clean_additional | server_val_permissive_mode |
171         server_incoming_num_tcp | server_msg_buffer_size | 
172         server_key_cache_size | server_key_cache_slabs | 
173         server_trusted_keys_file | server_val_nsec3_keysize_iterations |
174         server_use_syslog | server_outgoing_interface | server_root_hints |
175         server_do_not_query_localhost | server_cache_max_ttl |
176         server_harden_dnssec_stripped | server_access_control |
177         server_local_zone | server_local_data | server_interface_automatic |
178         server_statistics_interval | server_do_daemonize | 
179         server_use_caps_for_id | server_statistics_cumulative |
180         server_outgoing_port_permit | server_outgoing_port_avoid |
181         server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size |
182         server_harden_referral_path | server_private_address |
183         server_private_domain | server_extended_statistics | 
184         server_local_data_ptr | server_jostle_timeout | 
185         server_unwanted_reply_threshold | server_log_time_ascii | 
186         server_domain_insecure | server_val_sig_skew_min | 
187         server_val_sig_skew_max | server_cache_min_ttl | server_val_log_level |
188         server_auto_trust_anchor_file | server_add_holddown | 
189         server_del_holddown | server_keep_missing | server_so_rcvbuf |
190         server_edns_buffer_size | server_prefetch | server_prefetch_key |
191         server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag |
192         server_log_queries | server_tcp_upstream | server_ssl_upstream |
193         server_ssl_service_key | server_ssl_service_pem | server_ssl_port |
194         server_minimal_responses | server_rrset_roundrobin | server_max_udp_size |
195         server_so_reuseport | server_delay_close |
196         server_unblock_lan_zones | server_insecure_lan_zones |
197         server_dns64_prefix | server_dns64_synthall |
198         server_infra_cache_min_rtt | server_harden_algo_downgrade |
199         server_ip_transparent | server_ratelimit | server_ratelimit_slabs |
200         server_ratelimit_size | server_ratelimit_for_domain |
201         server_ratelimit_below_domain | server_ratelimit_factor |
202         server_caps_whitelist | server_cache_max_negative_ttl |
203         server_permit_small_holddown | server_qname_minimisation |
204         server_ip_freebind | server_define_tag | server_local_zone_tag |
205         server_disable_dnssec_lame_check | server_access_control_tag |
206         server_local_zone_override | server_access_control_tag_action |
207         server_access_control_tag_data | server_access_control_view |
208         server_qname_minimisation_strict | server_serve_expired |
209         server_fake_dsa | server_log_identity
210         ;
211 stubstart: VAR_STUB_ZONE
212         {
213                 struct config_stub* s;
214                 OUTYY(("\nP(stub_zone:)\n")); 
215                 s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
216                 if(s) {
217                         s->next = cfg_parser->cfg->stubs;
218                         cfg_parser->cfg->stubs = s;
219                 } else 
220                         yyerror("out of memory");
221         }
222         ;
223 contents_stub: contents_stub content_stub 
224         | ;
225 content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first |
226         stub_ssl_upstream
227         ;
228 forwardstart: VAR_FORWARD_ZONE
229         {
230                 struct config_stub* s;
231                 OUTYY(("\nP(forward_zone:)\n")); 
232                 s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
233                 if(s) {
234                         s->next = cfg_parser->cfg->forwards;
235                         cfg_parser->cfg->forwards = s;
236                 } else 
237                         yyerror("out of memory");
238         }
239         ;
240 contents_forward: contents_forward content_forward 
241         | ;
242 content_forward: forward_name | forward_host | forward_addr | forward_first |
243         forward_ssl_upstream
244         ;
245 viewstart: VAR_VIEW
246         {
247                 struct config_view* s;
248                 OUTYY(("\nP(view:)\n")); 
249                 s = (struct config_view*)calloc(1, sizeof(struct config_view));
250                 if(s) {
251                         s->next = cfg_parser->cfg->views;
252                         if(s->next && !s->next->name)
253                                 yyerror("view without name");
254                         cfg_parser->cfg->views = s;
255                 } else 
256                         yyerror("out of memory");
257         }
258         ;
259 contents_view: contents_view content_view 
260         | ;
261 content_view: view_name | view_local_zone | view_local_data | view_first
262         ;
263 server_num_threads: VAR_NUM_THREADS STRING_ARG 
264         { 
265                 OUTYY(("P(server_num_threads:%s)\n", $2)); 
266                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
267                         yyerror("number expected");
268                 else cfg_parser->cfg->num_threads = atoi($2);
269                 free($2);
270         }
271         ;
272 server_verbosity: VAR_VERBOSITY STRING_ARG 
273         { 
274                 OUTYY(("P(server_verbosity:%s)\n", $2)); 
275                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
276                         yyerror("number expected");
277                 else cfg_parser->cfg->verbosity = atoi($2);
278                 free($2);
279         }
280         ;
281 server_statistics_interval: VAR_STATISTICS_INTERVAL STRING_ARG 
282         { 
283                 OUTYY(("P(server_statistics_interval:%s)\n", $2)); 
284                 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0)
285                         cfg_parser->cfg->stat_interval = 0;
286                 else if(atoi($2) == 0)
287                         yyerror("number expected");
288                 else cfg_parser->cfg->stat_interval = atoi($2);
289                 free($2);
290         }
291         ;
292 server_statistics_cumulative: VAR_STATISTICS_CUMULATIVE STRING_ARG
293         {
294                 OUTYY(("P(server_statistics_cumulative:%s)\n", $2));
295                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
296                         yyerror("expected yes or no.");
297                 else cfg_parser->cfg->stat_cumulative = (strcmp($2, "yes")==0);
298                 free($2);
299         }
300         ;
301 server_extended_statistics: VAR_EXTENDED_STATISTICS STRING_ARG
302         {
303                 OUTYY(("P(server_extended_statistics:%s)\n", $2));
304                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
305                         yyerror("expected yes or no.");
306                 else cfg_parser->cfg->stat_extended = (strcmp($2, "yes")==0);
307                 free($2);
308         }
309         ;
310 server_port: VAR_PORT STRING_ARG
311         {
312                 OUTYY(("P(server_port:%s)\n", $2));
313                 if(atoi($2) == 0)
314                         yyerror("port number expected");
315                 else cfg_parser->cfg->port = atoi($2);
316                 free($2);
317         }
318         ;
319 server_interface: VAR_INTERFACE STRING_ARG
320         {
321                 OUTYY(("P(server_interface:%s)\n", $2));
322                 if(cfg_parser->cfg->num_ifs == 0)
323                         cfg_parser->cfg->ifs = calloc(1, sizeof(char*));
324                 else    cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs,
325                                 (cfg_parser->cfg->num_ifs+1)*sizeof(char*));
326                 if(!cfg_parser->cfg->ifs)
327                         yyerror("out of memory");
328                 else
329                         cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = $2;
330         }
331         ;
332 server_outgoing_interface: VAR_OUTGOING_INTERFACE STRING_ARG
333         {
334                 OUTYY(("P(server_outgoing_interface:%s)\n", $2));
335                 if(cfg_parser->cfg->num_out_ifs == 0)
336                         cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*));
337                 else    cfg_parser->cfg->out_ifs = realloc(
338                         cfg_parser->cfg->out_ifs, 
339                         (cfg_parser->cfg->num_out_ifs+1)*sizeof(char*));
340                 if(!cfg_parser->cfg->out_ifs)
341                         yyerror("out of memory");
342                 else
343                         cfg_parser->cfg->out_ifs[
344                                 cfg_parser->cfg->num_out_ifs++] = $2;
345         }
346         ;
347 server_outgoing_range: VAR_OUTGOING_RANGE STRING_ARG
348         {
349                 OUTYY(("P(server_outgoing_range:%s)\n", $2));
350                 if(atoi($2) == 0)
351                         yyerror("number expected");
352                 else cfg_parser->cfg->outgoing_num_ports = atoi($2);
353                 free($2);
354         }
355         ;
356 server_outgoing_port_permit: VAR_OUTGOING_PORT_PERMIT STRING_ARG
357         {
358                 OUTYY(("P(server_outgoing_port_permit:%s)\n", $2));
359                 if(!cfg_mark_ports($2, 1, 
360                         cfg_parser->cfg->outgoing_avail_ports, 65536))
361                         yyerror("port number or range (\"low-high\") expected");
362                 free($2);
363         }
364         ;
365 server_outgoing_port_avoid: VAR_OUTGOING_PORT_AVOID STRING_ARG
366         {
367                 OUTYY(("P(server_outgoing_port_avoid:%s)\n", $2));
368                 if(!cfg_mark_ports($2, 0, 
369                         cfg_parser->cfg->outgoing_avail_ports, 65536))
370                         yyerror("port number or range (\"low-high\") expected");
371                 free($2);
372         }
373         ;
374 server_outgoing_num_tcp: VAR_OUTGOING_NUM_TCP STRING_ARG
375         {
376                 OUTYY(("P(server_outgoing_num_tcp:%s)\n", $2));
377                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
378                         yyerror("number expected");
379                 else cfg_parser->cfg->outgoing_num_tcp = atoi($2);
380                 free($2);
381         }
382         ;
383 server_incoming_num_tcp: VAR_INCOMING_NUM_TCP STRING_ARG
384         {
385                 OUTYY(("P(server_incoming_num_tcp:%s)\n", $2));
386                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
387                         yyerror("number expected");
388                 else cfg_parser->cfg->incoming_num_tcp = atoi($2);
389                 free($2);
390         }
391         ;
392 server_interface_automatic: VAR_INTERFACE_AUTOMATIC STRING_ARG
393         {
394                 OUTYY(("P(server_interface_automatic:%s)\n", $2));
395                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
396                         yyerror("expected yes or no.");
397                 else cfg_parser->cfg->if_automatic = (strcmp($2, "yes")==0);
398                 free($2);
399         }
400         ;
401 server_do_ip4: VAR_DO_IP4 STRING_ARG
402         {
403                 OUTYY(("P(server_do_ip4:%s)\n", $2));
404                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
405                         yyerror("expected yes or no.");
406                 else cfg_parser->cfg->do_ip4 = (strcmp($2, "yes")==0);
407                 free($2);
408         }
409         ;
410 server_do_ip6: VAR_DO_IP6 STRING_ARG
411         {
412                 OUTYY(("P(server_do_ip6:%s)\n", $2));
413                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
414                         yyerror("expected yes or no.");
415                 else cfg_parser->cfg->do_ip6 = (strcmp($2, "yes")==0);
416                 free($2);
417         }
418         ;
419 server_do_udp: VAR_DO_UDP STRING_ARG
420         {
421                 OUTYY(("P(server_do_udp:%s)\n", $2));
422                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
423                         yyerror("expected yes or no.");
424                 else cfg_parser->cfg->do_udp = (strcmp($2, "yes")==0);
425                 free($2);
426         }
427         ;
428 server_do_tcp: VAR_DO_TCP STRING_ARG
429         {
430                 OUTYY(("P(server_do_tcp:%s)\n", $2));
431                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
432                         yyerror("expected yes or no.");
433                 else cfg_parser->cfg->do_tcp = (strcmp($2, "yes")==0);
434                 free($2);
435         }
436         ;
437 server_prefer_ip6: VAR_PREFER_IP6 STRING_ARG
438         {
439                 OUTYY(("P(server_prefer_ip6:%s)\n", $2));
440                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
441                         yyerror("expected yes or no.");
442                 else cfg_parser->cfg->prefer_ip6 = (strcmp($2, "yes")==0);
443                 free($2);
444         }
445         ;
446 server_tcp_mss: VAR_TCP_MSS STRING_ARG
447         {
448                 OUTYY(("P(server_tcp_mss:%s)\n", $2));
449                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
450                         yyerror("number expected");
451                 else cfg_parser->cfg->tcp_mss = atoi($2);
452                 free($2);
453         }
454         ;
455 server_outgoing_tcp_mss: VAR_OUTGOING_TCP_MSS STRING_ARG
456         {
457                 OUTYY(("P(server_outgoing_tcp_mss:%s)\n", $2));
458                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
459                         yyerror("number expected");
460                 else cfg_parser->cfg->outgoing_tcp_mss = atoi($2);
461                 free($2);
462         }
463         ;
464 server_tcp_upstream: VAR_TCP_UPSTREAM STRING_ARG
465         {
466                 OUTYY(("P(server_tcp_upstream:%s)\n", $2));
467                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
468                         yyerror("expected yes or no.");
469                 else cfg_parser->cfg->tcp_upstream = (strcmp($2, "yes")==0);
470                 free($2);
471         }
472         ;
473 server_ssl_upstream: VAR_SSL_UPSTREAM STRING_ARG
474         {
475                 OUTYY(("P(server_ssl_upstream:%s)\n", $2));
476                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
477                         yyerror("expected yes or no.");
478                 else cfg_parser->cfg->ssl_upstream = (strcmp($2, "yes")==0);
479                 free($2);
480         }
481         ;
482 server_ssl_service_key: VAR_SSL_SERVICE_KEY STRING_ARG
483         {
484                 OUTYY(("P(server_ssl_service_key:%s)\n", $2));
485                 free(cfg_parser->cfg->ssl_service_key);
486                 cfg_parser->cfg->ssl_service_key = $2;
487         }
488         ;
489 server_ssl_service_pem: VAR_SSL_SERVICE_PEM STRING_ARG
490         {
491                 OUTYY(("P(server_ssl_service_pem:%s)\n", $2));
492                 free(cfg_parser->cfg->ssl_service_pem);
493                 cfg_parser->cfg->ssl_service_pem = $2;
494         }
495         ;
496 server_ssl_port: VAR_SSL_PORT STRING_ARG
497         {
498                 OUTYY(("P(server_ssl_port:%s)\n", $2));
499                 if(atoi($2) == 0)
500                         yyerror("port number expected");
501                 else cfg_parser->cfg->ssl_port = atoi($2);
502                 free($2);
503         }
504         ;
505 server_do_daemonize: VAR_DO_DAEMONIZE STRING_ARG
506         {
507                 OUTYY(("P(server_do_daemonize:%s)\n", $2));
508                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
509                         yyerror("expected yes or no.");
510                 else cfg_parser->cfg->do_daemonize = (strcmp($2, "yes")==0);
511                 free($2);
512         }
513         ;
514 server_use_syslog: VAR_USE_SYSLOG STRING_ARG
515         {
516                 OUTYY(("P(server_use_syslog:%s)\n", $2));
517                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
518                         yyerror("expected yes or no.");
519                 else cfg_parser->cfg->use_syslog = (strcmp($2, "yes")==0);
520 #if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS)
521                 if(strcmp($2, "yes") == 0)
522                         yyerror("no syslog services are available. "
523                                 "(reconfigure and compile to add)");
524 #endif
525                 free($2);
526         }
527         ;
528 server_log_time_ascii: VAR_LOG_TIME_ASCII STRING_ARG
529         {
530                 OUTYY(("P(server_log_time_ascii:%s)\n", $2));
531                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
532                         yyerror("expected yes or no.");
533                 else cfg_parser->cfg->log_time_ascii = (strcmp($2, "yes")==0);
534                 free($2);
535         }
536         ;
537 server_log_queries: VAR_LOG_QUERIES STRING_ARG
538         {
539                 OUTYY(("P(server_log_queries:%s)\n", $2));
540                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
541                         yyerror("expected yes or no.");
542                 else cfg_parser->cfg->log_queries = (strcmp($2, "yes")==0);
543                 free($2);
544         }
545         ;
546 server_chroot: VAR_CHROOT STRING_ARG
547         {
548                 OUTYY(("P(server_chroot:%s)\n", $2));
549                 free(cfg_parser->cfg->chrootdir);
550                 cfg_parser->cfg->chrootdir = $2;
551         }
552         ;
553 server_username: VAR_USERNAME STRING_ARG
554         {
555                 OUTYY(("P(server_username:%s)\n", $2));
556                 free(cfg_parser->cfg->username);
557                 cfg_parser->cfg->username = $2;
558         }
559         ;
560 server_directory: VAR_DIRECTORY STRING_ARG
561         {
562                 OUTYY(("P(server_directory:%s)\n", $2));
563                 free(cfg_parser->cfg->directory);
564                 cfg_parser->cfg->directory = $2;
565                 /* change there right away for includes relative to this */
566                 if($2[0]) {
567                         char* d;
568 #ifdef UB_ON_WINDOWS
569                         w_config_adjust_directory(cfg_parser->cfg);
570 #endif
571                         d = cfg_parser->cfg->directory;
572                         /* adjust directory if we have already chroot,
573                          * like, we reread after sighup */
574                         if(cfg_parser->chroot && cfg_parser->chroot[0] &&
575                                 strncmp(d, cfg_parser->chroot, strlen(
576                                 cfg_parser->chroot)) == 0)
577                                 d += strlen(cfg_parser->chroot);
578                         if(chdir(d))
579                                 log_err("cannot chdir to directory: %s (%s)",
580                                         d, strerror(errno));
581                 }
582         }
583         ;
584 server_logfile: VAR_LOGFILE STRING_ARG
585         {
586                 OUTYY(("P(server_logfile:%s)\n", $2));
587                 free(cfg_parser->cfg->logfile);
588                 cfg_parser->cfg->logfile = $2;
589                 cfg_parser->cfg->use_syslog = 0;
590         }
591         ;
592 server_pidfile: VAR_PIDFILE STRING_ARG
593         {
594                 OUTYY(("P(server_pidfile:%s)\n", $2));
595                 free(cfg_parser->cfg->pidfile);
596                 cfg_parser->cfg->pidfile = $2;
597         }
598         ;
599 server_root_hints: VAR_ROOT_HINTS STRING_ARG
600         {
601                 OUTYY(("P(server_root_hints:%s)\n", $2));
602                 if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, $2))
603                         yyerror("out of memory");
604         }
605         ;
606 server_dlv_anchor_file: VAR_DLV_ANCHOR_FILE STRING_ARG
607         {
608                 OUTYY(("P(server_dlv_anchor_file:%s)\n", $2));
609                 free(cfg_parser->cfg->dlv_anchor_file);
610                 cfg_parser->cfg->dlv_anchor_file = $2;
611         }
612         ;
613 server_dlv_anchor: VAR_DLV_ANCHOR STRING_ARG
614         {
615                 OUTYY(("P(server_dlv_anchor:%s)\n", $2));
616                 if(!cfg_strlist_insert(&cfg_parser->cfg->dlv_anchor_list, $2))
617                         yyerror("out of memory");
618         }
619         ;
620 server_auto_trust_anchor_file: VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG
621         {
622                 OUTYY(("P(server_auto_trust_anchor_file:%s)\n", $2));
623                 if(!cfg_strlist_insert(&cfg_parser->cfg->
624                         auto_trust_anchor_file_list, $2))
625                         yyerror("out of memory");
626         }
627         ;
628 server_trust_anchor_file: VAR_TRUST_ANCHOR_FILE STRING_ARG
629         {
630                 OUTYY(("P(server_trust_anchor_file:%s)\n", $2));
631                 if(!cfg_strlist_insert(&cfg_parser->cfg->
632                         trust_anchor_file_list, $2))
633                         yyerror("out of memory");
634         }
635         ;
636 server_trusted_keys_file: VAR_TRUSTED_KEYS_FILE STRING_ARG
637         {
638                 OUTYY(("P(server_trusted_keys_file:%s)\n", $2));
639                 if(!cfg_strlist_insert(&cfg_parser->cfg->
640                         trusted_keys_file_list, $2))
641                         yyerror("out of memory");
642         }
643         ;
644 server_trust_anchor: VAR_TRUST_ANCHOR STRING_ARG
645         {
646                 OUTYY(("P(server_trust_anchor:%s)\n", $2));
647                 if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, $2))
648                         yyerror("out of memory");
649         }
650         ;
651 server_domain_insecure: VAR_DOMAIN_INSECURE STRING_ARG
652         {
653                 OUTYY(("P(server_domain_insecure:%s)\n", $2));
654                 if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, $2))
655                         yyerror("out of memory");
656         }
657         ;
658 server_hide_identity: VAR_HIDE_IDENTITY STRING_ARG
659         {
660                 OUTYY(("P(server_hide_identity:%s)\n", $2));
661                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
662                         yyerror("expected yes or no.");
663                 else cfg_parser->cfg->hide_identity = (strcmp($2, "yes")==0);
664                 free($2);
665         }
666         ;
667 server_hide_version: VAR_HIDE_VERSION STRING_ARG
668         {
669                 OUTYY(("P(server_hide_version:%s)\n", $2));
670                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
671                         yyerror("expected yes or no.");
672                 else cfg_parser->cfg->hide_version = (strcmp($2, "yes")==0);
673                 free($2);
674         }
675         ;
676 server_identity: VAR_IDENTITY STRING_ARG
677         {
678                 OUTYY(("P(server_identity:%s)\n", $2));
679                 free(cfg_parser->cfg->identity);
680                 cfg_parser->cfg->identity = $2;
681         }
682         ;
683 server_version: VAR_VERSION STRING_ARG
684         {
685                 OUTYY(("P(server_version:%s)\n", $2));
686                 free(cfg_parser->cfg->version);
687                 cfg_parser->cfg->version = $2;
688         }
689         ;
690 server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG
691         {
692                 OUTYY(("P(server_so_rcvbuf:%s)\n", $2));
693                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_rcvbuf))
694                         yyerror("buffer size expected");
695                 free($2);
696         }
697         ;
698 server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG
699         {
700                 OUTYY(("P(server_so_sndbuf:%s)\n", $2));
701                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_sndbuf))
702                         yyerror("buffer size expected");
703                 free($2);
704         }
705         ;
706 server_so_reuseport: VAR_SO_REUSEPORT STRING_ARG
707     {
708         OUTYY(("P(server_so_reuseport:%s)\n", $2));
709         if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
710             yyerror("expected yes or no.");
711         else cfg_parser->cfg->so_reuseport =
712             (strcmp($2, "yes")==0);
713         free($2);
714     }
715     ;
716 server_ip_transparent: VAR_IP_TRANSPARENT STRING_ARG
717     {
718         OUTYY(("P(server_ip_transparent:%s)\n", $2));
719         if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
720             yyerror("expected yes or no.");
721         else cfg_parser->cfg->ip_transparent =
722             (strcmp($2, "yes")==0);
723         free($2);
724     }
725     ;
726 server_ip_freebind: VAR_IP_FREEBIND STRING_ARG
727     {
728         OUTYY(("P(server_ip_freebind:%s)\n", $2));
729         if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
730             yyerror("expected yes or no.");
731         else cfg_parser->cfg->ip_freebind =
732             (strcmp($2, "yes")==0);
733         free($2);
734     }
735     ;
736 server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG
737         {
738                 OUTYY(("P(server_edns_buffer_size:%s)\n", $2));
739                 if(atoi($2) == 0)
740                         yyerror("number expected");
741                 else if (atoi($2) < 12)
742                         yyerror("edns buffer size too small");
743                 else if (atoi($2) > 65535)
744                         cfg_parser->cfg->edns_buffer_size = 65535;
745                 else cfg_parser->cfg->edns_buffer_size = atoi($2);
746                 free($2);
747         }
748         ;
749 server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG
750         {
751                 OUTYY(("P(server_msg_buffer_size:%s)\n", $2));
752                 if(atoi($2) == 0)
753                         yyerror("number expected");
754                 else if (atoi($2) < 4096)
755                         yyerror("message buffer size too small (use 4096)");
756                 else cfg_parser->cfg->msg_buffer_size = atoi($2);
757                 free($2);
758         }
759         ;
760 server_msg_cache_size: VAR_MSG_CACHE_SIZE STRING_ARG
761         {
762                 OUTYY(("P(server_msg_cache_size:%s)\n", $2));
763                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->msg_cache_size))
764                         yyerror("memory size expected");
765                 free($2);
766         }
767         ;
768 server_msg_cache_slabs: VAR_MSG_CACHE_SLABS STRING_ARG
769         {
770                 OUTYY(("P(server_msg_cache_slabs:%s)\n", $2));
771                 if(atoi($2) == 0)
772                         yyerror("number expected");
773                 else {
774                         cfg_parser->cfg->msg_cache_slabs = atoi($2);
775                         if(!is_pow2(cfg_parser->cfg->msg_cache_slabs))
776                                 yyerror("must be a power of 2");
777                 }
778                 free($2);
779         }
780         ;
781 server_num_queries_per_thread: VAR_NUM_QUERIES_PER_THREAD STRING_ARG
782         {
783                 OUTYY(("P(server_num_queries_per_thread:%s)\n", $2));
784                 if(atoi($2) == 0)
785                         yyerror("number expected");
786                 else cfg_parser->cfg->num_queries_per_thread = atoi($2);
787                 free($2);
788         }
789         ;
790 server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG
791         {
792                 OUTYY(("P(server_jostle_timeout:%s)\n", $2));
793                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
794                         yyerror("number expected");
795                 else cfg_parser->cfg->jostle_time = atoi($2);
796                 free($2);
797         }
798         ;
799 server_delay_close: VAR_DELAY_CLOSE STRING_ARG
800         {
801                 OUTYY(("P(server_delay_close:%s)\n", $2));
802                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
803                         yyerror("number expected");
804                 else cfg_parser->cfg->delay_close = atoi($2);
805                 free($2);
806         }
807         ;
808 server_unblock_lan_zones: VAR_UNBLOCK_LAN_ZONES STRING_ARG
809         {
810                 OUTYY(("P(server_unblock_lan_zones:%s)\n", $2));
811                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
812                         yyerror("expected yes or no.");
813                 else cfg_parser->cfg->unblock_lan_zones = 
814                         (strcmp($2, "yes")==0);
815                 free($2);
816         }
817         ;
818 server_insecure_lan_zones: VAR_INSECURE_LAN_ZONES STRING_ARG
819         {
820                 OUTYY(("P(server_insecure_lan_zones:%s)\n", $2));
821                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
822                         yyerror("expected yes or no.");
823                 else cfg_parser->cfg->insecure_lan_zones = 
824                         (strcmp($2, "yes")==0);
825                 free($2);
826         }
827         ;
828 server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG
829         {
830                 OUTYY(("P(server_rrset_cache_size:%s)\n", $2));
831                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->rrset_cache_size))
832                         yyerror("memory size expected");
833                 free($2);
834         }
835         ;
836 server_rrset_cache_slabs: VAR_RRSET_CACHE_SLABS STRING_ARG
837         {
838                 OUTYY(("P(server_rrset_cache_slabs:%s)\n", $2));
839                 if(atoi($2) == 0)
840                         yyerror("number expected");
841                 else {
842                         cfg_parser->cfg->rrset_cache_slabs = atoi($2);
843                         if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs))
844                                 yyerror("must be a power of 2");
845                 }
846                 free($2);
847         }
848         ;
849 server_infra_host_ttl: VAR_INFRA_HOST_TTL STRING_ARG
850         {
851                 OUTYY(("P(server_infra_host_ttl:%s)\n", $2));
852                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
853                         yyerror("number expected");
854                 else cfg_parser->cfg->host_ttl = atoi($2);
855                 free($2);
856         }
857         ;
858 server_infra_lame_ttl: VAR_INFRA_LAME_TTL STRING_ARG
859         {
860                 OUTYY(("P(server_infra_lame_ttl:%s)\n", $2));
861                 verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option "
862                         "removed, use infra-host-ttl)", $2);
863                 free($2);
864         }
865         ;
866 server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING_ARG
867         {
868                 OUTYY(("P(server_infra_cache_numhosts:%s)\n", $2));
869                 if(atoi($2) == 0)
870                         yyerror("number expected");
871                 else cfg_parser->cfg->infra_cache_numhosts = atoi($2);
872                 free($2);
873         }
874         ;
875 server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING_ARG
876         {
877                 OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2));
878                 verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s "
879                         "(option removed, use infra-cache-numhosts)", $2);
880                 free($2);
881         }
882         ;
883 server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG
884         {
885                 OUTYY(("P(server_infra_cache_slabs:%s)\n", $2));
886                 if(atoi($2) == 0)
887                         yyerror("number expected");
888                 else {
889                         cfg_parser->cfg->infra_cache_slabs = atoi($2);
890                         if(!is_pow2(cfg_parser->cfg->infra_cache_slabs))
891                                 yyerror("must be a power of 2");
892                 }
893                 free($2);
894         }
895         ;
896 server_infra_cache_min_rtt: VAR_INFRA_CACHE_MIN_RTT STRING_ARG
897         {
898                 OUTYY(("P(server_infra_cache_min_rtt:%s)\n", $2));
899                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
900                         yyerror("number expected");
901                 else cfg_parser->cfg->infra_cache_min_rtt = atoi($2);
902                 free($2);
903         }
904         ;
905 server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG
906         {
907                 OUTYY(("P(server_target_fetch_policy:%s)\n", $2));
908                 free(cfg_parser->cfg->target_fetch_policy);
909                 cfg_parser->cfg->target_fetch_policy = $2;
910         }
911         ;
912 server_harden_short_bufsize: VAR_HARDEN_SHORT_BUFSIZE STRING_ARG
913         {
914                 OUTYY(("P(server_harden_short_bufsize:%s)\n", $2));
915                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
916                         yyerror("expected yes or no.");
917                 else cfg_parser->cfg->harden_short_bufsize = 
918                         (strcmp($2, "yes")==0);
919                 free($2);
920         }
921         ;
922 server_harden_large_queries: VAR_HARDEN_LARGE_QUERIES STRING_ARG
923         {
924                 OUTYY(("P(server_harden_large_queries:%s)\n", $2));
925                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
926                         yyerror("expected yes or no.");
927                 else cfg_parser->cfg->harden_large_queries = 
928                         (strcmp($2, "yes")==0);
929                 free($2);
930         }
931         ;
932 server_harden_glue: VAR_HARDEN_GLUE STRING_ARG
933         {
934                 OUTYY(("P(server_harden_glue:%s)\n", $2));
935                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
936                         yyerror("expected yes or no.");
937                 else cfg_parser->cfg->harden_glue = 
938                         (strcmp($2, "yes")==0);
939                 free($2);
940         }
941         ;
942 server_harden_dnssec_stripped: VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG
943         {
944                 OUTYY(("P(server_harden_dnssec_stripped:%s)\n", $2));
945                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
946                         yyerror("expected yes or no.");
947                 else cfg_parser->cfg->harden_dnssec_stripped = 
948                         (strcmp($2, "yes")==0);
949                 free($2);
950         }
951         ;
952 server_harden_below_nxdomain: VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG
953         {
954                 OUTYY(("P(server_harden_below_nxdomain:%s)\n", $2));
955                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
956                         yyerror("expected yes or no.");
957                 else cfg_parser->cfg->harden_below_nxdomain = 
958                         (strcmp($2, "yes")==0);
959                 free($2);
960         }
961         ;
962 server_harden_referral_path: VAR_HARDEN_REFERRAL_PATH STRING_ARG
963         {
964                 OUTYY(("P(server_harden_referral_path:%s)\n", $2));
965                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
966                         yyerror("expected yes or no.");
967                 else cfg_parser->cfg->harden_referral_path = 
968                         (strcmp($2, "yes")==0);
969                 free($2);
970         }
971         ;
972 server_harden_algo_downgrade: VAR_HARDEN_ALGO_DOWNGRADE STRING_ARG
973         {
974                 OUTYY(("P(server_harden_algo_downgrade:%s)\n", $2));
975                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
976                         yyerror("expected yes or no.");
977                 else cfg_parser->cfg->harden_algo_downgrade = 
978                         (strcmp($2, "yes")==0);
979                 free($2);
980         }
981         ;
982 server_use_caps_for_id: VAR_USE_CAPS_FOR_ID STRING_ARG
983         {
984                 OUTYY(("P(server_use_caps_for_id:%s)\n", $2));
985                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
986                         yyerror("expected yes or no.");
987                 else cfg_parser->cfg->use_caps_bits_for_id = 
988                         (strcmp($2, "yes")==0);
989                 free($2);
990         }
991         ;
992 server_caps_whitelist: VAR_CAPS_WHITELIST STRING_ARG
993         {
994                 OUTYY(("P(server_caps_whitelist:%s)\n", $2));
995                 if(!cfg_strlist_insert(&cfg_parser->cfg->caps_whitelist, $2))
996                         yyerror("out of memory");
997         }
998         ;
999 server_private_address: VAR_PRIVATE_ADDRESS STRING_ARG
1000         {
1001                 OUTYY(("P(server_private_address:%s)\n", $2));
1002                 if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, $2))
1003                         yyerror("out of memory");
1004         }
1005         ;
1006 server_private_domain: VAR_PRIVATE_DOMAIN STRING_ARG
1007         {
1008                 OUTYY(("P(server_private_domain:%s)\n", $2));
1009                 if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, $2))
1010                         yyerror("out of memory");
1011         }
1012         ;
1013 server_prefetch: VAR_PREFETCH STRING_ARG
1014         {
1015                 OUTYY(("P(server_prefetch:%s)\n", $2));
1016                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1017                         yyerror("expected yes or no.");
1018                 else cfg_parser->cfg->prefetch = (strcmp($2, "yes")==0);
1019                 free($2);
1020         }
1021         ;
1022 server_prefetch_key: VAR_PREFETCH_KEY STRING_ARG
1023         {
1024                 OUTYY(("P(server_prefetch_key:%s)\n", $2));
1025                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1026                         yyerror("expected yes or no.");
1027                 else cfg_parser->cfg->prefetch_key = (strcmp($2, "yes")==0);
1028                 free($2);
1029         }
1030         ;
1031 server_unwanted_reply_threshold: VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG
1032         {
1033                 OUTYY(("P(server_unwanted_reply_threshold:%s)\n", $2));
1034                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1035                         yyerror("number expected");
1036                 else cfg_parser->cfg->unwanted_threshold = atoi($2);
1037                 free($2);
1038         }
1039         ;
1040 server_do_not_query_address: VAR_DO_NOT_QUERY_ADDRESS STRING_ARG
1041         {
1042                 OUTYY(("P(server_do_not_query_address:%s)\n", $2));
1043                 if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, $2))
1044                         yyerror("out of memory");
1045         }
1046         ;
1047 server_do_not_query_localhost: VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG
1048         {
1049                 OUTYY(("P(server_do_not_query_localhost:%s)\n", $2));
1050                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1051                         yyerror("expected yes or no.");
1052                 else cfg_parser->cfg->donotquery_localhost = 
1053                         (strcmp($2, "yes")==0);
1054                 free($2);
1055         }
1056         ;
1057 server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG
1058         {
1059                 OUTYY(("P(server_access_control:%s %s)\n", $2, $3));
1060                 if(strcmp($3, "deny")!=0 && strcmp($3, "refuse")!=0 &&
1061                         strcmp($3, "deny_non_local")!=0 &&
1062                         strcmp($3, "refuse_non_local")!=0 &&
1063                         strcmp($3, "allow")!=0 && 
1064                         strcmp($3, "allow_snoop")!=0) {
1065                         yyerror("expected deny, refuse, deny_non_local, "
1066                                 "refuse_non_local, allow or allow_snoop "
1067                                 "in access control action");
1068                 } else {
1069                         if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3))
1070                                 fatal_exit("out of memory adding acl");
1071                 }
1072         }
1073         ;
1074 server_module_conf: VAR_MODULE_CONF STRING_ARG
1075         {
1076                 OUTYY(("P(server_module_conf:%s)\n", $2));
1077                 free(cfg_parser->cfg->module_conf);
1078                 cfg_parser->cfg->module_conf = $2;
1079         }
1080         ;
1081 server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING_ARG
1082         {
1083                 OUTYY(("P(server_val_override_date:%s)\n", $2));
1084                 if(*$2 == '\0' || strcmp($2, "0") == 0) {
1085                         cfg_parser->cfg->val_date_override = 0;
1086                 } else if(strlen($2) == 14) {
1087                         cfg_parser->cfg->val_date_override = 
1088                                 cfg_convert_timeval($2);
1089                         if(!cfg_parser->cfg->val_date_override)
1090                                 yyerror("bad date/time specification");
1091                 } else {
1092                         if(atoi($2) == 0)
1093                                 yyerror("number expected");
1094                         cfg_parser->cfg->val_date_override = atoi($2);
1095                 }
1096                 free($2);
1097         }
1098         ;
1099 server_val_sig_skew_min: VAR_VAL_SIG_SKEW_MIN STRING_ARG
1100         {
1101                 OUTYY(("P(server_val_sig_skew_min:%s)\n", $2));
1102                 if(*$2 == '\0' || strcmp($2, "0") == 0) {
1103                         cfg_parser->cfg->val_sig_skew_min = 0;
1104                 } else {
1105                         cfg_parser->cfg->val_sig_skew_min = atoi($2);
1106                         if(!cfg_parser->cfg->val_sig_skew_min)
1107                                 yyerror("number expected");
1108                 }
1109                 free($2);
1110         }
1111         ;
1112 server_val_sig_skew_max: VAR_VAL_SIG_SKEW_MAX STRING_ARG
1113         {
1114                 OUTYY(("P(server_val_sig_skew_max:%s)\n", $2));
1115                 if(*$2 == '\0' || strcmp($2, "0") == 0) {
1116                         cfg_parser->cfg->val_sig_skew_max = 0;
1117                 } else {
1118                         cfg_parser->cfg->val_sig_skew_max = atoi($2);
1119                         if(!cfg_parser->cfg->val_sig_skew_max)
1120                                 yyerror("number expected");
1121                 }
1122                 free($2);
1123         }
1124         ;
1125 server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG
1126         {
1127                 OUTYY(("P(server_cache_max_ttl:%s)\n", $2));
1128                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1129                         yyerror("number expected");
1130                 else cfg_parser->cfg->max_ttl = atoi($2);
1131                 free($2);
1132         }
1133         ;
1134 server_cache_max_negative_ttl: VAR_CACHE_MAX_NEGATIVE_TTL STRING_ARG
1135         {
1136                 OUTYY(("P(server_cache_max_negative_ttl:%s)\n", $2));
1137                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1138                         yyerror("number expected");
1139                 else cfg_parser->cfg->max_negative_ttl = atoi($2);
1140                 free($2);
1141         }
1142         ;
1143 server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG
1144         {
1145                 OUTYY(("P(server_cache_min_ttl:%s)\n", $2));
1146                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1147                         yyerror("number expected");
1148                 else cfg_parser->cfg->min_ttl = atoi($2);
1149                 free($2);
1150         }
1151         ;
1152 server_bogus_ttl: VAR_BOGUS_TTL STRING_ARG
1153         {
1154                 OUTYY(("P(server_bogus_ttl:%s)\n", $2));
1155                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1156                         yyerror("number expected");
1157                 else cfg_parser->cfg->bogus_ttl = atoi($2);
1158                 free($2);
1159         }
1160         ;
1161 server_val_clean_additional: VAR_VAL_CLEAN_ADDITIONAL STRING_ARG
1162         {
1163                 OUTYY(("P(server_val_clean_additional:%s)\n", $2));
1164                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1165                         yyerror("expected yes or no.");
1166                 else cfg_parser->cfg->val_clean_additional = 
1167                         (strcmp($2, "yes")==0);
1168                 free($2);
1169         }
1170         ;
1171 server_val_permissive_mode: VAR_VAL_PERMISSIVE_MODE STRING_ARG
1172         {
1173                 OUTYY(("P(server_val_permissive_mode:%s)\n", $2));
1174                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1175                         yyerror("expected yes or no.");
1176                 else cfg_parser->cfg->val_permissive_mode = 
1177                         (strcmp($2, "yes")==0);
1178                 free($2);
1179         }
1180         ;
1181 server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG
1182         {
1183                 OUTYY(("P(server_ignore_cd_flag:%s)\n", $2));
1184                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1185                         yyerror("expected yes or no.");
1186                 else cfg_parser->cfg->ignore_cd = (strcmp($2, "yes")==0);
1187                 free($2);
1188         }
1189         ;
1190 server_serve_expired: VAR_SERVE_EXPIRED STRING_ARG
1191         {
1192                 OUTYY(("P(server_serve_expired:%s)\n", $2));
1193                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1194                         yyerror("expected yes or no.");
1195                 else cfg_parser->cfg->serve_expired = (strcmp($2, "yes")==0);
1196                 free($2);
1197         }
1198         ;
1199 server_fake_dsa: VAR_FAKE_DSA STRING_ARG
1200         {
1201                 OUTYY(("P(server_fake_dsa:%s)\n", $2));
1202                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1203                         yyerror("expected yes or no.");
1204                 else fake_dsa = (strcmp($2, "yes")==0);
1205                 if(fake_dsa)
1206                         log_warn("test option fake_dsa is enabled");
1207                 free($2);
1208         }
1209         ;
1210 server_val_log_level: VAR_VAL_LOG_LEVEL STRING_ARG
1211         {
1212                 OUTYY(("P(server_val_log_level:%s)\n", $2));
1213                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1214                         yyerror("number expected");
1215                 else cfg_parser->cfg->val_log_level = atoi($2);
1216                 free($2);
1217         }
1218         ;
1219 server_val_nsec3_keysize_iterations: VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG
1220         {
1221                 OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", $2));
1222                 free(cfg_parser->cfg->val_nsec3_key_iterations);
1223                 cfg_parser->cfg->val_nsec3_key_iterations = $2;
1224         }
1225         ;
1226 server_add_holddown: VAR_ADD_HOLDDOWN STRING_ARG
1227         {
1228                 OUTYY(("P(server_add_holddown:%s)\n", $2));
1229                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1230                         yyerror("number expected");
1231                 else cfg_parser->cfg->add_holddown = atoi($2);
1232                 free($2);
1233         }
1234         ;
1235 server_del_holddown: VAR_DEL_HOLDDOWN STRING_ARG
1236         {
1237                 OUTYY(("P(server_del_holddown:%s)\n", $2));
1238                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1239                         yyerror("number expected");
1240                 else cfg_parser->cfg->del_holddown = atoi($2);
1241                 free($2);
1242         }
1243         ;
1244 server_keep_missing: VAR_KEEP_MISSING STRING_ARG
1245         {
1246                 OUTYY(("P(server_keep_missing:%s)\n", $2));
1247                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1248                         yyerror("number expected");
1249                 else cfg_parser->cfg->keep_missing = atoi($2);
1250                 free($2);
1251         }
1252         ;
1253 server_permit_small_holddown: VAR_PERMIT_SMALL_HOLDDOWN STRING_ARG
1254         {
1255                 OUTYY(("P(server_permit_small_holddown:%s)\n", $2));
1256                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1257                         yyerror("expected yes or no.");
1258                 else cfg_parser->cfg->permit_small_holddown =
1259                         (strcmp($2, "yes")==0);
1260                 free($2);
1261         }
1262 server_key_cache_size: VAR_KEY_CACHE_SIZE STRING_ARG
1263         {
1264                 OUTYY(("P(server_key_cache_size:%s)\n", $2));
1265                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->key_cache_size))
1266                         yyerror("memory size expected");
1267                 free($2);
1268         }
1269         ;
1270 server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING_ARG
1271         {
1272                 OUTYY(("P(server_key_cache_slabs:%s)\n", $2));
1273                 if(atoi($2) == 0)
1274                         yyerror("number expected");
1275                 else {
1276                         cfg_parser->cfg->key_cache_slabs = atoi($2);
1277                         if(!is_pow2(cfg_parser->cfg->key_cache_slabs))
1278                                 yyerror("must be a power of 2");
1279                 }
1280                 free($2);
1281         }
1282         ;
1283 server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG
1284         {
1285                 OUTYY(("P(server_neg_cache_size:%s)\n", $2));
1286                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size))
1287                         yyerror("memory size expected");
1288                 free($2);
1289         }
1290         ;
1291 server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
1292         {
1293                 OUTYY(("P(server_local_zone:%s %s)\n", $2, $3));
1294                 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
1295                    strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
1296                    strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
1297                    && strcmp($3, "typetransparent")!=0
1298                    && strcmp($3, "always_transparent")!=0
1299                    && strcmp($3, "always_refuse")!=0
1300                    && strcmp($3, "always_nxdomain")!=0
1301                    && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0)
1302                         yyerror("local-zone type: expected static, deny, "
1303                                 "refuse, redirect, transparent, "
1304                                 "typetransparent, inform, inform_deny, "
1305                                 "always_transparent, always_refuse, "
1306                                 "always_nxdomain or nodefault");
1307                 else if(strcmp($3, "nodefault")==0) {
1308                         if(!cfg_strlist_insert(&cfg_parser->cfg->
1309                                 local_zones_nodefault, $2))
1310                                 fatal_exit("out of memory adding local-zone");
1311                         free($3);
1312                 } else {
1313                         if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones, 
1314                                 $2, $3))
1315                                 fatal_exit("out of memory adding local-zone");
1316                 }
1317         }
1318         ;
1319 server_local_data: VAR_LOCAL_DATA STRING_ARG
1320         {
1321                 OUTYY(("P(server_local_data:%s)\n", $2));
1322                 if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2))
1323                         fatal_exit("out of memory adding local-data");
1324         }
1325         ;
1326 server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
1327         {
1328                 char* ptr;
1329                 OUTYY(("P(server_local_data_ptr:%s)\n", $2));
1330                 ptr = cfg_ptr_reverse($2);
1331                 free($2);
1332                 if(ptr) {
1333                         if(!cfg_strlist_insert(&cfg_parser->cfg->
1334                                 local_data, ptr))
1335                                 fatal_exit("out of memory adding local-data");
1336                 } else {
1337                         yyerror("local-data-ptr could not be reversed");
1338                 }
1339         }
1340         ;
1341 server_minimal_responses: VAR_MINIMAL_RESPONSES STRING_ARG
1342         {
1343                 OUTYY(("P(server_minimal_responses:%s)\n", $2));
1344                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1345                         yyerror("expected yes or no.");
1346                 else cfg_parser->cfg->minimal_responses =
1347                         (strcmp($2, "yes")==0);
1348                 free($2);
1349         }
1350         ;
1351 server_rrset_roundrobin: VAR_RRSET_ROUNDROBIN STRING_ARG
1352         {
1353                 OUTYY(("P(server_rrset_roundrobin:%s)\n", $2));
1354                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1355                         yyerror("expected yes or no.");
1356                 else cfg_parser->cfg->rrset_roundrobin =
1357                         (strcmp($2, "yes")==0);
1358                 free($2);
1359         }
1360         ;
1361 server_max_udp_size: VAR_MAX_UDP_SIZE STRING_ARG
1362         {
1363                 OUTYY(("P(server_max_udp_size:%s)\n", $2));
1364                 cfg_parser->cfg->max_udp_size = atoi($2);
1365                 free($2);
1366         }
1367         ;
1368 server_dns64_prefix: VAR_DNS64_PREFIX STRING_ARG
1369         {
1370                 OUTYY(("P(dns64_prefix:%s)\n", $2));
1371                 free(cfg_parser->cfg->dns64_prefix);
1372                 cfg_parser->cfg->dns64_prefix = $2;
1373         }
1374         ;
1375 server_dns64_synthall: VAR_DNS64_SYNTHALL STRING_ARG
1376         {
1377                 OUTYY(("P(server_dns64_synthall:%s)\n", $2));
1378                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1379                         yyerror("expected yes or no.");
1380                 else cfg_parser->cfg->dns64_synthall = (strcmp($2, "yes")==0);
1381                 free($2);
1382         }
1383         ;
1384 server_define_tag: VAR_DEFINE_TAG STRING_ARG
1385         {
1386                 char* p, *s = $2;
1387                 OUTYY(("P(server_define_tag:%s)\n", $2));
1388                 while((p=strsep(&s, " \t\n")) != NULL) {
1389                         if(*p) {
1390                                 if(!config_add_tag(cfg_parser->cfg, p))
1391                                         yyerror("could not define-tag, "
1392                                                 "out of memory");
1393                         }
1394                 }
1395                 free($2);
1396         }
1397         ;
1398 server_local_zone_tag: VAR_LOCAL_ZONE_TAG STRING_ARG STRING_ARG
1399         {
1400                 size_t len = 0;
1401                 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3,
1402                         &len);
1403                 free($3);
1404                 OUTYY(("P(server_local_zone_tag:%s)\n", $2));
1405                 if(!bitlist)
1406                         yyerror("could not parse tags, (define-tag them first)");
1407                 if(bitlist) {
1408                         if(!cfg_strbytelist_insert(
1409                                 &cfg_parser->cfg->local_zone_tags,
1410                                 $2, bitlist, len)) {
1411                                 yyerror("out of memory");
1412                                 free($2);
1413                         }
1414                 }
1415         }
1416         ;
1417 server_access_control_tag: VAR_ACCESS_CONTROL_TAG STRING_ARG STRING_ARG
1418         {
1419                 size_t len = 0;
1420                 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3,
1421                         &len);
1422                 free($3);
1423                 OUTYY(("P(server_access_control_tag:%s)\n", $2));
1424                 if(!bitlist)
1425                         yyerror("could not parse tags, (define-tag them first)");
1426                 if(bitlist) {
1427                         if(!cfg_strbytelist_insert(
1428                                 &cfg_parser->cfg->acl_tags,
1429                                 $2, bitlist, len)) {
1430                                 yyerror("out of memory");
1431                                 free($2);
1432                         }
1433                 }
1434         }
1435         ;
1436 server_access_control_tag_action: VAR_ACCESS_CONTROL_TAG_ACTION STRING_ARG STRING_ARG STRING_ARG
1437         {
1438                 OUTYY(("P(server_access_control_tag_action:%s %s %s)\n", $2, $3, $4));
1439                 if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_actions,
1440                         $2, $3, $4)) {
1441                         yyerror("out of memory");
1442                         free($2);
1443                         free($3);
1444                         free($4);
1445                 }
1446         }
1447         ;
1448 server_access_control_tag_data: VAR_ACCESS_CONTROL_TAG_DATA STRING_ARG STRING_ARG STRING_ARG
1449         {
1450                 OUTYY(("P(server_access_control_tag_data:%s %s %s)\n", $2, $3, $4));
1451                 if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_datas,
1452                         $2, $3, $4)) {
1453                         yyerror("out of memory");
1454                         free($2);
1455                         free($3);
1456                         free($4);
1457                 }
1458         }
1459         ;
1460 server_local_zone_override: VAR_LOCAL_ZONE_OVERRIDE STRING_ARG STRING_ARG STRING_ARG
1461         {
1462                 OUTYY(("P(server_local_zone_override:%s %s %s)\n", $2, $3, $4));
1463                 if(!cfg_str3list_insert(&cfg_parser->cfg->local_zone_overrides,
1464                         $2, $3, $4)) {
1465                         yyerror("out of memory");
1466                         free($2);
1467                         free($3);
1468                         free($4);
1469                 }
1470         }
1471         ;
1472 server_access_control_view: VAR_ACCESS_CONTROL_VIEW STRING_ARG STRING_ARG
1473         {
1474                 OUTYY(("P(server_access_control_view:%s %s)\n", $2, $3));
1475                 if(!cfg_str2list_insert(&cfg_parser->cfg->acl_view,
1476                         $2, $3)) {
1477                         yyerror("out of memory");
1478                         free($2);
1479                         free($3);
1480                 }
1481         }
1482         ;
1483 server_ratelimit: VAR_RATELIMIT STRING_ARG 
1484         { 
1485                 OUTYY(("P(server_ratelimit:%s)\n", $2)); 
1486                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1487                         yyerror("number expected");
1488                 else cfg_parser->cfg->ratelimit = atoi($2);
1489                 free($2);
1490         }
1491         ;
1492 server_ratelimit_size: VAR_RATELIMIT_SIZE STRING_ARG
1493         {
1494                 OUTYY(("P(server_ratelimit_size:%s)\n", $2));
1495                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->ratelimit_size))
1496                         yyerror("memory size expected");
1497                 free($2);
1498         }
1499         ;
1500 server_ratelimit_slabs: VAR_RATELIMIT_SLABS STRING_ARG
1501         {
1502                 OUTYY(("P(server_ratelimit_slabs:%s)\n", $2));
1503                 if(atoi($2) == 0)
1504                         yyerror("number expected");
1505                 else {
1506                         cfg_parser->cfg->ratelimit_slabs = atoi($2);
1507                         if(!is_pow2(cfg_parser->cfg->ratelimit_slabs))
1508                                 yyerror("must be a power of 2");
1509                 }
1510                 free($2);
1511         }
1512         ;
1513 server_ratelimit_for_domain: VAR_RATELIMIT_FOR_DOMAIN STRING_ARG STRING_ARG
1514         {
1515                 OUTYY(("P(server_ratelimit_for_domain:%s %s)\n", $2, $3));
1516                 if(atoi($3) == 0 && strcmp($3, "0") != 0) {
1517                         yyerror("number expected");
1518                 } else {
1519                         if(!cfg_str2list_insert(&cfg_parser->cfg->
1520                                 ratelimit_for_domain, $2, $3))
1521                                 fatal_exit("out of memory adding "
1522                                         "ratelimit-for-domain");
1523                 }
1524         }
1525         ;
1526 server_ratelimit_below_domain: VAR_RATELIMIT_BELOW_DOMAIN STRING_ARG STRING_ARG
1527         {
1528                 OUTYY(("P(server_ratelimit_below_domain:%s %s)\n", $2, $3));
1529                 if(atoi($3) == 0 && strcmp($3, "0") != 0) {
1530                         yyerror("number expected");
1531                 } else {
1532                         if(!cfg_str2list_insert(&cfg_parser->cfg->
1533                                 ratelimit_below_domain, $2, $3))
1534                                 fatal_exit("out of memory adding "
1535                                         "ratelimit-below-domain");
1536                 }
1537         }
1538         ;
1539 server_ratelimit_factor: VAR_RATELIMIT_FACTOR STRING_ARG 
1540         { 
1541                 OUTYY(("P(server_ratelimit_factor:%s)\n", $2)); 
1542                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1543                         yyerror("number expected");
1544                 else cfg_parser->cfg->ratelimit_factor = atoi($2);
1545                 free($2);
1546         }
1547         ;
1548 server_qname_minimisation: VAR_QNAME_MINIMISATION STRING_ARG
1549         {
1550                 OUTYY(("P(server_qname_minimisation:%s)\n", $2));
1551                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1552                         yyerror("expected yes or no.");
1553                 else cfg_parser->cfg->qname_minimisation = 
1554                         (strcmp($2, "yes")==0);
1555                 free($2);
1556         }
1557         ;
1558 server_qname_minimisation_strict: VAR_QNAME_MINIMISATION_STRICT STRING_ARG
1559         {
1560                 OUTYY(("P(server_qname_minimisation_strict:%s)\n", $2));
1561                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1562                         yyerror("expected yes or no.");
1563                 else cfg_parser->cfg->qname_minimisation_strict = 
1564                         (strcmp($2, "yes")==0);
1565                 free($2);
1566         }
1567         ;
1568 stub_name: VAR_NAME STRING_ARG
1569         {
1570                 OUTYY(("P(name:%s)\n", $2));
1571                 if(cfg_parser->cfg->stubs->name)
1572                         yyerror("stub name override, there must be one name "
1573                                 "for one stub-zone");
1574                 free(cfg_parser->cfg->stubs->name);
1575                 cfg_parser->cfg->stubs->name = $2;
1576         }
1577         ;
1578 stub_host: VAR_STUB_HOST STRING_ARG
1579         {
1580                 OUTYY(("P(stub-host:%s)\n", $2));
1581                 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, $2))
1582                         yyerror("out of memory");
1583         }
1584         ;
1585 stub_addr: VAR_STUB_ADDR STRING_ARG
1586         {
1587                 OUTYY(("P(stub-addr:%s)\n", $2));
1588                 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, $2))
1589                         yyerror("out of memory");
1590         }
1591         ;
1592 stub_first: VAR_STUB_FIRST STRING_ARG
1593         {
1594                 OUTYY(("P(stub-first:%s)\n", $2));
1595                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1596                         yyerror("expected yes or no.");
1597                 else cfg_parser->cfg->stubs->isfirst=(strcmp($2, "yes")==0);
1598                 free($2);
1599         }
1600         ;
1601 stub_ssl_upstream: VAR_STUB_SSL_UPSTREAM STRING_ARG
1602         {
1603                 OUTYY(("P(stub-ssl-upstream:%s)\n", $2));
1604                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1605                         yyerror("expected yes or no.");
1606                 else cfg_parser->cfg->stubs->ssl_upstream = 
1607                         (strcmp($2, "yes")==0);
1608                 free($2);
1609         }
1610         ;
1611 stub_prime: VAR_STUB_PRIME STRING_ARG
1612         {
1613                 OUTYY(("P(stub-prime:%s)\n", $2));
1614                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1615                         yyerror("expected yes or no.");
1616                 else cfg_parser->cfg->stubs->isprime = 
1617                         (strcmp($2, "yes")==0);
1618                 free($2);
1619         }
1620         ;
1621 forward_name: VAR_NAME STRING_ARG
1622         {
1623                 OUTYY(("P(name:%s)\n", $2));
1624                 if(cfg_parser->cfg->forwards->name)
1625                         yyerror("forward name override, there must be one "
1626                                 "name for one forward-zone");
1627                 free(cfg_parser->cfg->forwards->name);
1628                 cfg_parser->cfg->forwards->name = $2;
1629         }
1630         ;
1631 forward_host: VAR_FORWARD_HOST STRING_ARG
1632         {
1633                 OUTYY(("P(forward-host:%s)\n", $2));
1634                 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, $2))
1635                         yyerror("out of memory");
1636         }
1637         ;
1638 forward_addr: VAR_FORWARD_ADDR STRING_ARG
1639         {
1640                 OUTYY(("P(forward-addr:%s)\n", $2));
1641                 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, $2))
1642                         yyerror("out of memory");
1643         }
1644         ;
1645 forward_first: VAR_FORWARD_FIRST STRING_ARG
1646         {
1647                 OUTYY(("P(forward-first:%s)\n", $2));
1648                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1649                         yyerror("expected yes or no.");
1650                 else cfg_parser->cfg->forwards->isfirst=(strcmp($2, "yes")==0);
1651                 free($2);
1652         }
1653         ;
1654 forward_ssl_upstream: VAR_FORWARD_SSL_UPSTREAM STRING_ARG
1655         {
1656                 OUTYY(("P(forward-ssl-upstream:%s)\n", $2));
1657                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1658                         yyerror("expected yes or no.");
1659                 else cfg_parser->cfg->forwards->ssl_upstream = 
1660                         (strcmp($2, "yes")==0);
1661                 free($2);
1662         }
1663         ;
1664 view_name: VAR_NAME STRING_ARG
1665         {
1666                 OUTYY(("P(name:%s)\n", $2));
1667                 if(cfg_parser->cfg->views->name)
1668                         yyerror("view name override, there must be one "
1669                                 "name for one view");
1670                 free(cfg_parser->cfg->views->name);
1671                 cfg_parser->cfg->views->name = $2;
1672         }
1673         ;
1674 view_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
1675         {
1676                 OUTYY(("P(view_local_zone:%s %s)\n", $2, $3));
1677                 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
1678                    strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
1679                    strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
1680                    && strcmp($3, "typetransparent")!=0
1681                    && strcmp($3, "always_transparent")!=0
1682                    && strcmp($3, "always_refuse")!=0
1683                    && strcmp($3, "always_nxdomain")!=0
1684                    && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0)
1685                         yyerror("local-zone type: expected static, deny, "
1686                                 "refuse, redirect, transparent, "
1687                                 "typetransparent, inform, inform_deny, "
1688                                 "always_transparent, always_refuse, "
1689                                 "always_nxdomain or nodefault");
1690                 else if(strcmp($3, "nodefault")==0) {
1691                         if(!cfg_strlist_insert(&cfg_parser->cfg->views->
1692                                 local_zones_nodefault, $2))
1693                                 fatal_exit("out of memory adding local-zone");
1694                         free($3);
1695                 } else {
1696                         if(!cfg_str2list_insert(
1697                                 &cfg_parser->cfg->views->local_zones, 
1698                                 $2, $3))
1699                                 fatal_exit("out of memory adding local-zone");
1700                 }
1701         }
1702         ;
1703 view_local_data: VAR_LOCAL_DATA STRING_ARG
1704         {
1705                 OUTYY(("P(view_local_data:%s)\n", $2));
1706                 if(!cfg_strlist_insert(&cfg_parser->cfg->views->local_data, $2)) {
1707                         fatal_exit("out of memory adding local-data");
1708                         free($2);
1709                 }
1710         }
1711         ;
1712 view_first: VAR_VIEW_FIRST STRING_ARG
1713         {
1714                 OUTYY(("P(view-first:%s)\n", $2));
1715                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1716                         yyerror("expected yes or no.");
1717                 else cfg_parser->cfg->views->isfirst=(strcmp($2, "yes")==0);
1718                 free($2);
1719         }
1720         ;
1721 rcstart: VAR_REMOTE_CONTROL
1722         { 
1723                 OUTYY(("\nP(remote-control:)\n")); 
1724         }
1725         ;
1726 contents_rc: contents_rc content_rc 
1727         | ;
1728 content_rc: rc_control_enable | rc_control_interface | rc_control_port |
1729         rc_server_key_file | rc_server_cert_file | rc_control_key_file |
1730         rc_control_cert_file | rc_control_use_cert
1731         ;
1732 rc_control_enable: VAR_CONTROL_ENABLE STRING_ARG
1733         {
1734                 OUTYY(("P(control_enable:%s)\n", $2));
1735                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1736                         yyerror("expected yes or no.");
1737                 else cfg_parser->cfg->remote_control_enable = 
1738                         (strcmp($2, "yes")==0);
1739                 free($2);
1740         }
1741         ;
1742 rc_control_port: VAR_CONTROL_PORT STRING_ARG
1743         {
1744                 OUTYY(("P(control_port:%s)\n", $2));
1745                 if(atoi($2) == 0)
1746                         yyerror("control port number expected");
1747                 else cfg_parser->cfg->control_port = atoi($2);
1748                 free($2);
1749         }
1750         ;
1751 rc_control_interface: VAR_CONTROL_INTERFACE STRING_ARG
1752         {
1753                 OUTYY(("P(control_interface:%s)\n", $2));
1754                 if(!cfg_strlist_insert(&cfg_parser->cfg->control_ifs, $2))
1755                         yyerror("out of memory");
1756         }
1757         ;
1758 rc_control_use_cert: VAR_CONTROL_USE_CERT STRING_ARG
1759         {
1760                 OUTYY(("P(control_use_cert:%s)\n", $2));
1761                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1762                         yyerror("expected yes or no.");
1763                 else cfg_parser->cfg->remote_control_use_cert =
1764                         (strcmp($2, "yes")==0);
1765                 free($2);
1766         }
1767         ;
1768 rc_server_key_file: VAR_SERVER_KEY_FILE STRING_ARG
1769         {
1770                 OUTYY(("P(rc_server_key_file:%s)\n", $2));
1771                 free(cfg_parser->cfg->server_key_file);
1772                 cfg_parser->cfg->server_key_file = $2;
1773         }
1774         ;
1775 rc_server_cert_file: VAR_SERVER_CERT_FILE STRING_ARG
1776         {
1777                 OUTYY(("P(rc_server_cert_file:%s)\n", $2));
1778                 free(cfg_parser->cfg->server_cert_file);
1779                 cfg_parser->cfg->server_cert_file = $2;
1780         }
1781         ;
1782 rc_control_key_file: VAR_CONTROL_KEY_FILE STRING_ARG
1783         {
1784                 OUTYY(("P(rc_control_key_file:%s)\n", $2));
1785                 free(cfg_parser->cfg->control_key_file);
1786                 cfg_parser->cfg->control_key_file = $2;
1787         }
1788         ;
1789 rc_control_cert_file: VAR_CONTROL_CERT_FILE STRING_ARG
1790         {
1791                 OUTYY(("P(rc_control_cert_file:%s)\n", $2));
1792                 free(cfg_parser->cfg->control_cert_file);
1793                 cfg_parser->cfg->control_cert_file = $2;
1794         }
1795         ;
1796 dtstart: VAR_DNSTAP
1797         {
1798                 OUTYY(("\nP(dnstap:)\n"));
1799         }
1800         ;
1801 contents_dt: contents_dt content_dt
1802         | ;
1803 content_dt: dt_dnstap_enable | dt_dnstap_socket_path |
1804         dt_dnstap_send_identity | dt_dnstap_send_version |
1805         dt_dnstap_identity | dt_dnstap_version |
1806         dt_dnstap_log_resolver_query_messages |
1807         dt_dnstap_log_resolver_response_messages |
1808         dt_dnstap_log_client_query_messages |
1809         dt_dnstap_log_client_response_messages |
1810         dt_dnstap_log_forwarder_query_messages |
1811         dt_dnstap_log_forwarder_response_messages
1812         ;
1813 dt_dnstap_enable: VAR_DNSTAP_ENABLE STRING_ARG
1814         {
1815                 OUTYY(("P(dt_dnstap_enable:%s)\n", $2));
1816                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1817                         yyerror("expected yes or no.");
1818                 else cfg_parser->cfg->dnstap = (strcmp($2, "yes")==0);
1819         }
1820         ;
1821 dt_dnstap_socket_path: VAR_DNSTAP_SOCKET_PATH STRING_ARG
1822         {
1823                 OUTYY(("P(dt_dnstap_socket_path:%s)\n", $2));
1824                 free(cfg_parser->cfg->dnstap_socket_path);
1825                 cfg_parser->cfg->dnstap_socket_path = $2;
1826         }
1827         ;
1828 dt_dnstap_send_identity: VAR_DNSTAP_SEND_IDENTITY STRING_ARG
1829         {
1830                 OUTYY(("P(dt_dnstap_send_identity:%s)\n", $2));
1831                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1832                         yyerror("expected yes or no.");
1833                 else cfg_parser->cfg->dnstap_send_identity = (strcmp($2, "yes")==0);
1834         }
1835         ;
1836 dt_dnstap_send_version: VAR_DNSTAP_SEND_VERSION STRING_ARG
1837         {
1838                 OUTYY(("P(dt_dnstap_send_version:%s)\n", $2));
1839                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1840                         yyerror("expected yes or no.");
1841                 else cfg_parser->cfg->dnstap_send_version = (strcmp($2, "yes")==0);
1842         }
1843         ;
1844 dt_dnstap_identity: VAR_DNSTAP_IDENTITY STRING_ARG
1845         {
1846                 OUTYY(("P(dt_dnstap_identity:%s)\n", $2));
1847                 free(cfg_parser->cfg->dnstap_identity);
1848                 cfg_parser->cfg->dnstap_identity = $2;
1849         }
1850         ;
1851 dt_dnstap_version: VAR_DNSTAP_VERSION STRING_ARG
1852         {
1853                 OUTYY(("P(dt_dnstap_version:%s)\n", $2));
1854                 free(cfg_parser->cfg->dnstap_version);
1855                 cfg_parser->cfg->dnstap_version = $2;
1856         }
1857         ;
1858 dt_dnstap_log_resolver_query_messages: VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES STRING_ARG
1859         {
1860                 OUTYY(("P(dt_dnstap_log_resolver_query_messages:%s)\n", $2));
1861                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1862                         yyerror("expected yes or no.");
1863                 else cfg_parser->cfg->dnstap_log_resolver_query_messages =
1864                         (strcmp($2, "yes")==0);
1865         }
1866         ;
1867 dt_dnstap_log_resolver_response_messages: VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES STRING_ARG
1868         {
1869                 OUTYY(("P(dt_dnstap_log_resolver_response_messages:%s)\n", $2));
1870                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1871                         yyerror("expected yes or no.");
1872                 else cfg_parser->cfg->dnstap_log_resolver_response_messages =
1873                         (strcmp($2, "yes")==0);
1874         }
1875         ;
1876 dt_dnstap_log_client_query_messages: VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES STRING_ARG
1877         {
1878                 OUTYY(("P(dt_dnstap_log_client_query_messages:%s)\n", $2));
1879                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1880                         yyerror("expected yes or no.");
1881                 else cfg_parser->cfg->dnstap_log_client_query_messages =
1882                         (strcmp($2, "yes")==0);
1883         }
1884         ;
1885 dt_dnstap_log_client_response_messages: VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES STRING_ARG
1886         {
1887                 OUTYY(("P(dt_dnstap_log_client_response_messages:%s)\n", $2));
1888                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1889                         yyerror("expected yes or no.");
1890                 else cfg_parser->cfg->dnstap_log_client_response_messages =
1891                         (strcmp($2, "yes")==0);
1892         }
1893         ;
1894 dt_dnstap_log_forwarder_query_messages: VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES STRING_ARG
1895         {
1896                 OUTYY(("P(dt_dnstap_log_forwarder_query_messages:%s)\n", $2));
1897                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1898                         yyerror("expected yes or no.");
1899                 else cfg_parser->cfg->dnstap_log_forwarder_query_messages =
1900                         (strcmp($2, "yes")==0);
1901         }
1902         ;
1903 dt_dnstap_log_forwarder_response_messages: VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES STRING_ARG
1904         {
1905                 OUTYY(("P(dt_dnstap_log_forwarder_response_messages:%s)\n", $2));
1906                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1907                         yyerror("expected yes or no.");
1908                 else cfg_parser->cfg->dnstap_log_forwarder_response_messages =
1909                         (strcmp($2, "yes")==0);
1910         }
1911         ;
1912 pythonstart: VAR_PYTHON
1913         { 
1914                 OUTYY(("\nP(python:)\n")); 
1915         }
1916         ;
1917 contents_py: contents_py content_py
1918         | ;
1919 content_py: py_script
1920         ;
1921 py_script: VAR_PYTHON_SCRIPT STRING_ARG
1922         {
1923                 OUTYY(("P(python-script:%s)\n", $2));
1924                 free(cfg_parser->cfg->python_script);
1925                 cfg_parser->cfg->python_script = $2;
1926         }
1927 server_disable_dnssec_lame_check: VAR_DISABLE_DNSSEC_LAME_CHECK STRING_ARG
1928         {
1929                 OUTYY(("P(disable_dnssec_lame_check:%s)\n", $2));
1930                 if (strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1931                         yyerror("expected yes or no.");
1932                 else cfg_parser->cfg->disable_dnssec_lame_check =
1933                         (strcmp($2, "yes")==0);
1934                 free($2);
1935         }
1936         ;
1937 server_log_identity: VAR_LOG_IDENTITY STRING_ARG
1938         {
1939                 OUTYY(("P(server_log_identity:%s)\n", $2));
1940                 free(cfg_parser->cfg->log_identity);
1941                 cfg_parser->cfg->log_identity = $2;
1942         }
1943         ;
1944 %%
1945
1946 /* parse helper routines could be here */