]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/unbound/util/configparser.y
Update libucl to git version 8d3b186
[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_DO_UDP VAR_DO_TCP 
73 %token VAR_CHROOT VAR_USERNAME VAR_DIRECTORY VAR_LOGFILE VAR_PIDFILE
74 %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD
75 %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP
76 %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS
77 %token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME
78 %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY
79 %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES
80 %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR
81 %token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION
82 %token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF
83 %token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE
84 %token VAR_BOGUS_TTL VAR_VAL_CLEAN_ADDITIONAL VAR_VAL_PERMISSIVE_MODE
85 %token VAR_INCOMING_NUM_TCP VAR_MSG_BUFFER_SIZE VAR_KEY_CACHE_SIZE
86 %token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE 
87 %token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG 
88 %token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST
89 %token VAR_CACHE_MAX_TTL VAR_HARDEN_DNSSEC_STRIPPED VAR_ACCESS_CONTROL
90 %token VAR_LOCAL_ZONE VAR_LOCAL_DATA VAR_INTERFACE_AUTOMATIC
91 %token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID
92 %token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT 
93 %token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR
94 %token VAR_NEG_CACHE_SIZE VAR_HARDEN_REFERRAL_PATH VAR_PRIVATE_ADDRESS
95 %token VAR_PRIVATE_DOMAIN VAR_REMOTE_CONTROL VAR_CONTROL_ENABLE
96 %token VAR_CONTROL_INTERFACE VAR_CONTROL_PORT VAR_SERVER_KEY_FILE
97 %token VAR_SERVER_CERT_FILE VAR_CONTROL_KEY_FILE VAR_CONTROL_CERT_FILE
98 %token VAR_CONTROL_USE_CERT
99 %token VAR_EXTENDED_STATISTICS VAR_LOCAL_DATA_PTR VAR_JOSTLE_TIMEOUT
100 %token VAR_STUB_PRIME VAR_UNWANTED_REPLY_THRESHOLD VAR_LOG_TIME_ASCII
101 %token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN
102 %token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL
103 %token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN 
104 %token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE VAR_PREFETCH
105 %token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_SO_REUSEPORT VAR_HARDEN_BELOW_NXDOMAIN
106 %token VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES VAR_TCP_UPSTREAM VAR_SSL_UPSTREAM
107 %token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST
108 %token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN
109 %token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE VAR_UNBLOCK_LAN_ZONES
110 %token VAR_DNS64_PREFIX VAR_DNS64_SYNTHALL
111 %token VAR_DNSTAP VAR_DNSTAP_ENABLE VAR_DNSTAP_SOCKET_PATH
112 %token VAR_DNSTAP_SEND_IDENTITY VAR_DNSTAP_SEND_VERSION
113 %token VAR_DNSTAP_IDENTITY VAR_DNSTAP_VERSION
114 %token VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES
115 %token VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES
116 %token VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES
117 %token VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES
118 %token VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES
119 %token VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES
120
121 %%
122 toplevelvars: /* empty */ | toplevelvars toplevelvar ;
123 toplevelvar: serverstart contents_server | stubstart contents_stub |
124         forwardstart contents_forward | pythonstart contents_py | 
125         rcstart contents_rc | dtstart contents_dt
126         ;
127
128 /* server: declaration */
129 serverstart: VAR_SERVER
130         { 
131                 OUTYY(("\nP(server:)\n")); 
132         }
133         ;
134 contents_server: contents_server content_server 
135         | ;
136 content_server: server_num_threads | server_verbosity | server_port |
137         server_outgoing_range | server_do_ip4 |
138         server_do_ip6 | server_do_udp | server_do_tcp | 
139         server_interface | server_chroot | server_username | 
140         server_directory | server_logfile | server_pidfile |
141         server_msg_cache_size | server_msg_cache_slabs |
142         server_num_queries_per_thread | server_rrset_cache_size | 
143         server_rrset_cache_slabs | server_outgoing_num_tcp | 
144         server_infra_host_ttl | server_infra_lame_ttl | 
145         server_infra_cache_slabs | server_infra_cache_numhosts |
146         server_infra_cache_lame_size | server_target_fetch_policy | 
147         server_harden_short_bufsize | server_harden_large_queries |
148         server_do_not_query_address | server_hide_identity |
149         server_hide_version | server_identity | server_version |
150         server_harden_glue | server_module_conf | server_trust_anchor_file |
151         server_trust_anchor | server_val_override_date | server_bogus_ttl |
152         server_val_clean_additional | server_val_permissive_mode |
153         server_incoming_num_tcp | server_msg_buffer_size | 
154         server_key_cache_size | server_key_cache_slabs | 
155         server_trusted_keys_file | server_val_nsec3_keysize_iterations |
156         server_use_syslog | server_outgoing_interface | server_root_hints |
157         server_do_not_query_localhost | server_cache_max_ttl |
158         server_harden_dnssec_stripped | server_access_control |
159         server_local_zone | server_local_data | server_interface_automatic |
160         server_statistics_interval | server_do_daemonize | 
161         server_use_caps_for_id | server_statistics_cumulative |
162         server_outgoing_port_permit | server_outgoing_port_avoid |
163         server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size |
164         server_harden_referral_path | server_private_address |
165         server_private_domain | server_extended_statistics | 
166         server_local_data_ptr | server_jostle_timeout | 
167         server_unwanted_reply_threshold | server_log_time_ascii | 
168         server_domain_insecure | server_val_sig_skew_min | 
169         server_val_sig_skew_max | server_cache_min_ttl | server_val_log_level |
170         server_auto_trust_anchor_file | server_add_holddown | 
171         server_del_holddown | server_keep_missing | server_so_rcvbuf |
172         server_edns_buffer_size | server_prefetch | server_prefetch_key |
173         server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag |
174         server_log_queries | server_tcp_upstream | server_ssl_upstream |
175         server_ssl_service_key | server_ssl_service_pem | server_ssl_port |
176         server_minimal_responses | server_rrset_roundrobin | server_max_udp_size |
177         server_so_reuseport | server_delay_close | server_unblock_lan_zones |
178         server_dns64_prefix | server_dns64_synthall
179         ;
180 stubstart: VAR_STUB_ZONE
181         {
182                 struct config_stub* s;
183                 OUTYY(("\nP(stub_zone:)\n")); 
184                 s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
185                 if(s) {
186                         s->next = cfg_parser->cfg->stubs;
187                         cfg_parser->cfg->stubs = s;
188                 } else 
189                         yyerror("out of memory");
190         }
191         ;
192 contents_stub: contents_stub content_stub 
193         | ;
194 content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first
195         ;
196 forwardstart: VAR_FORWARD_ZONE
197         {
198                 struct config_stub* s;
199                 OUTYY(("\nP(forward_zone:)\n")); 
200                 s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
201                 if(s) {
202                         s->next = cfg_parser->cfg->forwards;
203                         cfg_parser->cfg->forwards = s;
204                 } else 
205                         yyerror("out of memory");
206         }
207         ;
208 contents_forward: contents_forward content_forward 
209         | ;
210 content_forward: forward_name | forward_host | forward_addr | forward_first
211         ;
212 server_num_threads: VAR_NUM_THREADS STRING_ARG 
213         { 
214                 OUTYY(("P(server_num_threads:%s)\n", $2)); 
215                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
216                         yyerror("number expected");
217                 else cfg_parser->cfg->num_threads = atoi($2);
218                 free($2);
219         }
220         ;
221 server_verbosity: VAR_VERBOSITY STRING_ARG 
222         { 
223                 OUTYY(("P(server_verbosity:%s)\n", $2)); 
224                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
225                         yyerror("number expected");
226                 else cfg_parser->cfg->verbosity = atoi($2);
227                 free($2);
228         }
229         ;
230 server_statistics_interval: VAR_STATISTICS_INTERVAL STRING_ARG 
231         { 
232                 OUTYY(("P(server_statistics_interval:%s)\n", $2)); 
233                 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0)
234                         cfg_parser->cfg->stat_interval = 0;
235                 else if(atoi($2) == 0)
236                         yyerror("number expected");
237                 else cfg_parser->cfg->stat_interval = atoi($2);
238                 free($2);
239         }
240         ;
241 server_statistics_cumulative: VAR_STATISTICS_CUMULATIVE STRING_ARG
242         {
243                 OUTYY(("P(server_statistics_cumulative:%s)\n", $2));
244                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
245                         yyerror("expected yes or no.");
246                 else cfg_parser->cfg->stat_cumulative = (strcmp($2, "yes")==0);
247                 free($2);
248         }
249         ;
250 server_extended_statistics: VAR_EXTENDED_STATISTICS STRING_ARG
251         {
252                 OUTYY(("P(server_extended_statistics:%s)\n", $2));
253                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
254                         yyerror("expected yes or no.");
255                 else cfg_parser->cfg->stat_extended = (strcmp($2, "yes")==0);
256                 free($2);
257         }
258         ;
259 server_port: VAR_PORT STRING_ARG
260         {
261                 OUTYY(("P(server_port:%s)\n", $2));
262                 if(atoi($2) == 0)
263                         yyerror("port number expected");
264                 else cfg_parser->cfg->port = atoi($2);
265                 free($2);
266         }
267         ;
268 server_interface: VAR_INTERFACE STRING_ARG
269         {
270                 OUTYY(("P(server_interface:%s)\n", $2));
271                 if(cfg_parser->cfg->num_ifs == 0)
272                         cfg_parser->cfg->ifs = calloc(1, sizeof(char*));
273                 else    cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs,
274                                 (cfg_parser->cfg->num_ifs+1)*sizeof(char*));
275                 if(!cfg_parser->cfg->ifs)
276                         yyerror("out of memory");
277                 else
278                         cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = $2;
279         }
280         ;
281 server_outgoing_interface: VAR_OUTGOING_INTERFACE STRING_ARG
282         {
283                 OUTYY(("P(server_outgoing_interface:%s)\n", $2));
284                 if(cfg_parser->cfg->num_out_ifs == 0)
285                         cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*));
286                 else    cfg_parser->cfg->out_ifs = realloc(
287                         cfg_parser->cfg->out_ifs, 
288                         (cfg_parser->cfg->num_out_ifs+1)*sizeof(char*));
289                 if(!cfg_parser->cfg->out_ifs)
290                         yyerror("out of memory");
291                 else
292                         cfg_parser->cfg->out_ifs[
293                                 cfg_parser->cfg->num_out_ifs++] = $2;
294         }
295         ;
296 server_outgoing_range: VAR_OUTGOING_RANGE STRING_ARG
297         {
298                 OUTYY(("P(server_outgoing_range:%s)\n", $2));
299                 if(atoi($2) == 0)
300                         yyerror("number expected");
301                 else cfg_parser->cfg->outgoing_num_ports = atoi($2);
302                 free($2);
303         }
304         ;
305 server_outgoing_port_permit: VAR_OUTGOING_PORT_PERMIT STRING_ARG
306         {
307                 OUTYY(("P(server_outgoing_port_permit:%s)\n", $2));
308                 if(!cfg_mark_ports($2, 1, 
309                         cfg_parser->cfg->outgoing_avail_ports, 65536))
310                         yyerror("port number or range (\"low-high\") expected");
311                 free($2);
312         }
313         ;
314 server_outgoing_port_avoid: VAR_OUTGOING_PORT_AVOID STRING_ARG
315         {
316                 OUTYY(("P(server_outgoing_port_avoid:%s)\n", $2));
317                 if(!cfg_mark_ports($2, 0, 
318                         cfg_parser->cfg->outgoing_avail_ports, 65536))
319                         yyerror("port number or range (\"low-high\") expected");
320                 free($2);
321         }
322         ;
323 server_outgoing_num_tcp: VAR_OUTGOING_NUM_TCP STRING_ARG
324         {
325                 OUTYY(("P(server_outgoing_num_tcp:%s)\n", $2));
326                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
327                         yyerror("number expected");
328                 else cfg_parser->cfg->outgoing_num_tcp = atoi($2);
329                 free($2);
330         }
331         ;
332 server_incoming_num_tcp: VAR_INCOMING_NUM_TCP STRING_ARG
333         {
334                 OUTYY(("P(server_incoming_num_tcp:%s)\n", $2));
335                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
336                         yyerror("number expected");
337                 else cfg_parser->cfg->incoming_num_tcp = atoi($2);
338                 free($2);
339         }
340         ;
341 server_interface_automatic: VAR_INTERFACE_AUTOMATIC STRING_ARG
342         {
343                 OUTYY(("P(server_interface_automatic:%s)\n", $2));
344                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
345                         yyerror("expected yes or no.");
346                 else cfg_parser->cfg->if_automatic = (strcmp($2, "yes")==0);
347                 free($2);
348         }
349         ;
350 server_do_ip4: VAR_DO_IP4 STRING_ARG
351         {
352                 OUTYY(("P(server_do_ip4:%s)\n", $2));
353                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
354                         yyerror("expected yes or no.");
355                 else cfg_parser->cfg->do_ip4 = (strcmp($2, "yes")==0);
356                 free($2);
357         }
358         ;
359 server_do_ip6: VAR_DO_IP6 STRING_ARG
360         {
361                 OUTYY(("P(server_do_ip6:%s)\n", $2));
362                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
363                         yyerror("expected yes or no.");
364                 else cfg_parser->cfg->do_ip6 = (strcmp($2, "yes")==0);
365                 free($2);
366         }
367         ;
368 server_do_udp: VAR_DO_UDP STRING_ARG
369         {
370                 OUTYY(("P(server_do_udp:%s)\n", $2));
371                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
372                         yyerror("expected yes or no.");
373                 else cfg_parser->cfg->do_udp = (strcmp($2, "yes")==0);
374                 free($2);
375         }
376         ;
377 server_do_tcp: VAR_DO_TCP STRING_ARG
378         {
379                 OUTYY(("P(server_do_tcp:%s)\n", $2));
380                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
381                         yyerror("expected yes or no.");
382                 else cfg_parser->cfg->do_tcp = (strcmp($2, "yes")==0);
383                 free($2);
384         }
385         ;
386 server_tcp_upstream: VAR_TCP_UPSTREAM STRING_ARG
387         {
388                 OUTYY(("P(server_tcp_upstream:%s)\n", $2));
389                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
390                         yyerror("expected yes or no.");
391                 else cfg_parser->cfg->tcp_upstream = (strcmp($2, "yes")==0);
392                 free($2);
393         }
394         ;
395 server_ssl_upstream: VAR_SSL_UPSTREAM STRING_ARG
396         {
397                 OUTYY(("P(server_ssl_upstream:%s)\n", $2));
398                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
399                         yyerror("expected yes or no.");
400                 else cfg_parser->cfg->ssl_upstream = (strcmp($2, "yes")==0);
401                 free($2);
402         }
403         ;
404 server_ssl_service_key: VAR_SSL_SERVICE_KEY STRING_ARG
405         {
406                 OUTYY(("P(server_ssl_service_key:%s)\n", $2));
407                 free(cfg_parser->cfg->ssl_service_key);
408                 cfg_parser->cfg->ssl_service_key = $2;
409         }
410         ;
411 server_ssl_service_pem: VAR_SSL_SERVICE_PEM STRING_ARG
412         {
413                 OUTYY(("P(server_ssl_service_pem:%s)\n", $2));
414                 free(cfg_parser->cfg->ssl_service_pem);
415                 cfg_parser->cfg->ssl_service_pem = $2;
416         }
417         ;
418 server_ssl_port: VAR_SSL_PORT STRING_ARG
419         {
420                 OUTYY(("P(server_ssl_port:%s)\n", $2));
421                 if(atoi($2) == 0)
422                         yyerror("port number expected");
423                 else cfg_parser->cfg->ssl_port = atoi($2);
424                 free($2);
425         }
426         ;
427 server_do_daemonize: VAR_DO_DAEMONIZE STRING_ARG
428         {
429                 OUTYY(("P(server_do_daemonize:%s)\n", $2));
430                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
431                         yyerror("expected yes or no.");
432                 else cfg_parser->cfg->do_daemonize = (strcmp($2, "yes")==0);
433                 free($2);
434         }
435         ;
436 server_use_syslog: VAR_USE_SYSLOG STRING_ARG
437         {
438                 OUTYY(("P(server_use_syslog:%s)\n", $2));
439                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
440                         yyerror("expected yes or no.");
441                 else cfg_parser->cfg->use_syslog = (strcmp($2, "yes")==0);
442 #if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS)
443                 if(strcmp($2, "yes") == 0)
444                         yyerror("no syslog services are available. "
445                                 "(reconfigure and compile to add)");
446 #endif
447                 free($2);
448         }
449         ;
450 server_log_time_ascii: VAR_LOG_TIME_ASCII STRING_ARG
451         {
452                 OUTYY(("P(server_log_time_ascii:%s)\n", $2));
453                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
454                         yyerror("expected yes or no.");
455                 else cfg_parser->cfg->log_time_ascii = (strcmp($2, "yes")==0);
456                 free($2);
457         }
458         ;
459 server_log_queries: VAR_LOG_QUERIES STRING_ARG
460         {
461                 OUTYY(("P(server_log_queries:%s)\n", $2));
462                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
463                         yyerror("expected yes or no.");
464                 else cfg_parser->cfg->log_queries = (strcmp($2, "yes")==0);
465                 free($2);
466         }
467         ;
468 server_chroot: VAR_CHROOT STRING_ARG
469         {
470                 OUTYY(("P(server_chroot:%s)\n", $2));
471                 free(cfg_parser->cfg->chrootdir);
472                 cfg_parser->cfg->chrootdir = $2;
473         }
474         ;
475 server_username: VAR_USERNAME STRING_ARG
476         {
477                 OUTYY(("P(server_username:%s)\n", $2));
478                 free(cfg_parser->cfg->username);
479                 cfg_parser->cfg->username = $2;
480         }
481         ;
482 server_directory: VAR_DIRECTORY STRING_ARG
483         {
484                 OUTYY(("P(server_directory:%s)\n", $2));
485                 free(cfg_parser->cfg->directory);
486                 cfg_parser->cfg->directory = $2;
487         }
488         ;
489 server_logfile: VAR_LOGFILE STRING_ARG
490         {
491                 OUTYY(("P(server_logfile:%s)\n", $2));
492                 free(cfg_parser->cfg->logfile);
493                 cfg_parser->cfg->logfile = $2;
494                 cfg_parser->cfg->use_syslog = 0;
495         }
496         ;
497 server_pidfile: VAR_PIDFILE STRING_ARG
498         {
499                 OUTYY(("P(server_pidfile:%s)\n", $2));
500                 free(cfg_parser->cfg->pidfile);
501                 cfg_parser->cfg->pidfile = $2;
502         }
503         ;
504 server_root_hints: VAR_ROOT_HINTS STRING_ARG
505         {
506                 OUTYY(("P(server_root_hints:%s)\n", $2));
507                 if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, $2))
508                         yyerror("out of memory");
509         }
510         ;
511 server_dlv_anchor_file: VAR_DLV_ANCHOR_FILE STRING_ARG
512         {
513                 OUTYY(("P(server_dlv_anchor_file:%s)\n", $2));
514                 free(cfg_parser->cfg->dlv_anchor_file);
515                 cfg_parser->cfg->dlv_anchor_file = $2;
516         }
517         ;
518 server_dlv_anchor: VAR_DLV_ANCHOR STRING_ARG
519         {
520                 OUTYY(("P(server_dlv_anchor:%s)\n", $2));
521                 if(!cfg_strlist_insert(&cfg_parser->cfg->dlv_anchor_list, $2))
522                         yyerror("out of memory");
523         }
524         ;
525 server_auto_trust_anchor_file: VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG
526         {
527                 OUTYY(("P(server_auto_trust_anchor_file:%s)\n", $2));
528                 if(!cfg_strlist_insert(&cfg_parser->cfg->
529                         auto_trust_anchor_file_list, $2))
530                         yyerror("out of memory");
531         }
532         ;
533 server_trust_anchor_file: VAR_TRUST_ANCHOR_FILE STRING_ARG
534         {
535                 OUTYY(("P(server_trust_anchor_file:%s)\n", $2));
536                 if(!cfg_strlist_insert(&cfg_parser->cfg->
537                         trust_anchor_file_list, $2))
538                         yyerror("out of memory");
539         }
540         ;
541 server_trusted_keys_file: VAR_TRUSTED_KEYS_FILE STRING_ARG
542         {
543                 OUTYY(("P(server_trusted_keys_file:%s)\n", $2));
544                 if(!cfg_strlist_insert(&cfg_parser->cfg->
545                         trusted_keys_file_list, $2))
546                         yyerror("out of memory");
547         }
548         ;
549 server_trust_anchor: VAR_TRUST_ANCHOR STRING_ARG
550         {
551                 OUTYY(("P(server_trust_anchor:%s)\n", $2));
552                 if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, $2))
553                         yyerror("out of memory");
554         }
555         ;
556 server_domain_insecure: VAR_DOMAIN_INSECURE STRING_ARG
557         {
558                 OUTYY(("P(server_domain_insecure:%s)\n", $2));
559                 if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, $2))
560                         yyerror("out of memory");
561         }
562         ;
563 server_hide_identity: VAR_HIDE_IDENTITY STRING_ARG
564         {
565                 OUTYY(("P(server_hide_identity:%s)\n", $2));
566                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
567                         yyerror("expected yes or no.");
568                 else cfg_parser->cfg->hide_identity = (strcmp($2, "yes")==0);
569                 free($2);
570         }
571         ;
572 server_hide_version: VAR_HIDE_VERSION STRING_ARG
573         {
574                 OUTYY(("P(server_hide_version:%s)\n", $2));
575                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
576                         yyerror("expected yes or no.");
577                 else cfg_parser->cfg->hide_version = (strcmp($2, "yes")==0);
578                 free($2);
579         }
580         ;
581 server_identity: VAR_IDENTITY STRING_ARG
582         {
583                 OUTYY(("P(server_identity:%s)\n", $2));
584                 free(cfg_parser->cfg->identity);
585                 cfg_parser->cfg->identity = $2;
586         }
587         ;
588 server_version: VAR_VERSION STRING_ARG
589         {
590                 OUTYY(("P(server_version:%s)\n", $2));
591                 free(cfg_parser->cfg->version);
592                 cfg_parser->cfg->version = $2;
593         }
594         ;
595 server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG
596         {
597                 OUTYY(("P(server_so_rcvbuf:%s)\n", $2));
598                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_rcvbuf))
599                         yyerror("buffer size expected");
600                 free($2);
601         }
602         ;
603 server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG
604         {
605                 OUTYY(("P(server_so_sndbuf:%s)\n", $2));
606                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_sndbuf))
607                         yyerror("buffer size expected");
608                 free($2);
609         }
610         ;
611 server_so_reuseport: VAR_SO_REUSEPORT STRING_ARG
612     {
613         OUTYY(("P(server_so_reuseport:%s)\n", $2));
614         if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
615             yyerror("expected yes or no.");
616         else cfg_parser->cfg->so_reuseport =
617             (strcmp($2, "yes")==0);
618         free($2);
619     }
620     ;
621 server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG
622         {
623                 OUTYY(("P(server_edns_buffer_size:%s)\n", $2));
624                 if(atoi($2) == 0)
625                         yyerror("number expected");
626                 else if (atoi($2) < 12)
627                         yyerror("edns buffer size too small");
628                 else if (atoi($2) > 65535)
629                         cfg_parser->cfg->edns_buffer_size = 65535;
630                 else cfg_parser->cfg->edns_buffer_size = atoi($2);
631                 free($2);
632         }
633         ;
634 server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG
635         {
636                 OUTYY(("P(server_msg_buffer_size:%s)\n", $2));
637                 if(atoi($2) == 0)
638                         yyerror("number expected");
639                 else if (atoi($2) < 4096)
640                         yyerror("message buffer size too small (use 4096)");
641                 else cfg_parser->cfg->msg_buffer_size = atoi($2);
642                 free($2);
643         }
644         ;
645 server_msg_cache_size: VAR_MSG_CACHE_SIZE STRING_ARG
646         {
647                 OUTYY(("P(server_msg_cache_size:%s)\n", $2));
648                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->msg_cache_size))
649                         yyerror("memory size expected");
650                 free($2);
651         }
652         ;
653 server_msg_cache_slabs: VAR_MSG_CACHE_SLABS STRING_ARG
654         {
655                 OUTYY(("P(server_msg_cache_slabs:%s)\n", $2));
656                 if(atoi($2) == 0)
657                         yyerror("number expected");
658                 else {
659                         cfg_parser->cfg->msg_cache_slabs = atoi($2);
660                         if(!is_pow2(cfg_parser->cfg->msg_cache_slabs))
661                                 yyerror("must be a power of 2");
662                 }
663                 free($2);
664         }
665         ;
666 server_num_queries_per_thread: VAR_NUM_QUERIES_PER_THREAD STRING_ARG
667         {
668                 OUTYY(("P(server_num_queries_per_thread:%s)\n", $2));
669                 if(atoi($2) == 0)
670                         yyerror("number expected");
671                 else cfg_parser->cfg->num_queries_per_thread = atoi($2);
672                 free($2);
673         }
674         ;
675 server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG
676         {
677                 OUTYY(("P(server_jostle_timeout:%s)\n", $2));
678                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
679                         yyerror("number expected");
680                 else cfg_parser->cfg->jostle_time = atoi($2);
681                 free($2);
682         }
683         ;
684 server_delay_close: VAR_DELAY_CLOSE STRING_ARG
685         {
686                 OUTYY(("P(server_delay_close:%s)\n", $2));
687                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
688                         yyerror("number expected");
689                 else cfg_parser->cfg->delay_close = atoi($2);
690                 free($2);
691         }
692         ;
693 server_unblock_lan_zones: VAR_UNBLOCK_LAN_ZONES STRING_ARG
694         {
695                 OUTYY(("P(server_unblock_lan_zones:%s)\n", $2));
696                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
697                         yyerror("expected yes or no.");
698                 else cfg_parser->cfg->unblock_lan_zones = 
699                         (strcmp($2, "yes")==0);
700                 free($2);
701         }
702         ;
703 server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG
704         {
705                 OUTYY(("P(server_rrset_cache_size:%s)\n", $2));
706                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->rrset_cache_size))
707                         yyerror("memory size expected");
708                 free($2);
709         }
710         ;
711 server_rrset_cache_slabs: VAR_RRSET_CACHE_SLABS STRING_ARG
712         {
713                 OUTYY(("P(server_rrset_cache_slabs:%s)\n", $2));
714                 if(atoi($2) == 0)
715                         yyerror("number expected");
716                 else {
717                         cfg_parser->cfg->rrset_cache_slabs = atoi($2);
718                         if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs))
719                                 yyerror("must be a power of 2");
720                 }
721                 free($2);
722         }
723         ;
724 server_infra_host_ttl: VAR_INFRA_HOST_TTL STRING_ARG
725         {
726                 OUTYY(("P(server_infra_host_ttl:%s)\n", $2));
727                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
728                         yyerror("number expected");
729                 else cfg_parser->cfg->host_ttl = atoi($2);
730                 free($2);
731         }
732         ;
733 server_infra_lame_ttl: VAR_INFRA_LAME_TTL STRING_ARG
734         {
735                 OUTYY(("P(server_infra_lame_ttl:%s)\n", $2));
736                 verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option "
737                         "removed, use infra-host-ttl)", $2);
738                 free($2);
739         }
740         ;
741 server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING_ARG
742         {
743                 OUTYY(("P(server_infra_cache_numhosts:%s)\n", $2));
744                 if(atoi($2) == 0)
745                         yyerror("number expected");
746                 else cfg_parser->cfg->infra_cache_numhosts = atoi($2);
747                 free($2);
748         }
749         ;
750 server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING_ARG
751         {
752                 OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2));
753                 verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s "
754                         "(option removed, use infra-cache-numhosts)", $2);
755                 free($2);
756         }
757         ;
758 server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG
759         {
760                 OUTYY(("P(server_infra_cache_slabs:%s)\n", $2));
761                 if(atoi($2) == 0)
762                         yyerror("number expected");
763                 else {
764                         cfg_parser->cfg->infra_cache_slabs = atoi($2);
765                         if(!is_pow2(cfg_parser->cfg->infra_cache_slabs))
766                                 yyerror("must be a power of 2");
767                 }
768                 free($2);
769         }
770         ;
771 server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG
772         {
773                 OUTYY(("P(server_target_fetch_policy:%s)\n", $2));
774                 free(cfg_parser->cfg->target_fetch_policy);
775                 cfg_parser->cfg->target_fetch_policy = $2;
776         }
777         ;
778 server_harden_short_bufsize: VAR_HARDEN_SHORT_BUFSIZE STRING_ARG
779         {
780                 OUTYY(("P(server_harden_short_bufsize:%s)\n", $2));
781                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
782                         yyerror("expected yes or no.");
783                 else cfg_parser->cfg->harden_short_bufsize = 
784                         (strcmp($2, "yes")==0);
785                 free($2);
786         }
787         ;
788 server_harden_large_queries: VAR_HARDEN_LARGE_QUERIES STRING_ARG
789         {
790                 OUTYY(("P(server_harden_large_queries:%s)\n", $2));
791                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
792                         yyerror("expected yes or no.");
793                 else cfg_parser->cfg->harden_large_queries = 
794                         (strcmp($2, "yes")==0);
795                 free($2);
796         }
797         ;
798 server_harden_glue: VAR_HARDEN_GLUE STRING_ARG
799         {
800                 OUTYY(("P(server_harden_glue:%s)\n", $2));
801                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
802                         yyerror("expected yes or no.");
803                 else cfg_parser->cfg->harden_glue = 
804                         (strcmp($2, "yes")==0);
805                 free($2);
806         }
807         ;
808 server_harden_dnssec_stripped: VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG
809         {
810                 OUTYY(("P(server_harden_dnssec_stripped:%s)\n", $2));
811                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
812                         yyerror("expected yes or no.");
813                 else cfg_parser->cfg->harden_dnssec_stripped = 
814                         (strcmp($2, "yes")==0);
815                 free($2);
816         }
817         ;
818 server_harden_below_nxdomain: VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG
819         {
820                 OUTYY(("P(server_harden_below_nxdomain:%s)\n", $2));
821                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
822                         yyerror("expected yes or no.");
823                 else cfg_parser->cfg->harden_below_nxdomain = 
824                         (strcmp($2, "yes")==0);
825                 free($2);
826         }
827         ;
828 server_harden_referral_path: VAR_HARDEN_REFERRAL_PATH STRING_ARG
829         {
830                 OUTYY(("P(server_harden_referral_path:%s)\n", $2));
831                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
832                         yyerror("expected yes or no.");
833                 else cfg_parser->cfg->harden_referral_path = 
834                         (strcmp($2, "yes")==0);
835                 free($2);
836         }
837         ;
838 server_use_caps_for_id: VAR_USE_CAPS_FOR_ID STRING_ARG
839         {
840                 OUTYY(("P(server_use_caps_for_id:%s)\n", $2));
841                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
842                         yyerror("expected yes or no.");
843                 else cfg_parser->cfg->use_caps_bits_for_id = 
844                         (strcmp($2, "yes")==0);
845                 free($2);
846         }
847         ;
848 server_private_address: VAR_PRIVATE_ADDRESS STRING_ARG
849         {
850                 OUTYY(("P(server_private_address:%s)\n", $2));
851                 if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, $2))
852                         yyerror("out of memory");
853         }
854         ;
855 server_private_domain: VAR_PRIVATE_DOMAIN STRING_ARG
856         {
857                 OUTYY(("P(server_private_domain:%s)\n", $2));
858                 if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, $2))
859                         yyerror("out of memory");
860         }
861         ;
862 server_prefetch: VAR_PREFETCH STRING_ARG
863         {
864                 OUTYY(("P(server_prefetch:%s)\n", $2));
865                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
866                         yyerror("expected yes or no.");
867                 else cfg_parser->cfg->prefetch = (strcmp($2, "yes")==0);
868                 free($2);
869         }
870         ;
871 server_prefetch_key: VAR_PREFETCH_KEY STRING_ARG
872         {
873                 OUTYY(("P(server_prefetch_key:%s)\n", $2));
874                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
875                         yyerror("expected yes or no.");
876                 else cfg_parser->cfg->prefetch_key = (strcmp($2, "yes")==0);
877                 free($2);
878         }
879         ;
880 server_unwanted_reply_threshold: VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG
881         {
882                 OUTYY(("P(server_unwanted_reply_threshold:%s)\n", $2));
883                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
884                         yyerror("number expected");
885                 else cfg_parser->cfg->unwanted_threshold = atoi($2);
886                 free($2);
887         }
888         ;
889 server_do_not_query_address: VAR_DO_NOT_QUERY_ADDRESS STRING_ARG
890         {
891                 OUTYY(("P(server_do_not_query_address:%s)\n", $2));
892                 if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, $2))
893                         yyerror("out of memory");
894         }
895         ;
896 server_do_not_query_localhost: VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG
897         {
898                 OUTYY(("P(server_do_not_query_localhost:%s)\n", $2));
899                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
900                         yyerror("expected yes or no.");
901                 else cfg_parser->cfg->donotquery_localhost = 
902                         (strcmp($2, "yes")==0);
903                 free($2);
904         }
905         ;
906 server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG
907         {
908                 OUTYY(("P(server_access_control:%s %s)\n", $2, $3));
909                 if(strcmp($3, "deny")!=0 && strcmp($3, "refuse")!=0 &&
910                         strcmp($3, "deny_non_local")!=0 &&
911                         strcmp($3, "refuse_non_local")!=0 &&
912                         strcmp($3, "allow")!=0 && 
913                         strcmp($3, "allow_snoop")!=0) {
914                         yyerror("expected deny, refuse, deny_non_local, "
915                                 "refuse_non_local, allow or allow_snoop "
916                                 "in access control action");
917                 } else {
918                         if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3))
919                                 fatal_exit("out of memory adding acl");
920                 }
921         }
922         ;
923 server_module_conf: VAR_MODULE_CONF STRING_ARG
924         {
925                 OUTYY(("P(server_module_conf:%s)\n", $2));
926                 free(cfg_parser->cfg->module_conf);
927                 cfg_parser->cfg->module_conf = $2;
928         }
929         ;
930 server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING_ARG
931         {
932                 OUTYY(("P(server_val_override_date:%s)\n", $2));
933                 if(strlen($2) == 0 || strcmp($2, "0") == 0) {
934                         cfg_parser->cfg->val_date_override = 0;
935                 } else if(strlen($2) == 14) {
936                         cfg_parser->cfg->val_date_override = 
937                                 cfg_convert_timeval($2);
938                         if(!cfg_parser->cfg->val_date_override)
939                                 yyerror("bad date/time specification");
940                 } else {
941                         if(atoi($2) == 0)
942                                 yyerror("number expected");
943                         cfg_parser->cfg->val_date_override = atoi($2);
944                 }
945                 free($2);
946         }
947         ;
948 server_val_sig_skew_min: VAR_VAL_SIG_SKEW_MIN STRING_ARG
949         {
950                 OUTYY(("P(server_val_sig_skew_min:%s)\n", $2));
951                 if(strlen($2) == 0 || strcmp($2, "0") == 0) {
952                         cfg_parser->cfg->val_sig_skew_min = 0;
953                 } else {
954                         cfg_parser->cfg->val_sig_skew_min = atoi($2);
955                         if(!cfg_parser->cfg->val_sig_skew_min)
956                                 yyerror("number expected");
957                 }
958                 free($2);
959         }
960         ;
961 server_val_sig_skew_max: VAR_VAL_SIG_SKEW_MAX STRING_ARG
962         {
963                 OUTYY(("P(server_val_sig_skew_max:%s)\n", $2));
964                 if(strlen($2) == 0 || strcmp($2, "0") == 0) {
965                         cfg_parser->cfg->val_sig_skew_max = 0;
966                 } else {
967                         cfg_parser->cfg->val_sig_skew_max = atoi($2);
968                         if(!cfg_parser->cfg->val_sig_skew_max)
969                                 yyerror("number expected");
970                 }
971                 free($2);
972         }
973         ;
974 server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG
975         {
976                 OUTYY(("P(server_cache_max_ttl:%s)\n", $2));
977                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
978                         yyerror("number expected");
979                 else cfg_parser->cfg->max_ttl = atoi($2);
980                 free($2);
981         }
982         ;
983 server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG
984         {
985                 OUTYY(("P(server_cache_min_ttl:%s)\n", $2));
986                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
987                         yyerror("number expected");
988                 else cfg_parser->cfg->min_ttl = atoi($2);
989                 free($2);
990         }
991         ;
992 server_bogus_ttl: VAR_BOGUS_TTL STRING_ARG
993         {
994                 OUTYY(("P(server_bogus_ttl:%s)\n", $2));
995                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
996                         yyerror("number expected");
997                 else cfg_parser->cfg->bogus_ttl = atoi($2);
998                 free($2);
999         }
1000         ;
1001 server_val_clean_additional: VAR_VAL_CLEAN_ADDITIONAL STRING_ARG
1002         {
1003                 OUTYY(("P(server_val_clean_additional:%s)\n", $2));
1004                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1005                         yyerror("expected yes or no.");
1006                 else cfg_parser->cfg->val_clean_additional = 
1007                         (strcmp($2, "yes")==0);
1008                 free($2);
1009         }
1010         ;
1011 server_val_permissive_mode: VAR_VAL_PERMISSIVE_MODE STRING_ARG
1012         {
1013                 OUTYY(("P(server_val_permissive_mode:%s)\n", $2));
1014                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1015                         yyerror("expected yes or no.");
1016                 else cfg_parser->cfg->val_permissive_mode = 
1017                         (strcmp($2, "yes")==0);
1018                 free($2);
1019         }
1020         ;
1021 server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG
1022         {
1023                 OUTYY(("P(server_ignore_cd_flag:%s)\n", $2));
1024                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1025                         yyerror("expected yes or no.");
1026                 else cfg_parser->cfg->ignore_cd = (strcmp($2, "yes")==0);
1027                 free($2);
1028         }
1029         ;
1030 server_val_log_level: VAR_VAL_LOG_LEVEL STRING_ARG
1031         {
1032                 OUTYY(("P(server_val_log_level:%s)\n", $2));
1033                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1034                         yyerror("number expected");
1035                 else cfg_parser->cfg->val_log_level = atoi($2);
1036                 free($2);
1037         }
1038         ;
1039 server_val_nsec3_keysize_iterations: VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG
1040         {
1041                 OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", $2));
1042                 free(cfg_parser->cfg->val_nsec3_key_iterations);
1043                 cfg_parser->cfg->val_nsec3_key_iterations = $2;
1044         }
1045         ;
1046 server_add_holddown: VAR_ADD_HOLDDOWN STRING_ARG
1047         {
1048                 OUTYY(("P(server_add_holddown:%s)\n", $2));
1049                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1050                         yyerror("number expected");
1051                 else cfg_parser->cfg->add_holddown = atoi($2);
1052                 free($2);
1053         }
1054         ;
1055 server_del_holddown: VAR_DEL_HOLDDOWN STRING_ARG
1056         {
1057                 OUTYY(("P(server_del_holddown:%s)\n", $2));
1058                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1059                         yyerror("number expected");
1060                 else cfg_parser->cfg->del_holddown = atoi($2);
1061                 free($2);
1062         }
1063         ;
1064 server_keep_missing: VAR_KEEP_MISSING STRING_ARG
1065         {
1066                 OUTYY(("P(server_keep_missing:%s)\n", $2));
1067                 if(atoi($2) == 0 && strcmp($2, "0") != 0)
1068                         yyerror("number expected");
1069                 else cfg_parser->cfg->keep_missing = atoi($2);
1070                 free($2);
1071         }
1072         ;
1073 server_key_cache_size: VAR_KEY_CACHE_SIZE STRING_ARG
1074         {
1075                 OUTYY(("P(server_key_cache_size:%s)\n", $2));
1076                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->key_cache_size))
1077                         yyerror("memory size expected");
1078                 free($2);
1079         }
1080         ;
1081 server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING_ARG
1082         {
1083                 OUTYY(("P(server_key_cache_slabs:%s)\n", $2));
1084                 if(atoi($2) == 0)
1085                         yyerror("number expected");
1086                 else {
1087                         cfg_parser->cfg->key_cache_slabs = atoi($2);
1088                         if(!is_pow2(cfg_parser->cfg->key_cache_slabs))
1089                                 yyerror("must be a power of 2");
1090                 }
1091                 free($2);
1092         }
1093         ;
1094 server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG
1095         {
1096                 OUTYY(("P(server_neg_cache_size:%s)\n", $2));
1097                 if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size))
1098                         yyerror("memory size expected");
1099                 free($2);
1100         }
1101         ;
1102 server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
1103         {
1104                 OUTYY(("P(server_local_zone:%s %s)\n", $2, $3));
1105                 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
1106                    strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
1107                    strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
1108                    && strcmp($3, "typetransparent")!=0)
1109                         yyerror("local-zone type: expected static, deny, "
1110                                 "refuse, redirect, transparent, "
1111                                 "typetransparent or nodefault");
1112                 else if(strcmp($3, "nodefault")==0) {
1113                         if(!cfg_strlist_insert(&cfg_parser->cfg->
1114                                 local_zones_nodefault, $2))
1115                                 fatal_exit("out of memory adding local-zone");
1116                         free($3);
1117                 } else {
1118                         if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones, 
1119                                 $2, $3))
1120                                 fatal_exit("out of memory adding local-zone");
1121                 }
1122         }
1123         ;
1124 server_local_data: VAR_LOCAL_DATA STRING_ARG
1125         {
1126                 OUTYY(("P(server_local_data:%s)\n", $2));
1127                 if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2))
1128                         fatal_exit("out of memory adding local-data");
1129         }
1130         ;
1131 server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG
1132         {
1133                 char* ptr;
1134                 OUTYY(("P(server_local_data_ptr:%s)\n", $2));
1135                 ptr = cfg_ptr_reverse($2);
1136                 free($2);
1137                 if(ptr) {
1138                         if(!cfg_strlist_insert(&cfg_parser->cfg->
1139                                 local_data, ptr))
1140                                 fatal_exit("out of memory adding local-data");
1141                 } else {
1142                         yyerror("local-data-ptr could not be reversed");
1143                 }
1144         }
1145         ;
1146 server_minimal_responses: VAR_MINIMAL_RESPONSES STRING_ARG
1147         {
1148                 OUTYY(("P(server_minimal_responses:%s)\n", $2));
1149                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1150                         yyerror("expected yes or no.");
1151                 else cfg_parser->cfg->minimal_responses =
1152                         (strcmp($2, "yes")==0);
1153                 free($2);
1154         }
1155         ;
1156 server_rrset_roundrobin: VAR_RRSET_ROUNDROBIN STRING_ARG
1157         {
1158                 OUTYY(("P(server_rrset_roundrobin:%s)\n", $2));
1159                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1160                         yyerror("expected yes or no.");
1161                 else cfg_parser->cfg->rrset_roundrobin =
1162                         (strcmp($2, "yes")==0);
1163                 free($2);
1164         }
1165         ;
1166 server_max_udp_size: VAR_MAX_UDP_SIZE STRING_ARG
1167         {
1168                 OUTYY(("P(server_max_udp_size:%s)\n", $2));
1169                 cfg_parser->cfg->max_udp_size = atoi($2);
1170                 free($2);
1171         }
1172         ;
1173 server_dns64_prefix: VAR_DNS64_PREFIX STRING_ARG
1174         {
1175                 OUTYY(("P(dns64_prefix:%s)\n", $2));
1176                 free(cfg_parser->cfg->dns64_prefix);
1177                 cfg_parser->cfg->dns64_prefix = $2;
1178         }
1179         ;
1180 server_dns64_synthall: VAR_DNS64_SYNTHALL STRING_ARG
1181         {
1182                 OUTYY(("P(server_dns64_synthall:%s)\n", $2));
1183                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1184                         yyerror("expected yes or no.");
1185                 else cfg_parser->cfg->dns64_synthall = (strcmp($2, "yes")==0);
1186                 free($2);
1187         }
1188         ;
1189 stub_name: VAR_NAME STRING_ARG
1190         {
1191                 OUTYY(("P(name:%s)\n", $2));
1192                 if(cfg_parser->cfg->stubs->name)
1193                         yyerror("stub name override, there must be one name "
1194                                 "for one stub-zone");
1195                 free(cfg_parser->cfg->stubs->name);
1196                 cfg_parser->cfg->stubs->name = $2;
1197         }
1198         ;
1199 stub_host: VAR_STUB_HOST STRING_ARG
1200         {
1201                 OUTYY(("P(stub-host:%s)\n", $2));
1202                 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, $2))
1203                         yyerror("out of memory");
1204         }
1205         ;
1206 stub_addr: VAR_STUB_ADDR STRING_ARG
1207         {
1208                 OUTYY(("P(stub-addr:%s)\n", $2));
1209                 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, $2))
1210                         yyerror("out of memory");
1211         }
1212         ;
1213 stub_first: VAR_STUB_FIRST STRING_ARG
1214         {
1215                 OUTYY(("P(stub-first:%s)\n", $2));
1216                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1217                         yyerror("expected yes or no.");
1218                 else cfg_parser->cfg->stubs->isfirst=(strcmp($2, "yes")==0);
1219                 free($2);
1220         }
1221         ;
1222 stub_prime: VAR_STUB_PRIME STRING_ARG
1223         {
1224                 OUTYY(("P(stub-prime:%s)\n", $2));
1225                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1226                         yyerror("expected yes or no.");
1227                 else cfg_parser->cfg->stubs->isprime = 
1228                         (strcmp($2, "yes")==0);
1229                 free($2);
1230         }
1231         ;
1232 forward_name: VAR_NAME STRING_ARG
1233         {
1234                 OUTYY(("P(name:%s)\n", $2));
1235                 if(cfg_parser->cfg->forwards->name)
1236                         yyerror("forward name override, there must be one "
1237                                 "name for one forward-zone");
1238                 free(cfg_parser->cfg->forwards->name);
1239                 cfg_parser->cfg->forwards->name = $2;
1240         }
1241         ;
1242 forward_host: VAR_FORWARD_HOST STRING_ARG
1243         {
1244                 OUTYY(("P(forward-host:%s)\n", $2));
1245                 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, $2))
1246                         yyerror("out of memory");
1247         }
1248         ;
1249 forward_addr: VAR_FORWARD_ADDR STRING_ARG
1250         {
1251                 OUTYY(("P(forward-addr:%s)\n", $2));
1252                 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, $2))
1253                         yyerror("out of memory");
1254         }
1255         ;
1256 forward_first: VAR_FORWARD_FIRST STRING_ARG
1257         {
1258                 OUTYY(("P(forward-first:%s)\n", $2));
1259                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1260                         yyerror("expected yes or no.");
1261                 else cfg_parser->cfg->forwards->isfirst=(strcmp($2, "yes")==0);
1262                 free($2);
1263         }
1264         ;
1265 rcstart: VAR_REMOTE_CONTROL
1266         { 
1267                 OUTYY(("\nP(remote-control:)\n")); 
1268         }
1269         ;
1270 contents_rc: contents_rc content_rc 
1271         | ;
1272 content_rc: rc_control_enable | rc_control_interface | rc_control_port |
1273         rc_server_key_file | rc_server_cert_file | rc_control_key_file |
1274         rc_control_cert_file | rc_control_use_cert
1275         ;
1276 rc_control_enable: VAR_CONTROL_ENABLE STRING_ARG
1277         {
1278                 OUTYY(("P(control_enable:%s)\n", $2));
1279                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1280                         yyerror("expected yes or no.");
1281                 else cfg_parser->cfg->remote_control_enable = 
1282                         (strcmp($2, "yes")==0);
1283                 free($2);
1284         }
1285         ;
1286 rc_control_port: VAR_CONTROL_PORT STRING_ARG
1287         {
1288                 OUTYY(("P(control_port:%s)\n", $2));
1289                 if(atoi($2) == 0)
1290                         yyerror("control port number expected");
1291                 else cfg_parser->cfg->control_port = atoi($2);
1292                 free($2);
1293         }
1294         ;
1295 rc_control_interface: VAR_CONTROL_INTERFACE STRING_ARG
1296         {
1297                 OUTYY(("P(control_interface:%s)\n", $2));
1298                 if(!cfg_strlist_insert(&cfg_parser->cfg->control_ifs, $2))
1299                         yyerror("out of memory");
1300         }
1301         ;
1302 rc_control_use_cert: VAR_CONTROL_USE_CERT STRING_ARG
1303         {
1304                 OUTYY(("P(control_use_cert:%s)\n", $2));
1305                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1306                         yyerror("expected yes or no.");
1307                 else cfg_parser->cfg->remote_control_use_cert =
1308                         (strcmp($2, "yes")==0);
1309                 free($2);
1310         }
1311         ;
1312 rc_server_key_file: VAR_SERVER_KEY_FILE STRING_ARG
1313         {
1314                 OUTYY(("P(rc_server_key_file:%s)\n", $2));
1315                 free(cfg_parser->cfg->server_key_file);
1316                 cfg_parser->cfg->server_key_file = $2;
1317         }
1318         ;
1319 rc_server_cert_file: VAR_SERVER_CERT_FILE STRING_ARG
1320         {
1321                 OUTYY(("P(rc_server_cert_file:%s)\n", $2));
1322                 free(cfg_parser->cfg->server_cert_file);
1323                 cfg_parser->cfg->server_cert_file = $2;
1324         }
1325         ;
1326 rc_control_key_file: VAR_CONTROL_KEY_FILE STRING_ARG
1327         {
1328                 OUTYY(("P(rc_control_key_file:%s)\n", $2));
1329                 free(cfg_parser->cfg->control_key_file);
1330                 cfg_parser->cfg->control_key_file = $2;
1331         }
1332         ;
1333 rc_control_cert_file: VAR_CONTROL_CERT_FILE STRING_ARG
1334         {
1335                 OUTYY(("P(rc_control_cert_file:%s)\n", $2));
1336                 free(cfg_parser->cfg->control_cert_file);
1337                 cfg_parser->cfg->control_cert_file = $2;
1338         }
1339         ;
1340 dtstart: VAR_DNSTAP
1341         {
1342                 OUTYY(("\nP(dnstap:)\n"));
1343         }
1344         ;
1345 contents_dt: contents_dt content_dt
1346         | ;
1347 content_dt: dt_dnstap_enable | dt_dnstap_socket_path |
1348         dt_dnstap_send_identity | dt_dnstap_send_version |
1349         dt_dnstap_identity | dt_dnstap_version |
1350         dt_dnstap_log_resolver_query_messages |
1351         dt_dnstap_log_resolver_response_messages |
1352         dt_dnstap_log_client_query_messages |
1353         dt_dnstap_log_client_response_messages |
1354         dt_dnstap_log_forwarder_query_messages |
1355         dt_dnstap_log_forwarder_response_messages
1356         ;
1357 dt_dnstap_enable: VAR_DNSTAP_ENABLE STRING_ARG
1358         {
1359                 OUTYY(("P(dt_dnstap_enable:%s)\n", $2));
1360                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1361                         yyerror("expected yes or no.");
1362                 else cfg_parser->cfg->dnstap = (strcmp($2, "yes")==0);
1363         }
1364         ;
1365 dt_dnstap_socket_path: VAR_DNSTAP_SOCKET_PATH STRING_ARG
1366         {
1367                 OUTYY(("P(dt_dnstap_socket_path:%s)\n", $2));
1368                 free(cfg_parser->cfg->dnstap_socket_path);
1369                 cfg_parser->cfg->dnstap_socket_path = $2;
1370         }
1371         ;
1372 dt_dnstap_send_identity: VAR_DNSTAP_SEND_IDENTITY STRING_ARG
1373         {
1374                 OUTYY(("P(dt_dnstap_send_identity:%s)\n", $2));
1375                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1376                         yyerror("expected yes or no.");
1377                 else cfg_parser->cfg->dnstap_send_identity = (strcmp($2, "yes")==0);
1378         }
1379         ;
1380 dt_dnstap_send_version: VAR_DNSTAP_SEND_VERSION STRING_ARG
1381         {
1382                 OUTYY(("P(dt_dnstap_send_version:%s)\n", $2));
1383                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1384                         yyerror("expected yes or no.");
1385                 else cfg_parser->cfg->dnstap_send_version = (strcmp($2, "yes")==0);
1386         }
1387         ;
1388 dt_dnstap_identity: VAR_DNSTAP_IDENTITY STRING_ARG
1389         {
1390                 OUTYY(("P(dt_dnstap_identity:%s)\n", $2));
1391                 free(cfg_parser->cfg->dnstap_identity);
1392                 cfg_parser->cfg->dnstap_identity = $2;
1393         }
1394         ;
1395 dt_dnstap_version: VAR_DNSTAP_VERSION STRING_ARG
1396         {
1397                 OUTYY(("P(dt_dnstap_version:%s)\n", $2));
1398                 free(cfg_parser->cfg->dnstap_version);
1399                 cfg_parser->cfg->dnstap_version = $2;
1400         }
1401         ;
1402 dt_dnstap_log_resolver_query_messages: VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES STRING_ARG
1403         {
1404                 OUTYY(("P(dt_dnstap_log_resolver_query_messages:%s)\n", $2));
1405                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1406                         yyerror("expected yes or no.");
1407                 else cfg_parser->cfg->dnstap_log_resolver_query_messages =
1408                         (strcmp($2, "yes")==0);
1409         }
1410         ;
1411 dt_dnstap_log_resolver_response_messages: VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES STRING_ARG
1412         {
1413                 OUTYY(("P(dt_dnstap_log_resolver_response_messages:%s)\n", $2));
1414                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1415                         yyerror("expected yes or no.");
1416                 else cfg_parser->cfg->dnstap_log_resolver_response_messages =
1417                         (strcmp($2, "yes")==0);
1418         }
1419         ;
1420 dt_dnstap_log_client_query_messages: VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES STRING_ARG
1421         {
1422                 OUTYY(("P(dt_dnstap_log_client_query_messages:%s)\n", $2));
1423                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1424                         yyerror("expected yes or no.");
1425                 else cfg_parser->cfg->dnstap_log_client_query_messages =
1426                         (strcmp($2, "yes")==0);
1427         }
1428         ;
1429 dt_dnstap_log_client_response_messages: VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES STRING_ARG
1430         {
1431                 OUTYY(("P(dt_dnstap_log_client_response_messages:%s)\n", $2));
1432                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1433                         yyerror("expected yes or no.");
1434                 else cfg_parser->cfg->dnstap_log_client_response_messages =
1435                         (strcmp($2, "yes")==0);
1436         }
1437         ;
1438 dt_dnstap_log_forwarder_query_messages: VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES STRING_ARG
1439         {
1440                 OUTYY(("P(dt_dnstap_log_forwarder_query_messages:%s)\n", $2));
1441                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1442                         yyerror("expected yes or no.");
1443                 else cfg_parser->cfg->dnstap_log_forwarder_query_messages =
1444                         (strcmp($2, "yes")==0);
1445         }
1446         ;
1447 dt_dnstap_log_forwarder_response_messages: VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES STRING_ARG
1448         {
1449                 OUTYY(("P(dt_dnstap_log_forwarder_response_messages:%s)\n", $2));
1450                 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
1451                         yyerror("expected yes or no.");
1452                 else cfg_parser->cfg->dnstap_log_forwarder_response_messages =
1453                         (strcmp($2, "yes")==0);
1454         }
1455         ;
1456 pythonstart: VAR_PYTHON
1457         { 
1458                 OUTYY(("\nP(python:)\n")); 
1459         }
1460         ;
1461 contents_py: contents_py content_py
1462         | ;
1463 content_py: py_script
1464         ;
1465 py_script: VAR_PYTHON_SCRIPT STRING_ARG
1466         {
1467                 OUTYY(("P(python-script:%s)\n", $2));
1468                 free(cfg_parser->cfg->python_script);
1469                 cfg_parser->cfg->python_script = $2;
1470         }
1471 %%
1472
1473 /* parse helper routines could be here */