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