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 static void validate_respip_action(const char* action); 55 56 /* these need to be global, otherwise they cannot be used inside yacc */ 57 extern struct config_parser_state* cfg_parser; 58 59 #if 0 60 #define OUTYY(s) printf s /* used ONLY when debugging */ 61 #else 62 #define OUTYY(s) 63 #endif 64 65 %} 66 %union { 67 char* str; 68 }; 69 70 %token SPACE LETTER NEWLINE COMMENT COLON ANY ZONESTR 71 %token <str> STRING_ARG 72 %token VAR_SERVER VAR_VERBOSITY VAR_NUM_THREADS VAR_PORT 73 %token VAR_OUTGOING_RANGE VAR_INTERFACE 74 %token VAR_DO_IP4 VAR_DO_IP6 VAR_PREFER_IP6 VAR_DO_UDP VAR_DO_TCP 75 %token VAR_TCP_MSS VAR_OUTGOING_TCP_MSS VAR_TCP_IDLE_TIMEOUT 76 %token VAR_EDNS_TCP_KEEPALIVE VAR_EDNS_TCP_KEEPALIVE_TIMEOUT 77 %token VAR_CHROOT VAR_USERNAME VAR_DIRECTORY VAR_LOGFILE VAR_PIDFILE 78 %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD 79 %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP 80 %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS 81 %token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME 82 %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY 83 %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES 84 %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR 85 %token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION 86 %token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF 87 %token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE 88 %token VAR_BOGUS_TTL VAR_VAL_CLEAN_ADDITIONAL VAR_VAL_PERMISSIVE_MODE 89 %token VAR_INCOMING_NUM_TCP VAR_MSG_BUFFER_SIZE VAR_KEY_CACHE_SIZE 90 %token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE 91 %token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG 92 %token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST 93 %token VAR_CACHE_MAX_TTL VAR_HARDEN_DNSSEC_STRIPPED VAR_ACCESS_CONTROL 94 %token VAR_LOCAL_ZONE VAR_LOCAL_DATA VAR_INTERFACE_AUTOMATIC 95 %token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID 96 %token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT 97 %token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR 98 %token VAR_NEG_CACHE_SIZE VAR_HARDEN_REFERRAL_PATH VAR_PRIVATE_ADDRESS 99 %token VAR_PRIVATE_DOMAIN VAR_REMOTE_CONTROL VAR_CONTROL_ENABLE 100 %token VAR_CONTROL_INTERFACE VAR_CONTROL_PORT VAR_SERVER_KEY_FILE 101 %token VAR_SERVER_CERT_FILE VAR_CONTROL_KEY_FILE VAR_CONTROL_CERT_FILE 102 %token VAR_CONTROL_USE_CERT 103 %token VAR_EXTENDED_STATISTICS VAR_LOCAL_DATA_PTR VAR_JOSTLE_TIMEOUT 104 %token VAR_STUB_PRIME VAR_UNWANTED_REPLY_THRESHOLD VAR_LOG_TIME_ASCII 105 %token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN 106 %token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL 107 %token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN 108 %token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE VAR_PREFETCH 109 %token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_SO_REUSEPORT VAR_HARDEN_BELOW_NXDOMAIN 110 %token VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES VAR_LOG_REPLIES VAR_LOG_LOCAL_ACTIONS 111 %token VAR_TCP_UPSTREAM VAR_SSL_UPSTREAM 112 %token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST 113 %token VAR_STUB_SSL_UPSTREAM VAR_FORWARD_SSL_UPSTREAM VAR_TLS_CERT_BUNDLE 114 %token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN 115 %token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE 116 %token VAR_UNBLOCK_LAN_ZONES VAR_INSECURE_LAN_ZONES 117 %token VAR_INFRA_CACHE_MIN_RTT 118 %token VAR_DNS64_PREFIX VAR_DNS64_SYNTHALL VAR_DNS64_IGNORE_AAAA 119 %token VAR_DNSTAP VAR_DNSTAP_ENABLE VAR_DNSTAP_SOCKET_PATH 120 %token VAR_DNSTAP_SEND_IDENTITY VAR_DNSTAP_SEND_VERSION 121 %token VAR_DNSTAP_IDENTITY VAR_DNSTAP_VERSION 122 %token VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES 123 %token VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES 124 %token VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES 125 %token VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES 126 %token VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES 127 %token VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES 128 %token VAR_RESPONSE_IP_TAG VAR_RESPONSE_IP VAR_RESPONSE_IP_DATA 129 %token VAR_HARDEN_ALGO_DOWNGRADE VAR_IP_TRANSPARENT 130 %token VAR_DISABLE_DNSSEC_LAME_CHECK 131 %token VAR_IP_RATELIMIT VAR_IP_RATELIMIT_SLABS VAR_IP_RATELIMIT_SIZE 132 %token VAR_RATELIMIT VAR_RATELIMIT_SLABS VAR_RATELIMIT_SIZE 133 %token VAR_RATELIMIT_FOR_DOMAIN VAR_RATELIMIT_BELOW_DOMAIN 134 %token VAR_IP_RATELIMIT_FACTOR VAR_RATELIMIT_FACTOR 135 %token VAR_SEND_CLIENT_SUBNET VAR_CLIENT_SUBNET_ZONE 136 %token VAR_CLIENT_SUBNET_ALWAYS_FORWARD VAR_CLIENT_SUBNET_OPCODE 137 %token VAR_MAX_CLIENT_SUBNET_IPV4 VAR_MAX_CLIENT_SUBNET_IPV6 138 %token VAR_MIN_CLIENT_SUBNET_IPV4 VAR_MIN_CLIENT_SUBNET_IPV6 139 %token VAR_MAX_ECS_TREE_SIZE_IPV4 VAR_MAX_ECS_TREE_SIZE_IPV6 140 %token VAR_CAPS_WHITELIST VAR_CACHE_MAX_NEGATIVE_TTL VAR_PERMIT_SMALL_HOLDDOWN 141 %token VAR_QNAME_MINIMISATION VAR_QNAME_MINIMISATION_STRICT VAR_IP_FREEBIND 142 %token VAR_DEFINE_TAG VAR_LOCAL_ZONE_TAG VAR_ACCESS_CONTROL_TAG 143 %token VAR_LOCAL_ZONE_OVERRIDE VAR_ACCESS_CONTROL_TAG_ACTION 144 %token VAR_ACCESS_CONTROL_TAG_DATA VAR_VIEW VAR_ACCESS_CONTROL_VIEW 145 %token VAR_VIEW_FIRST VAR_SERVE_EXPIRED VAR_SERVE_EXPIRED_TTL 146 %token VAR_SERVE_EXPIRED_TTL_RESET VAR_FAKE_DSA VAR_FAKE_SHA1 147 %token VAR_LOG_IDENTITY VAR_HIDE_TRUSTANCHOR VAR_TRUST_ANCHOR_SIGNALING 148 %token VAR_AGGRESSIVE_NSEC VAR_USE_SYSTEMD VAR_SHM_ENABLE VAR_SHM_KEY 149 %token VAR_ROOT_KEY_SENTINEL 150 %token VAR_DNSCRYPT VAR_DNSCRYPT_ENABLE VAR_DNSCRYPT_PORT VAR_DNSCRYPT_PROVIDER 151 %token VAR_DNSCRYPT_SECRET_KEY VAR_DNSCRYPT_PROVIDER_CERT 152 %token VAR_DNSCRYPT_PROVIDER_CERT_ROTATED 153 %token VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE 154 %token VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS 155 %token VAR_DNSCRYPT_NONCE_CACHE_SIZE 156 %token VAR_DNSCRYPT_NONCE_CACHE_SLABS 157 %token VAR_IPSECMOD_ENABLED VAR_IPSECMOD_HOOK VAR_IPSECMOD_IGNORE_BOGUS 158 %token VAR_IPSECMOD_MAX_TTL VAR_IPSECMOD_WHITELIST VAR_IPSECMOD_STRICT 159 %token VAR_CACHEDB VAR_CACHEDB_BACKEND VAR_CACHEDB_SECRETSEED 160 %token VAR_CACHEDB_REDISHOST VAR_CACHEDB_REDISPORT VAR_CACHEDB_REDISTIMEOUT 161 %token VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM VAR_FOR_UPSTREAM 162 %token VAR_AUTH_ZONE VAR_ZONEFILE VAR_MASTER VAR_URL VAR_FOR_DOWNSTREAM 163 %token VAR_FALLBACK_ENABLED VAR_TLS_ADDITIONAL_PORT VAR_LOW_RTT VAR_LOW_RTT_PERMIL 164 %token VAR_FAST_SERVER_PERMIL VAR_FAST_SERVER_NUM 165 %token VAR_ALLOW_NOTIFY VAR_TLS_WIN_CERT VAR_TCP_CONNECTION_LIMIT 166 %token VAR_FORWARD_NO_CACHE VAR_STUB_NO_CACHE VAR_LOG_SERVFAIL VAR_DENY_ANY 167 %token VAR_UNKNOWN_SERVER_TIME_LIMIT VAR_LOG_TAG_QUERYREPLY 168 %token VAR_STREAM_WAIT_SIZE VAR_TLS_CIPHERS VAR_TLS_CIPHERSUITES 169 %token VAR_TLS_SESSION_TICKET_KEYS 170 171 %% 172 toplevelvars: /* empty */ | toplevelvars toplevelvar ; 173 toplevelvar: serverstart contents_server | stubstart contents_stub | 174 forwardstart contents_forward | pythonstart contents_py | 175 rcstart contents_rc | dtstart contents_dt | viewstart contents_view | 176 dnscstart contents_dnsc | cachedbstart contents_cachedb | 177 authstart contents_auth 178 ; 179 180 /* server: declaration */ 181 serverstart: VAR_SERVER 182 { 183 OUTYY(("\nP(server:)\n")); 184 } 185 ; 186 contents_server: contents_server content_server 187 | ; 188 content_server: server_num_threads | server_verbosity | server_port | 189 server_outgoing_range | server_do_ip4 | 190 server_do_ip6 | server_prefer_ip6 | 191 server_do_udp | server_do_tcp | 192 server_tcp_mss | server_outgoing_tcp_mss | server_tcp_idle_timeout | 193 server_tcp_keepalive | server_tcp_keepalive_timeout | 194 server_interface | server_chroot | server_username | 195 server_directory | server_logfile | server_pidfile | 196 server_msg_cache_size | server_msg_cache_slabs | 197 server_num_queries_per_thread | server_rrset_cache_size | 198 server_rrset_cache_slabs | server_outgoing_num_tcp | 199 server_infra_host_ttl | server_infra_lame_ttl | 200 server_infra_cache_slabs | server_infra_cache_numhosts | 201 server_infra_cache_lame_size | server_target_fetch_policy | 202 server_harden_short_bufsize | server_harden_large_queries | 203 server_do_not_query_address | server_hide_identity | 204 server_hide_version | server_identity | server_version | 205 server_harden_glue | server_module_conf | server_trust_anchor_file | 206 server_trust_anchor | server_val_override_date | server_bogus_ttl | 207 server_val_clean_additional | server_val_permissive_mode | 208 server_incoming_num_tcp | server_msg_buffer_size | 209 server_key_cache_size | server_key_cache_slabs | 210 server_trusted_keys_file | server_val_nsec3_keysize_iterations | 211 server_use_syslog | server_outgoing_interface | server_root_hints | 212 server_do_not_query_localhost | server_cache_max_ttl | 213 server_harden_dnssec_stripped | server_access_control | 214 server_local_zone | server_local_data | server_interface_automatic | 215 server_statistics_interval | server_do_daemonize | 216 server_use_caps_for_id | server_statistics_cumulative | 217 server_outgoing_port_permit | server_outgoing_port_avoid | 218 server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size | 219 server_harden_referral_path | server_private_address | 220 server_private_domain | server_extended_statistics | 221 server_local_data_ptr | server_jostle_timeout | 222 server_unwanted_reply_threshold | server_log_time_ascii | 223 server_domain_insecure | server_val_sig_skew_min | 224 server_val_sig_skew_max | server_cache_min_ttl | server_val_log_level | 225 server_auto_trust_anchor_file | server_add_holddown | 226 server_del_holddown | server_keep_missing | server_so_rcvbuf | 227 server_edns_buffer_size | server_prefetch | server_prefetch_key | 228 server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag | 229 server_log_queries | server_log_replies | server_tcp_upstream | server_ssl_upstream | 230 server_log_local_actions | 231 server_ssl_service_key | server_ssl_service_pem | server_ssl_port | 232 server_minimal_responses | server_rrset_roundrobin | server_max_udp_size | 233 server_so_reuseport | server_delay_close | 234 server_unblock_lan_zones | server_insecure_lan_zones | 235 server_dns64_prefix | server_dns64_synthall | server_dns64_ignore_aaaa | 236 server_infra_cache_min_rtt | server_harden_algo_downgrade | 237 server_ip_transparent | server_ip_ratelimit | server_ratelimit | 238 server_ip_ratelimit_slabs | server_ratelimit_slabs | 239 server_ip_ratelimit_size | server_ratelimit_size | 240 server_ratelimit_for_domain | 241 server_ratelimit_below_domain | server_ratelimit_factor | 242 server_ip_ratelimit_factor | server_send_client_subnet | 243 server_client_subnet_zone | server_client_subnet_always_forward | 244 server_client_subnet_opcode | 245 server_max_client_subnet_ipv4 | server_max_client_subnet_ipv6 | 246 server_min_client_subnet_ipv4 | server_min_client_subnet_ipv6 | 247 server_max_ecs_tree_size_ipv4 | server_max_ecs_tree_size_ipv6 | 248 server_caps_whitelist | server_cache_max_negative_ttl | 249 server_permit_small_holddown | server_qname_minimisation | 250 server_ip_freebind | server_define_tag | server_local_zone_tag | 251 server_disable_dnssec_lame_check | server_access_control_tag | 252 server_local_zone_override | server_access_control_tag_action | 253 server_access_control_tag_data | server_access_control_view | 254 server_qname_minimisation_strict | server_serve_expired | 255 server_serve_expired_ttl | server_serve_expired_ttl_reset | 256 server_fake_dsa | server_log_identity | server_use_systemd | 257 server_response_ip_tag | server_response_ip | server_response_ip_data | 258 server_shm_enable | server_shm_key | server_fake_sha1 | 259 server_hide_trustanchor | server_trust_anchor_signaling | 260 server_root_key_sentinel | 261 server_ipsecmod_enabled | server_ipsecmod_hook | 262 server_ipsecmod_ignore_bogus | server_ipsecmod_max_ttl | 263 server_ipsecmod_whitelist | server_ipsecmod_strict | 264 server_udp_upstream_without_downstream | server_aggressive_nsec | 265 server_tls_cert_bundle | server_tls_additional_port | server_low_rtt | 266 server_fast_server_permil | server_fast_server_num | server_tls_win_cert | 267 server_tcp_connection_limit | server_log_servfail | server_deny_any | 268 server_unknown_server_time_limit | server_log_tag_queryreply | 269 server_stream_wait_size | server_tls_ciphers | 270 server_tls_ciphersuites | server_tls_session_ticket_keys 271 ; 272 stubstart: VAR_STUB_ZONE 273 { 274 struct config_stub* s; 275 OUTYY(("\nP(stub_zone:)\n")); 276 s = (struct config_stub*)calloc(1, sizeof(struct config_stub)); 277 if(s) { 278 s->next = cfg_parser->cfg->stubs; 279 cfg_parser->cfg->stubs = s; 280 } else 281 yyerror("out of memory"); 282 } 283 ; 284 contents_stub: contents_stub content_stub 285 | ; 286 content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first | 287 stub_no_cache | stub_ssl_upstream 288 ; 289 forwardstart: VAR_FORWARD_ZONE 290 { 291 struct config_stub* s; 292 OUTYY(("\nP(forward_zone:)\n")); 293 s = (struct config_stub*)calloc(1, sizeof(struct config_stub)); 294 if(s) { 295 s->next = cfg_parser->cfg->forwards; 296 cfg_parser->cfg->forwards = s; 297 } else 298 yyerror("out of memory"); 299 } 300 ; 301 contents_forward: contents_forward content_forward 302 | ; 303 content_forward: forward_name | forward_host | forward_addr | forward_first | 304 forward_no_cache | forward_ssl_upstream 305 ; 306 viewstart: VAR_VIEW 307 { 308 struct config_view* s; 309 OUTYY(("\nP(view:)\n")); 310 s = (struct config_view*)calloc(1, sizeof(struct config_view)); 311 if(s) { 312 s->next = cfg_parser->cfg->views; 313 if(s->next && !s->next->name) 314 yyerror("view without name"); 315 cfg_parser->cfg->views = s; 316 } else 317 yyerror("out of memory"); 318 } 319 ; 320 contents_view: contents_view content_view 321 | ; 322 content_view: view_name | view_local_zone | view_local_data | view_first | 323 view_response_ip | view_response_ip_data | view_local_data_ptr 324 ; 325 authstart: VAR_AUTH_ZONE 326 { 327 struct config_auth* s; 328 OUTYY(("\nP(auth_zone:)\n")); 329 s = (struct config_auth*)calloc(1, sizeof(struct config_auth)); 330 if(s) { 331 s->next = cfg_parser->cfg->auths; 332 cfg_parser->cfg->auths = s; 333 /* defaults for auth zone */ 334 s->for_downstream = 1; 335 s->for_upstream = 1; 336 s->fallback_enabled = 0; 337 } else 338 yyerror("out of memory"); 339 } 340 ; 341 contents_auth: contents_auth content_auth 342 | ; 343 content_auth: auth_name | auth_zonefile | auth_master | auth_url | 344 auth_for_downstream | auth_for_upstream | auth_fallback_enabled | 345 auth_allow_notify 346 ; 347 server_num_threads: VAR_NUM_THREADS STRING_ARG 348 { 349 OUTYY(("P(server_num_threads:%s)\n", $2)); 350 if(atoi($2) == 0 && strcmp($2, "0") != 0) 351 yyerror("number expected"); 352 else cfg_parser->cfg->num_threads = atoi($2); 353 free($2); 354 } 355 ; 356 server_verbosity: VAR_VERBOSITY STRING_ARG 357 { 358 OUTYY(("P(server_verbosity:%s)\n", $2)); 359 if(atoi($2) == 0 && strcmp($2, "0") != 0) 360 yyerror("number expected"); 361 else cfg_parser->cfg->verbosity = atoi($2); 362 free($2); 363 } 364 ; 365 server_statistics_interval: VAR_STATISTICS_INTERVAL STRING_ARG 366 { 367 OUTYY(("P(server_statistics_interval:%s)\n", $2)); 368 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0) 369 cfg_parser->cfg->stat_interval = 0; 370 else if(atoi($2) == 0) 371 yyerror("number expected"); 372 else cfg_parser->cfg->stat_interval = atoi($2); 373 free($2); 374 } 375 ; 376 server_statistics_cumulative: VAR_STATISTICS_CUMULATIVE STRING_ARG 377 { 378 OUTYY(("P(server_statistics_cumulative:%s)\n", $2)); 379 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 380 yyerror("expected yes or no."); 381 else cfg_parser->cfg->stat_cumulative = (strcmp($2, "yes")==0); 382 free($2); 383 } 384 ; 385 server_extended_statistics: VAR_EXTENDED_STATISTICS STRING_ARG 386 { 387 OUTYY(("P(server_extended_statistics:%s)\n", $2)); 388 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 389 yyerror("expected yes or no."); 390 else cfg_parser->cfg->stat_extended = (strcmp($2, "yes")==0); 391 free($2); 392 } 393 ; 394 server_shm_enable: VAR_SHM_ENABLE STRING_ARG 395 { 396 OUTYY(("P(server_shm_enable:%s)\n", $2)); 397 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 398 yyerror("expected yes or no."); 399 else cfg_parser->cfg->shm_enable = (strcmp($2, "yes")==0); 400 free($2); 401 } 402 ; 403 server_shm_key: VAR_SHM_KEY STRING_ARG 404 { 405 OUTYY(("P(server_shm_key:%s)\n", $2)); 406 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0) 407 cfg_parser->cfg->shm_key = 0; 408 else if(atoi($2) == 0) 409 yyerror("number expected"); 410 else cfg_parser->cfg->shm_key = atoi($2); 411 free($2); 412 } 413 ; 414 server_port: VAR_PORT STRING_ARG 415 { 416 OUTYY(("P(server_port:%s)\n", $2)); 417 if(atoi($2) == 0) 418 yyerror("port number expected"); 419 else cfg_parser->cfg->port = atoi($2); 420 free($2); 421 } 422 ; 423 server_send_client_subnet: VAR_SEND_CLIENT_SUBNET STRING_ARG 424 { 425 #ifdef CLIENT_SUBNET 426 OUTYY(("P(server_send_client_subnet:%s)\n", $2)); 427 if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet, $2)) 428 fatal_exit("out of memory adding client-subnet"); 429 #else 430 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 431 #endif 432 } 433 ; 434 server_client_subnet_zone: VAR_CLIENT_SUBNET_ZONE STRING_ARG 435 { 436 #ifdef CLIENT_SUBNET 437 OUTYY(("P(server_client_subnet_zone:%s)\n", $2)); 438 if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet_zone, 439 $2)) 440 fatal_exit("out of memory adding client-subnet-zone"); 441 #else 442 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 443 #endif 444 } 445 ; 446 server_client_subnet_always_forward: 447 VAR_CLIENT_SUBNET_ALWAYS_FORWARD STRING_ARG 448 { 449 #ifdef CLIENT_SUBNET 450 OUTYY(("P(server_client_subnet_always_forward:%s)\n", $2)); 451 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 452 yyerror("expected yes or no."); 453 else 454 cfg_parser->cfg->client_subnet_always_forward = 455 (strcmp($2, "yes")==0); 456 #else 457 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 458 #endif 459 free($2); 460 } 461 ; 462 server_client_subnet_opcode: VAR_CLIENT_SUBNET_OPCODE STRING_ARG 463 { 464 #ifdef CLIENT_SUBNET 465 OUTYY(("P(client_subnet_opcode:%s)\n", $2)); 466 OUTYY(("P(Deprecated option, ignoring)\n")); 467 #else 468 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 469 #endif 470 free($2); 471 } 472 ; 473 server_max_client_subnet_ipv4: VAR_MAX_CLIENT_SUBNET_IPV4 STRING_ARG 474 { 475 #ifdef CLIENT_SUBNET 476 OUTYY(("P(max_client_subnet_ipv4:%s)\n", $2)); 477 if(atoi($2) == 0 && strcmp($2, "0") != 0) 478 yyerror("IPv4 subnet length expected"); 479 else if (atoi($2) > 32) 480 cfg_parser->cfg->max_client_subnet_ipv4 = 32; 481 else if (atoi($2) < 0) 482 cfg_parser->cfg->max_client_subnet_ipv4 = 0; 483 else cfg_parser->cfg->max_client_subnet_ipv4 = (uint8_t)atoi($2); 484 #else 485 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 486 #endif 487 free($2); 488 } 489 ; 490 server_max_client_subnet_ipv6: VAR_MAX_CLIENT_SUBNET_IPV6 STRING_ARG 491 { 492 #ifdef CLIENT_SUBNET 493 OUTYY(("P(max_client_subnet_ipv6:%s)\n", $2)); 494 if(atoi($2) == 0 && strcmp($2, "0") != 0) 495 yyerror("Ipv6 subnet length expected"); 496 else if (atoi($2) > 128) 497 cfg_parser->cfg->max_client_subnet_ipv6 = 128; 498 else if (atoi($2) < 0) 499 cfg_parser->cfg->max_client_subnet_ipv6 = 0; 500 else cfg_parser->cfg->max_client_subnet_ipv6 = (uint8_t)atoi($2); 501 #else 502 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 503 #endif 504 free($2); 505 } 506 ; 507 server_min_client_subnet_ipv4: VAR_MIN_CLIENT_SUBNET_IPV4 STRING_ARG 508 { 509 #ifdef CLIENT_SUBNET 510 OUTYY(("P(min_client_subnet_ipv4:%s)\n", $2)); 511 if(atoi($2) == 0 && strcmp($2, "0") != 0) 512 yyerror("IPv4 subnet length expected"); 513 else if (atoi($2) > 32) 514 cfg_parser->cfg->min_client_subnet_ipv4 = 32; 515 else if (atoi($2) < 0) 516 cfg_parser->cfg->min_client_subnet_ipv4 = 0; 517 else cfg_parser->cfg->min_client_subnet_ipv4 = (uint8_t)atoi($2); 518 #else 519 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 520 #endif 521 free($2); 522 } 523 ; 524 server_min_client_subnet_ipv6: VAR_MIN_CLIENT_SUBNET_IPV6 STRING_ARG 525 { 526 #ifdef CLIENT_SUBNET 527 OUTYY(("P(min_client_subnet_ipv6:%s)\n", $2)); 528 if(atoi($2) == 0 && strcmp($2, "0") != 0) 529 yyerror("Ipv6 subnet length expected"); 530 else if (atoi($2) > 128) 531 cfg_parser->cfg->min_client_subnet_ipv6 = 128; 532 else if (atoi($2) < 0) 533 cfg_parser->cfg->min_client_subnet_ipv6 = 0; 534 else cfg_parser->cfg->min_client_subnet_ipv6 = (uint8_t)atoi($2); 535 #else 536 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 537 #endif 538 free($2); 539 } 540 ; 541 server_max_ecs_tree_size_ipv4: VAR_MAX_ECS_TREE_SIZE_IPV4 STRING_ARG 542 { 543 #ifdef CLIENT_SUBNET 544 OUTYY(("P(max_ecs_tree_size_ipv4:%s)\n", $2)); 545 if(atoi($2) == 0 && strcmp($2, "0") != 0) 546 yyerror("IPv4 ECS tree size expected"); 547 else if (atoi($2) < 0) 548 cfg_parser->cfg->max_ecs_tree_size_ipv4 = 0; 549 else cfg_parser->cfg->max_ecs_tree_size_ipv4 = (uint32_t)atoi($2); 550 #else 551 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 552 #endif 553 free($2); 554 } 555 ; 556 server_max_ecs_tree_size_ipv6: VAR_MAX_ECS_TREE_SIZE_IPV6 STRING_ARG 557 { 558 #ifdef CLIENT_SUBNET 559 OUTYY(("P(max_ecs_tree_size_ipv6:%s)\n", $2)); 560 if(atoi($2) == 0 && strcmp($2, "0") != 0) 561 yyerror("IPv6 ECS tree size expected"); 562 else if (atoi($2) < 0) 563 cfg_parser->cfg->max_ecs_tree_size_ipv6 = 0; 564 else cfg_parser->cfg->max_ecs_tree_size_ipv6 = (uint32_t)atoi($2); 565 #else 566 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 567 #endif 568 free($2); 569 } 570 ; 571 server_interface: VAR_INTERFACE STRING_ARG 572 { 573 OUTYY(("P(server_interface:%s)\n", $2)); 574 if(cfg_parser->cfg->num_ifs == 0) 575 cfg_parser->cfg->ifs = calloc(1, sizeof(char*)); 576 else cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs, 577 (cfg_parser->cfg->num_ifs+1)*sizeof(char*)); 578 if(!cfg_parser->cfg->ifs) 579 yyerror("out of memory"); 580 else 581 cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = $2; 582 } 583 ; 584 server_outgoing_interface: VAR_OUTGOING_INTERFACE STRING_ARG 585 { 586 OUTYY(("P(server_outgoing_interface:%s)\n", $2)); 587 if(cfg_parser->cfg->num_out_ifs == 0) 588 cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*)); 589 else cfg_parser->cfg->out_ifs = realloc( 590 cfg_parser->cfg->out_ifs, 591 (cfg_parser->cfg->num_out_ifs+1)*sizeof(char*)); 592 if(!cfg_parser->cfg->out_ifs) 593 yyerror("out of memory"); 594 else 595 cfg_parser->cfg->out_ifs[ 596 cfg_parser->cfg->num_out_ifs++] = $2; 597 } 598 ; 599 server_outgoing_range: VAR_OUTGOING_RANGE STRING_ARG 600 { 601 OUTYY(("P(server_outgoing_range:%s)\n", $2)); 602 if(atoi($2) == 0) 603 yyerror("number expected"); 604 else cfg_parser->cfg->outgoing_num_ports = atoi($2); 605 free($2); 606 } 607 ; 608 server_outgoing_port_permit: VAR_OUTGOING_PORT_PERMIT STRING_ARG 609 { 610 OUTYY(("P(server_outgoing_port_permit:%s)\n", $2)); 611 if(!cfg_mark_ports($2, 1, 612 cfg_parser->cfg->outgoing_avail_ports, 65536)) 613 yyerror("port number or range (\"low-high\") expected"); 614 free($2); 615 } 616 ; 617 server_outgoing_port_avoid: VAR_OUTGOING_PORT_AVOID STRING_ARG 618 { 619 OUTYY(("P(server_outgoing_port_avoid:%s)\n", $2)); 620 if(!cfg_mark_ports($2, 0, 621 cfg_parser->cfg->outgoing_avail_ports, 65536)) 622 yyerror("port number or range (\"low-high\") expected"); 623 free($2); 624 } 625 ; 626 server_outgoing_num_tcp: VAR_OUTGOING_NUM_TCP STRING_ARG 627 { 628 OUTYY(("P(server_outgoing_num_tcp:%s)\n", $2)); 629 if(atoi($2) == 0 && strcmp($2, "0") != 0) 630 yyerror("number expected"); 631 else cfg_parser->cfg->outgoing_num_tcp = atoi($2); 632 free($2); 633 } 634 ; 635 server_incoming_num_tcp: VAR_INCOMING_NUM_TCP STRING_ARG 636 { 637 OUTYY(("P(server_incoming_num_tcp:%s)\n", $2)); 638 if(atoi($2) == 0 && strcmp($2, "0") != 0) 639 yyerror("number expected"); 640 else cfg_parser->cfg->incoming_num_tcp = atoi($2); 641 free($2); 642 } 643 ; 644 server_interface_automatic: VAR_INTERFACE_AUTOMATIC STRING_ARG 645 { 646 OUTYY(("P(server_interface_automatic:%s)\n", $2)); 647 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 648 yyerror("expected yes or no."); 649 else cfg_parser->cfg->if_automatic = (strcmp($2, "yes")==0); 650 free($2); 651 } 652 ; 653 server_do_ip4: VAR_DO_IP4 STRING_ARG 654 { 655 OUTYY(("P(server_do_ip4:%s)\n", $2)); 656 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 657 yyerror("expected yes or no."); 658 else cfg_parser->cfg->do_ip4 = (strcmp($2, "yes")==0); 659 free($2); 660 } 661 ; 662 server_do_ip6: VAR_DO_IP6 STRING_ARG 663 { 664 OUTYY(("P(server_do_ip6:%s)\n", $2)); 665 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 666 yyerror("expected yes or no."); 667 else cfg_parser->cfg->do_ip6 = (strcmp($2, "yes")==0); 668 free($2); 669 } 670 ; 671 server_do_udp: VAR_DO_UDP STRING_ARG 672 { 673 OUTYY(("P(server_do_udp:%s)\n", $2)); 674 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 675 yyerror("expected yes or no."); 676 else cfg_parser->cfg->do_udp = (strcmp($2, "yes")==0); 677 free($2); 678 } 679 ; 680 server_do_tcp: VAR_DO_TCP STRING_ARG 681 { 682 OUTYY(("P(server_do_tcp:%s)\n", $2)); 683 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 684 yyerror("expected yes or no."); 685 else cfg_parser->cfg->do_tcp = (strcmp($2, "yes")==0); 686 free($2); 687 } 688 ; 689 server_prefer_ip6: VAR_PREFER_IP6 STRING_ARG 690 { 691 OUTYY(("P(server_prefer_ip6:%s)\n", $2)); 692 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 693 yyerror("expected yes or no."); 694 else cfg_parser->cfg->prefer_ip6 = (strcmp($2, "yes")==0); 695 free($2); 696 } 697 ; 698 server_tcp_mss: VAR_TCP_MSS STRING_ARG 699 { 700 OUTYY(("P(server_tcp_mss:%s)\n", $2)); 701 if(atoi($2) == 0 && strcmp($2, "0") != 0) 702 yyerror("number expected"); 703 else cfg_parser->cfg->tcp_mss = atoi($2); 704 free($2); 705 } 706 ; 707 server_outgoing_tcp_mss: VAR_OUTGOING_TCP_MSS STRING_ARG 708 { 709 OUTYY(("P(server_outgoing_tcp_mss:%s)\n", $2)); 710 if(atoi($2) == 0 && strcmp($2, "0") != 0) 711 yyerror("number expected"); 712 else cfg_parser->cfg->outgoing_tcp_mss = atoi($2); 713 free($2); 714 } 715 ; 716 server_tcp_idle_timeout: VAR_TCP_IDLE_TIMEOUT STRING_ARG 717 { 718 OUTYY(("P(server_tcp_idle_timeout:%s)\n", $2)); 719 if(atoi($2) == 0 && strcmp($2, "0") != 0) 720 yyerror("number expected"); 721 else if (atoi($2) > 120000) 722 cfg_parser->cfg->tcp_idle_timeout = 120000; 723 else if (atoi($2) < 1) 724 cfg_parser->cfg->tcp_idle_timeout = 1; 725 else cfg_parser->cfg->tcp_idle_timeout = atoi($2); 726 free($2); 727 } 728 ; 729 server_tcp_keepalive: VAR_EDNS_TCP_KEEPALIVE STRING_ARG 730 { 731 OUTYY(("P(server_tcp_keepalive:%s)\n", $2)); 732 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 733 yyerror("expected yes or no."); 734 else cfg_parser->cfg->do_tcp_keepalive = (strcmp($2, "yes")==0); 735 free($2); 736 } 737 ; 738 server_tcp_keepalive_timeout: VAR_EDNS_TCP_KEEPALIVE_TIMEOUT STRING_ARG 739 { 740 OUTYY(("P(server_tcp_keepalive_timeout:%s)\n", $2)); 741 if(atoi($2) == 0 && strcmp($2, "0") != 0) 742 yyerror("number expected"); 743 else if (atoi($2) > 6553500) 744 cfg_parser->cfg->tcp_keepalive_timeout = 6553500; 745 else if (atoi($2) < 1) 746 cfg_parser->cfg->tcp_keepalive_timeout = 0; 747 else cfg_parser->cfg->tcp_keepalive_timeout = atoi($2); 748 free($2); 749 } 750 ; 751 server_tcp_upstream: VAR_TCP_UPSTREAM STRING_ARG 752 { 753 OUTYY(("P(server_tcp_upstream:%s)\n", $2)); 754 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 755 yyerror("expected yes or no."); 756 else cfg_parser->cfg->tcp_upstream = (strcmp($2, "yes")==0); 757 free($2); 758 } 759 ; 760 server_udp_upstream_without_downstream: VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM STRING_ARG 761 { 762 OUTYY(("P(server_udp_upstream_without_downstream:%s)\n", $2)); 763 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 764 yyerror("expected yes or no."); 765 else cfg_parser->cfg->udp_upstream_without_downstream = (strcmp($2, "yes")==0); 766 free($2); 767 } 768 ; 769 server_ssl_upstream: VAR_SSL_UPSTREAM STRING_ARG 770 { 771 OUTYY(("P(server_ssl_upstream:%s)\n", $2)); 772 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 773 yyerror("expected yes or no."); 774 else cfg_parser->cfg->ssl_upstream = (strcmp($2, "yes")==0); 775 free($2); 776 } 777 ; 778 server_ssl_service_key: VAR_SSL_SERVICE_KEY STRING_ARG 779 { 780 OUTYY(("P(server_ssl_service_key:%s)\n", $2)); 781 free(cfg_parser->cfg->ssl_service_key); 782 cfg_parser->cfg->ssl_service_key = $2; 783 } 784 ; 785 server_ssl_service_pem: VAR_SSL_SERVICE_PEM STRING_ARG 786 { 787 OUTYY(("P(server_ssl_service_pem:%s)\n", $2)); 788 free(cfg_parser->cfg->ssl_service_pem); 789 cfg_parser->cfg->ssl_service_pem = $2; 790 } 791 ; 792 server_ssl_port: VAR_SSL_PORT STRING_ARG 793 { 794 OUTYY(("P(server_ssl_port:%s)\n", $2)); 795 if(atoi($2) == 0) 796 yyerror("port number expected"); 797 else cfg_parser->cfg->ssl_port = atoi($2); 798 free($2); 799 } 800 ; 801 server_tls_cert_bundle: VAR_TLS_CERT_BUNDLE STRING_ARG 802 { 803 OUTYY(("P(server_tls_cert_bundle:%s)\n", $2)); 804 free(cfg_parser->cfg->tls_cert_bundle); 805 cfg_parser->cfg->tls_cert_bundle = $2; 806 } 807 ; 808 server_tls_win_cert: VAR_TLS_WIN_CERT STRING_ARG 809 { 810 OUTYY(("P(server_tls_win_cert:%s)\n", $2)); 811 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 812 yyerror("expected yes or no."); 813 else cfg_parser->cfg->tls_win_cert = (strcmp($2, "yes")==0); 814 free($2); 815 } 816 ; 817 server_tls_additional_port: VAR_TLS_ADDITIONAL_PORT STRING_ARG 818 { 819 OUTYY(("P(server_tls_additional_port:%s)\n", $2)); 820 if(!cfg_strlist_insert(&cfg_parser->cfg->tls_additional_port, 821 $2)) 822 yyerror("out of memory"); 823 } 824 ; 825 server_tls_ciphers: VAR_TLS_CIPHERS STRING_ARG 826 { 827 OUTYY(("P(server_tls_ciphers:%s)\n", $2)); 828 free(cfg_parser->cfg->tls_ciphers); 829 cfg_parser->cfg->tls_ciphers = $2; 830 } 831 ; 832 server_tls_ciphersuites: VAR_TLS_CIPHERSUITES STRING_ARG 833 { 834 OUTYY(("P(server_tls_ciphersuites:%s)\n", $2)); 835 free(cfg_parser->cfg->tls_ciphersuites); 836 cfg_parser->cfg->tls_ciphersuites = $2; 837 } 838 ; 839 server_tls_session_ticket_keys: VAR_TLS_SESSION_TICKET_KEYS STRING_ARG 840 { 841 OUTYY(("P(server_tls_session_ticket_keys:%s)\n", $2)); 842 if(!cfg_strlist_append(&cfg_parser->cfg->tls_session_ticket_keys, 843 $2)) 844 yyerror("out of memory"); 845 } 846 ; 847 server_use_systemd: VAR_USE_SYSTEMD STRING_ARG 848 { 849 OUTYY(("P(server_use_systemd:%s)\n", $2)); 850 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 851 yyerror("expected yes or no."); 852 else cfg_parser->cfg->use_systemd = (strcmp($2, "yes")==0); 853 free($2); 854 } 855 ; 856 server_do_daemonize: VAR_DO_DAEMONIZE STRING_ARG 857 { 858 OUTYY(("P(server_do_daemonize:%s)\n", $2)); 859 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 860 yyerror("expected yes or no."); 861 else cfg_parser->cfg->do_daemonize = (strcmp($2, "yes")==0); 862 free($2); 863 } 864 ; 865 server_use_syslog: VAR_USE_SYSLOG STRING_ARG 866 { 867 OUTYY(("P(server_use_syslog:%s)\n", $2)); 868 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 869 yyerror("expected yes or no."); 870 else cfg_parser->cfg->use_syslog = (strcmp($2, "yes")==0); 871 #if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS) 872 if(strcmp($2, "yes") == 0) 873 yyerror("no syslog services are available. " 874 "(reconfigure and compile to add)"); 875 #endif 876 free($2); 877 } 878 ; 879 server_log_time_ascii: VAR_LOG_TIME_ASCII STRING_ARG 880 { 881 OUTYY(("P(server_log_time_ascii:%s)\n", $2)); 882 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 883 yyerror("expected yes or no."); 884 else cfg_parser->cfg->log_time_ascii = (strcmp($2, "yes")==0); 885 free($2); 886 } 887 ; 888 server_log_queries: VAR_LOG_QUERIES STRING_ARG 889 { 890 OUTYY(("P(server_log_queries:%s)\n", $2)); 891 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 892 yyerror("expected yes or no."); 893 else cfg_parser->cfg->log_queries = (strcmp($2, "yes")==0); 894 free($2); 895 } 896 ; 897 server_log_replies: VAR_LOG_REPLIES STRING_ARG 898 { 899 OUTYY(("P(server_log_replies:%s)\n", $2)); 900 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 901 yyerror("expected yes or no."); 902 else cfg_parser->cfg->log_replies = (strcmp($2, "yes")==0); 903 free($2); 904 } 905 ; 906 server_log_tag_queryreply: VAR_LOG_TAG_QUERYREPLY STRING_ARG 907 { 908 OUTYY(("P(server_log_tag_queryreply:%s)\n", $2)); 909 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 910 yyerror("expected yes or no."); 911 else cfg_parser->cfg->log_tag_queryreply = (strcmp($2, "yes")==0); 912 free($2); 913 } 914 ; 915 server_log_servfail: VAR_LOG_SERVFAIL STRING_ARG 916 { 917 OUTYY(("P(server_log_servfail:%s)\n", $2)); 918 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 919 yyerror("expected yes or no."); 920 else cfg_parser->cfg->log_servfail = (strcmp($2, "yes")==0); 921 free($2); 922 } 923 ; 924 server_log_local_actions: VAR_LOG_LOCAL_ACTIONS STRING_ARG 925 { 926 OUTYY(("P(server_log_local_actions:%s)\n", $2)); 927 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 928 yyerror("expected yes or no."); 929 else cfg_parser->cfg->log_local_actions = (strcmp($2, "yes")==0); 930 free($2); 931 } 932 ; 933 server_chroot: VAR_CHROOT STRING_ARG 934 { 935 OUTYY(("P(server_chroot:%s)\n", $2)); 936 free(cfg_parser->cfg->chrootdir); 937 cfg_parser->cfg->chrootdir = $2; 938 } 939 ; 940 server_username: VAR_USERNAME STRING_ARG 941 { 942 OUTYY(("P(server_username:%s)\n", $2)); 943 free(cfg_parser->cfg->username); 944 cfg_parser->cfg->username = $2; 945 } 946 ; 947 server_directory: VAR_DIRECTORY STRING_ARG 948 { 949 OUTYY(("P(server_directory:%s)\n", $2)); 950 free(cfg_parser->cfg->directory); 951 cfg_parser->cfg->directory = $2; 952 /* change there right away for includes relative to this */ 953 if($2[0]) { 954 char* d; 955 #ifdef UB_ON_WINDOWS 956 w_config_adjust_directory(cfg_parser->cfg); 957 #endif 958 d = cfg_parser->cfg->directory; 959 /* adjust directory if we have already chroot, 960 * like, we reread after sighup */ 961 if(cfg_parser->chroot && cfg_parser->chroot[0] && 962 strncmp(d, cfg_parser->chroot, strlen( 963 cfg_parser->chroot)) == 0) 964 d += strlen(cfg_parser->chroot); 965 if(d[0]) { 966 if(chdir(d)) 967 log_err("cannot chdir to directory: %s (%s)", 968 d, strerror(errno)); 969 } 970 } 971 } 972 ; 973 server_logfile: VAR_LOGFILE STRING_ARG 974 { 975 OUTYY(("P(server_logfile:%s)\n", $2)); 976 free(cfg_parser->cfg->logfile); 977 cfg_parser->cfg->logfile = $2; 978 cfg_parser->cfg->use_syslog = 0; 979 } 980 ; 981 server_pidfile: VAR_PIDFILE STRING_ARG 982 { 983 OUTYY(("P(server_pidfile:%s)\n", $2)); 984 free(cfg_parser->cfg->pidfile); 985 cfg_parser->cfg->pidfile = $2; 986 } 987 ; 988 server_root_hints: VAR_ROOT_HINTS STRING_ARG 989 { 990 OUTYY(("P(server_root_hints:%s)\n", $2)); 991 if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, $2)) 992 yyerror("out of memory"); 993 } 994 ; 995 server_dlv_anchor_file: VAR_DLV_ANCHOR_FILE STRING_ARG 996 { 997 OUTYY(("P(server_dlv_anchor_file:%s)\n", $2)); 998 free(cfg_parser->cfg->dlv_anchor_file); 999 cfg_parser->cfg->dlv_anchor_file = $2; 1000 } 1001 ; 1002 server_dlv_anchor: VAR_DLV_ANCHOR STRING_ARG 1003 { 1004 OUTYY(("P(server_dlv_anchor:%s)\n", $2)); 1005 if(!cfg_strlist_insert(&cfg_parser->cfg->dlv_anchor_list, $2)) 1006 yyerror("out of memory"); 1007 } 1008 ; 1009 server_auto_trust_anchor_file: VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG 1010 { 1011 OUTYY(("P(server_auto_trust_anchor_file:%s)\n", $2)); 1012 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1013 auto_trust_anchor_file_list, $2)) 1014 yyerror("out of memory"); 1015 } 1016 ; 1017 server_trust_anchor_file: VAR_TRUST_ANCHOR_FILE STRING_ARG 1018 { 1019 OUTYY(("P(server_trust_anchor_file:%s)\n", $2)); 1020 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1021 trust_anchor_file_list, $2)) 1022 yyerror("out of memory"); 1023 } 1024 ; 1025 server_trusted_keys_file: VAR_TRUSTED_KEYS_FILE STRING_ARG 1026 { 1027 OUTYY(("P(server_trusted_keys_file:%s)\n", $2)); 1028 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1029 trusted_keys_file_list, $2)) 1030 yyerror("out of memory"); 1031 } 1032 ; 1033 server_trust_anchor: VAR_TRUST_ANCHOR STRING_ARG 1034 { 1035 OUTYY(("P(server_trust_anchor:%s)\n", $2)); 1036 if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, $2)) 1037 yyerror("out of memory"); 1038 } 1039 ; 1040 server_trust_anchor_signaling: VAR_TRUST_ANCHOR_SIGNALING STRING_ARG 1041 { 1042 OUTYY(("P(server_trust_anchor_signaling:%s)\n", $2)); 1043 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1044 yyerror("expected yes or no."); 1045 else 1046 cfg_parser->cfg->trust_anchor_signaling = 1047 (strcmp($2, "yes")==0); 1048 free($2); 1049 } 1050 ; 1051 server_root_key_sentinel: VAR_ROOT_KEY_SENTINEL STRING_ARG 1052 { 1053 OUTYY(("P(server_root_key_sentinel:%s)\n", $2)); 1054 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1055 yyerror("expected yes or no."); 1056 else 1057 cfg_parser->cfg->root_key_sentinel = 1058 (strcmp($2, "yes")==0); 1059 free($2); 1060 } 1061 ; 1062 server_domain_insecure: VAR_DOMAIN_INSECURE STRING_ARG 1063 { 1064 OUTYY(("P(server_domain_insecure:%s)\n", $2)); 1065 if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, $2)) 1066 yyerror("out of memory"); 1067 } 1068 ; 1069 server_hide_identity: VAR_HIDE_IDENTITY STRING_ARG 1070 { 1071 OUTYY(("P(server_hide_identity:%s)\n", $2)); 1072 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1073 yyerror("expected yes or no."); 1074 else cfg_parser->cfg->hide_identity = (strcmp($2, "yes")==0); 1075 free($2); 1076 } 1077 ; 1078 server_hide_version: VAR_HIDE_VERSION STRING_ARG 1079 { 1080 OUTYY(("P(server_hide_version:%s)\n", $2)); 1081 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1082 yyerror("expected yes or no."); 1083 else cfg_parser->cfg->hide_version = (strcmp($2, "yes")==0); 1084 free($2); 1085 } 1086 ; 1087 server_hide_trustanchor: VAR_HIDE_TRUSTANCHOR STRING_ARG 1088 { 1089 OUTYY(("P(server_hide_trustanchor:%s)\n", $2)); 1090 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1091 yyerror("expected yes or no."); 1092 else cfg_parser->cfg->hide_trustanchor = (strcmp($2, "yes")==0); 1093 free($2); 1094 } 1095 ; 1096 server_identity: VAR_IDENTITY STRING_ARG 1097 { 1098 OUTYY(("P(server_identity:%s)\n", $2)); 1099 free(cfg_parser->cfg->identity); 1100 cfg_parser->cfg->identity = $2; 1101 } 1102 ; 1103 server_version: VAR_VERSION STRING_ARG 1104 { 1105 OUTYY(("P(server_version:%s)\n", $2)); 1106 free(cfg_parser->cfg->version); 1107 cfg_parser->cfg->version = $2; 1108 } 1109 ; 1110 server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG 1111 { 1112 OUTYY(("P(server_so_rcvbuf:%s)\n", $2)); 1113 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_rcvbuf)) 1114 yyerror("buffer size expected"); 1115 free($2); 1116 } 1117 ; 1118 server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG 1119 { 1120 OUTYY(("P(server_so_sndbuf:%s)\n", $2)); 1121 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_sndbuf)) 1122 yyerror("buffer size expected"); 1123 free($2); 1124 } 1125 ; 1126 server_so_reuseport: VAR_SO_REUSEPORT STRING_ARG 1127 { 1128 OUTYY(("P(server_so_reuseport:%s)\n", $2)); 1129 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1130 yyerror("expected yes or no."); 1131 else cfg_parser->cfg->so_reuseport = 1132 (strcmp($2, "yes")==0); 1133 free($2); 1134 } 1135 ; 1136 server_ip_transparent: VAR_IP_TRANSPARENT STRING_ARG 1137 { 1138 OUTYY(("P(server_ip_transparent:%s)\n", $2)); 1139 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1140 yyerror("expected yes or no."); 1141 else cfg_parser->cfg->ip_transparent = 1142 (strcmp($2, "yes")==0); 1143 free($2); 1144 } 1145 ; 1146 server_ip_freebind: VAR_IP_FREEBIND STRING_ARG 1147 { 1148 OUTYY(("P(server_ip_freebind:%s)\n", $2)); 1149 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1150 yyerror("expected yes or no."); 1151 else cfg_parser->cfg->ip_freebind = 1152 (strcmp($2, "yes")==0); 1153 free($2); 1154 } 1155 ; 1156 server_stream_wait_size: VAR_STREAM_WAIT_SIZE STRING_ARG 1157 { 1158 OUTYY(("P(server_stream_wait_size:%s)\n", $2)); 1159 if(!cfg_parse_memsize($2, &cfg_parser->cfg->stream_wait_size)) 1160 yyerror("memory size expected"); 1161 free($2); 1162 } 1163 ; 1164 server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG 1165 { 1166 OUTYY(("P(server_edns_buffer_size:%s)\n", $2)); 1167 if(atoi($2) == 0) 1168 yyerror("number expected"); 1169 else if (atoi($2) < 12) 1170 yyerror("edns buffer size too small"); 1171 else if (atoi($2) > 65535) 1172 cfg_parser->cfg->edns_buffer_size = 65535; 1173 else cfg_parser->cfg->edns_buffer_size = atoi($2); 1174 free($2); 1175 } 1176 ; 1177 server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG 1178 { 1179 OUTYY(("P(server_msg_buffer_size:%s)\n", $2)); 1180 if(atoi($2) == 0) 1181 yyerror("number expected"); 1182 else if (atoi($2) < 4096) 1183 yyerror("message buffer size too small (use 4096)"); 1184 else cfg_parser->cfg->msg_buffer_size = atoi($2); 1185 free($2); 1186 } 1187 ; 1188 server_msg_cache_size: VAR_MSG_CACHE_SIZE STRING_ARG 1189 { 1190 OUTYY(("P(server_msg_cache_size:%s)\n", $2)); 1191 if(!cfg_parse_memsize($2, &cfg_parser->cfg->msg_cache_size)) 1192 yyerror("memory size expected"); 1193 free($2); 1194 } 1195 ; 1196 server_msg_cache_slabs: VAR_MSG_CACHE_SLABS STRING_ARG 1197 { 1198 OUTYY(("P(server_msg_cache_slabs:%s)\n", $2)); 1199 if(atoi($2) == 0) 1200 yyerror("number expected"); 1201 else { 1202 cfg_parser->cfg->msg_cache_slabs = atoi($2); 1203 if(!is_pow2(cfg_parser->cfg->msg_cache_slabs)) 1204 yyerror("must be a power of 2"); 1205 } 1206 free($2); 1207 } 1208 ; 1209 server_num_queries_per_thread: VAR_NUM_QUERIES_PER_THREAD STRING_ARG 1210 { 1211 OUTYY(("P(server_num_queries_per_thread:%s)\n", $2)); 1212 if(atoi($2) == 0) 1213 yyerror("number expected"); 1214 else cfg_parser->cfg->num_queries_per_thread = atoi($2); 1215 free($2); 1216 } 1217 ; 1218 server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG 1219 { 1220 OUTYY(("P(server_jostle_timeout:%s)\n", $2)); 1221 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1222 yyerror("number expected"); 1223 else cfg_parser->cfg->jostle_time = atoi($2); 1224 free($2); 1225 } 1226 ; 1227 server_delay_close: VAR_DELAY_CLOSE STRING_ARG 1228 { 1229 OUTYY(("P(server_delay_close:%s)\n", $2)); 1230 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1231 yyerror("number expected"); 1232 else cfg_parser->cfg->delay_close = atoi($2); 1233 free($2); 1234 } 1235 ; 1236 server_unblock_lan_zones: VAR_UNBLOCK_LAN_ZONES STRING_ARG 1237 { 1238 OUTYY(("P(server_unblock_lan_zones:%s)\n", $2)); 1239 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1240 yyerror("expected yes or no."); 1241 else cfg_parser->cfg->unblock_lan_zones = 1242 (strcmp($2, "yes")==0); 1243 free($2); 1244 } 1245 ; 1246 server_insecure_lan_zones: VAR_INSECURE_LAN_ZONES STRING_ARG 1247 { 1248 OUTYY(("P(server_insecure_lan_zones:%s)\n", $2)); 1249 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1250 yyerror("expected yes or no."); 1251 else cfg_parser->cfg->insecure_lan_zones = 1252 (strcmp($2, "yes")==0); 1253 free($2); 1254 } 1255 ; 1256 server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG 1257 { 1258 OUTYY(("P(server_rrset_cache_size:%s)\n", $2)); 1259 if(!cfg_parse_memsize($2, &cfg_parser->cfg->rrset_cache_size)) 1260 yyerror("memory size expected"); 1261 free($2); 1262 } 1263 ; 1264 server_rrset_cache_slabs: VAR_RRSET_CACHE_SLABS STRING_ARG 1265 { 1266 OUTYY(("P(server_rrset_cache_slabs:%s)\n", $2)); 1267 if(atoi($2) == 0) 1268 yyerror("number expected"); 1269 else { 1270 cfg_parser->cfg->rrset_cache_slabs = atoi($2); 1271 if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs)) 1272 yyerror("must be a power of 2"); 1273 } 1274 free($2); 1275 } 1276 ; 1277 server_infra_host_ttl: VAR_INFRA_HOST_TTL STRING_ARG 1278 { 1279 OUTYY(("P(server_infra_host_ttl:%s)\n", $2)); 1280 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1281 yyerror("number expected"); 1282 else cfg_parser->cfg->host_ttl = atoi($2); 1283 free($2); 1284 } 1285 ; 1286 server_infra_lame_ttl: VAR_INFRA_LAME_TTL STRING_ARG 1287 { 1288 OUTYY(("P(server_infra_lame_ttl:%s)\n", $2)); 1289 verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option " 1290 "removed, use infra-host-ttl)", $2); 1291 free($2); 1292 } 1293 ; 1294 server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING_ARG 1295 { 1296 OUTYY(("P(server_infra_cache_numhosts:%s)\n", $2)); 1297 if(atoi($2) == 0) 1298 yyerror("number expected"); 1299 else cfg_parser->cfg->infra_cache_numhosts = atoi($2); 1300 free($2); 1301 } 1302 ; 1303 server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING_ARG 1304 { 1305 OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2)); 1306 verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s " 1307 "(option removed, use infra-cache-numhosts)", $2); 1308 free($2); 1309 } 1310 ; 1311 server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG 1312 { 1313 OUTYY(("P(server_infra_cache_slabs:%s)\n", $2)); 1314 if(atoi($2) == 0) 1315 yyerror("number expected"); 1316 else { 1317 cfg_parser->cfg->infra_cache_slabs = atoi($2); 1318 if(!is_pow2(cfg_parser->cfg->infra_cache_slabs)) 1319 yyerror("must be a power of 2"); 1320 } 1321 free($2); 1322 } 1323 ; 1324 server_infra_cache_min_rtt: VAR_INFRA_CACHE_MIN_RTT STRING_ARG 1325 { 1326 OUTYY(("P(server_infra_cache_min_rtt:%s)\n", $2)); 1327 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1328 yyerror("number expected"); 1329 else cfg_parser->cfg->infra_cache_min_rtt = atoi($2); 1330 free($2); 1331 } 1332 ; 1333 server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG 1334 { 1335 OUTYY(("P(server_target_fetch_policy:%s)\n", $2)); 1336 free(cfg_parser->cfg->target_fetch_policy); 1337 cfg_parser->cfg->target_fetch_policy = $2; 1338 } 1339 ; 1340 server_harden_short_bufsize: VAR_HARDEN_SHORT_BUFSIZE STRING_ARG 1341 { 1342 OUTYY(("P(server_harden_short_bufsize:%s)\n", $2)); 1343 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1344 yyerror("expected yes or no."); 1345 else cfg_parser->cfg->harden_short_bufsize = 1346 (strcmp($2, "yes")==0); 1347 free($2); 1348 } 1349 ; 1350 server_harden_large_queries: VAR_HARDEN_LARGE_QUERIES STRING_ARG 1351 { 1352 OUTYY(("P(server_harden_large_queries:%s)\n", $2)); 1353 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1354 yyerror("expected yes or no."); 1355 else cfg_parser->cfg->harden_large_queries = 1356 (strcmp($2, "yes")==0); 1357 free($2); 1358 } 1359 ; 1360 server_harden_glue: VAR_HARDEN_GLUE STRING_ARG 1361 { 1362 OUTYY(("P(server_harden_glue:%s)\n", $2)); 1363 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1364 yyerror("expected yes or no."); 1365 else cfg_parser->cfg->harden_glue = 1366 (strcmp($2, "yes")==0); 1367 free($2); 1368 } 1369 ; 1370 server_harden_dnssec_stripped: VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG 1371 { 1372 OUTYY(("P(server_harden_dnssec_stripped:%s)\n", $2)); 1373 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1374 yyerror("expected yes or no."); 1375 else cfg_parser->cfg->harden_dnssec_stripped = 1376 (strcmp($2, "yes")==0); 1377 free($2); 1378 } 1379 ; 1380 server_harden_below_nxdomain: VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG 1381 { 1382 OUTYY(("P(server_harden_below_nxdomain:%s)\n", $2)); 1383 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1384 yyerror("expected yes or no."); 1385 else cfg_parser->cfg->harden_below_nxdomain = 1386 (strcmp($2, "yes")==0); 1387 free($2); 1388 } 1389 ; 1390 server_harden_referral_path: VAR_HARDEN_REFERRAL_PATH STRING_ARG 1391 { 1392 OUTYY(("P(server_harden_referral_path:%s)\n", $2)); 1393 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1394 yyerror("expected yes or no."); 1395 else cfg_parser->cfg->harden_referral_path = 1396 (strcmp($2, "yes")==0); 1397 free($2); 1398 } 1399 ; 1400 server_harden_algo_downgrade: VAR_HARDEN_ALGO_DOWNGRADE STRING_ARG 1401 { 1402 OUTYY(("P(server_harden_algo_downgrade:%s)\n", $2)); 1403 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1404 yyerror("expected yes or no."); 1405 else cfg_parser->cfg->harden_algo_downgrade = 1406 (strcmp($2, "yes")==0); 1407 free($2); 1408 } 1409 ; 1410 server_use_caps_for_id: VAR_USE_CAPS_FOR_ID STRING_ARG 1411 { 1412 OUTYY(("P(server_use_caps_for_id:%s)\n", $2)); 1413 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1414 yyerror("expected yes or no."); 1415 else cfg_parser->cfg->use_caps_bits_for_id = 1416 (strcmp($2, "yes")==0); 1417 free($2); 1418 } 1419 ; 1420 server_caps_whitelist: VAR_CAPS_WHITELIST STRING_ARG 1421 { 1422 OUTYY(("P(server_caps_whitelist:%s)\n", $2)); 1423 if(!cfg_strlist_insert(&cfg_parser->cfg->caps_whitelist, $2)) 1424 yyerror("out of memory"); 1425 } 1426 ; 1427 server_private_address: VAR_PRIVATE_ADDRESS STRING_ARG 1428 { 1429 OUTYY(("P(server_private_address:%s)\n", $2)); 1430 if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, $2)) 1431 yyerror("out of memory"); 1432 } 1433 ; 1434 server_private_domain: VAR_PRIVATE_DOMAIN STRING_ARG 1435 { 1436 OUTYY(("P(server_private_domain:%s)\n", $2)); 1437 if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, $2)) 1438 yyerror("out of memory"); 1439 } 1440 ; 1441 server_prefetch: VAR_PREFETCH STRING_ARG 1442 { 1443 OUTYY(("P(server_prefetch:%s)\n", $2)); 1444 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1445 yyerror("expected yes or no."); 1446 else cfg_parser->cfg->prefetch = (strcmp($2, "yes")==0); 1447 free($2); 1448 } 1449 ; 1450 server_prefetch_key: VAR_PREFETCH_KEY STRING_ARG 1451 { 1452 OUTYY(("P(server_prefetch_key:%s)\n", $2)); 1453 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1454 yyerror("expected yes or no."); 1455 else cfg_parser->cfg->prefetch_key = (strcmp($2, "yes")==0); 1456 free($2); 1457 } 1458 ; 1459 server_deny_any: VAR_DENY_ANY STRING_ARG 1460 { 1461 OUTYY(("P(server_deny_any:%s)\n", $2)); 1462 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1463 yyerror("expected yes or no."); 1464 else cfg_parser->cfg->deny_any = (strcmp($2, "yes")==0); 1465 free($2); 1466 } 1467 ; 1468 server_unwanted_reply_threshold: VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG 1469 { 1470 OUTYY(("P(server_unwanted_reply_threshold:%s)\n", $2)); 1471 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1472 yyerror("number expected"); 1473 else cfg_parser->cfg->unwanted_threshold = atoi($2); 1474 free($2); 1475 } 1476 ; 1477 server_do_not_query_address: VAR_DO_NOT_QUERY_ADDRESS STRING_ARG 1478 { 1479 OUTYY(("P(server_do_not_query_address:%s)\n", $2)); 1480 if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, $2)) 1481 yyerror("out of memory"); 1482 } 1483 ; 1484 server_do_not_query_localhost: VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG 1485 { 1486 OUTYY(("P(server_do_not_query_localhost:%s)\n", $2)); 1487 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1488 yyerror("expected yes or no."); 1489 else cfg_parser->cfg->donotquery_localhost = 1490 (strcmp($2, "yes")==0); 1491 free($2); 1492 } 1493 ; 1494 server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG 1495 { 1496 OUTYY(("P(server_access_control:%s %s)\n", $2, $3)); 1497 if(strcmp($3, "deny")!=0 && strcmp($3, "refuse")!=0 && 1498 strcmp($3, "deny_non_local")!=0 && 1499 strcmp($3, "refuse_non_local")!=0 && 1500 strcmp($3, "allow_setrd")!=0 && 1501 strcmp($3, "allow")!=0 && 1502 strcmp($3, "allow_snoop")!=0) { 1503 yyerror("expected deny, refuse, deny_non_local, " 1504 "refuse_non_local, allow, allow_setrd or " 1505 "allow_snoop in access control action"); 1506 free($2); 1507 free($3); 1508 } else { 1509 if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3)) 1510 fatal_exit("out of memory adding acl"); 1511 } 1512 } 1513 ; 1514 server_module_conf: VAR_MODULE_CONF STRING_ARG 1515 { 1516 OUTYY(("P(server_module_conf:%s)\n", $2)); 1517 free(cfg_parser->cfg->module_conf); 1518 cfg_parser->cfg->module_conf = $2; 1519 } 1520 ; 1521 server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING_ARG 1522 { 1523 OUTYY(("P(server_val_override_date:%s)\n", $2)); 1524 if(*$2 == '\0' || strcmp($2, "0") == 0) { 1525 cfg_parser->cfg->val_date_override = 0; 1526 } else if(strlen($2) == 14) { 1527 cfg_parser->cfg->val_date_override = 1528 cfg_convert_timeval($2); 1529 if(!cfg_parser->cfg->val_date_override) 1530 yyerror("bad date/time specification"); 1531 } else { 1532 if(atoi($2) == 0) 1533 yyerror("number expected"); 1534 cfg_parser->cfg->val_date_override = atoi($2); 1535 } 1536 free($2); 1537 } 1538 ; 1539 server_val_sig_skew_min: VAR_VAL_SIG_SKEW_MIN STRING_ARG 1540 { 1541 OUTYY(("P(server_val_sig_skew_min:%s)\n", $2)); 1542 if(*$2 == '\0' || strcmp($2, "0") == 0) { 1543 cfg_parser->cfg->val_sig_skew_min = 0; 1544 } else { 1545 cfg_parser->cfg->val_sig_skew_min = atoi($2); 1546 if(!cfg_parser->cfg->val_sig_skew_min) 1547 yyerror("number expected"); 1548 } 1549 free($2); 1550 } 1551 ; 1552 server_val_sig_skew_max: VAR_VAL_SIG_SKEW_MAX STRING_ARG 1553 { 1554 OUTYY(("P(server_val_sig_skew_max:%s)\n", $2)); 1555 if(*$2 == '\0' || strcmp($2, "0") == 0) { 1556 cfg_parser->cfg->val_sig_skew_max = 0; 1557 } else { 1558 cfg_parser->cfg->val_sig_skew_max = atoi($2); 1559 if(!cfg_parser->cfg->val_sig_skew_max) 1560 yyerror("number expected"); 1561 } 1562 free($2); 1563 } 1564 ; 1565 server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG 1566 { 1567 OUTYY(("P(server_cache_max_ttl:%s)\n", $2)); 1568 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1569 yyerror("number expected"); 1570 else cfg_parser->cfg->max_ttl = atoi($2); 1571 free($2); 1572 } 1573 ; 1574 server_cache_max_negative_ttl: VAR_CACHE_MAX_NEGATIVE_TTL STRING_ARG 1575 { 1576 OUTYY(("P(server_cache_max_negative_ttl:%s)\n", $2)); 1577 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1578 yyerror("number expected"); 1579 else cfg_parser->cfg->max_negative_ttl = atoi($2); 1580 free($2); 1581 } 1582 ; 1583 server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG 1584 { 1585 OUTYY(("P(server_cache_min_ttl:%s)\n", $2)); 1586 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1587 yyerror("number expected"); 1588 else cfg_parser->cfg->min_ttl = atoi($2); 1589 free($2); 1590 } 1591 ; 1592 server_bogus_ttl: VAR_BOGUS_TTL STRING_ARG 1593 { 1594 OUTYY(("P(server_bogus_ttl:%s)\n", $2)); 1595 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1596 yyerror("number expected"); 1597 else cfg_parser->cfg->bogus_ttl = atoi($2); 1598 free($2); 1599 } 1600 ; 1601 server_val_clean_additional: VAR_VAL_CLEAN_ADDITIONAL STRING_ARG 1602 { 1603 OUTYY(("P(server_val_clean_additional:%s)\n", $2)); 1604 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1605 yyerror("expected yes or no."); 1606 else cfg_parser->cfg->val_clean_additional = 1607 (strcmp($2, "yes")==0); 1608 free($2); 1609 } 1610 ; 1611 server_val_permissive_mode: VAR_VAL_PERMISSIVE_MODE STRING_ARG 1612 { 1613 OUTYY(("P(server_val_permissive_mode:%s)\n", $2)); 1614 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1615 yyerror("expected yes or no."); 1616 else cfg_parser->cfg->val_permissive_mode = 1617 (strcmp($2, "yes")==0); 1618 free($2); 1619 } 1620 ; 1621 server_aggressive_nsec: VAR_AGGRESSIVE_NSEC STRING_ARG 1622 { 1623 OUTYY(("P(server_aggressive_nsec:%s)\n", $2)); 1624 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1625 yyerror("expected yes or no."); 1626 else 1627 cfg_parser->cfg->aggressive_nsec = 1628 (strcmp($2, "yes")==0); 1629 free($2); 1630 } 1631 ; 1632 server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG 1633 { 1634 OUTYY(("P(server_ignore_cd_flag:%s)\n", $2)); 1635 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1636 yyerror("expected yes or no."); 1637 else cfg_parser->cfg->ignore_cd = (strcmp($2, "yes")==0); 1638 free($2); 1639 } 1640 ; 1641 server_serve_expired: VAR_SERVE_EXPIRED STRING_ARG 1642 { 1643 OUTYY(("P(server_serve_expired:%s)\n", $2)); 1644 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1645 yyerror("expected yes or no."); 1646 else cfg_parser->cfg->serve_expired = (strcmp($2, "yes")==0); 1647 free($2); 1648 } 1649 ; 1650 server_serve_expired_ttl: VAR_SERVE_EXPIRED_TTL STRING_ARG 1651 { 1652 OUTYY(("P(server_serve_expired_ttl:%s)\n", $2)); 1653 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1654 yyerror("number expected"); 1655 else cfg_parser->cfg->serve_expired_ttl = atoi($2); 1656 free($2); 1657 } 1658 ; 1659 server_serve_expired_ttl_reset: VAR_SERVE_EXPIRED_TTL_RESET STRING_ARG 1660 { 1661 OUTYY(("P(server_serve_expired_ttl_reset:%s)\n", $2)); 1662 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1663 yyerror("expected yes or no."); 1664 else cfg_parser->cfg->serve_expired_ttl_reset = (strcmp($2, "yes")==0); 1665 free($2); 1666 } 1667 ; 1668 server_fake_dsa: VAR_FAKE_DSA STRING_ARG 1669 { 1670 OUTYY(("P(server_fake_dsa:%s)\n", $2)); 1671 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1672 yyerror("expected yes or no."); 1673 #ifdef HAVE_SSL 1674 else fake_dsa = (strcmp($2, "yes")==0); 1675 if(fake_dsa) 1676 log_warn("test option fake_dsa is enabled"); 1677 #endif 1678 free($2); 1679 } 1680 ; 1681 server_fake_sha1: VAR_FAKE_SHA1 STRING_ARG 1682 { 1683 OUTYY(("P(server_fake_sha1:%s)\n", $2)); 1684 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1685 yyerror("expected yes or no."); 1686 #ifdef HAVE_SSL 1687 else fake_sha1 = (strcmp($2, "yes")==0); 1688 if(fake_sha1) 1689 log_warn("test option fake_sha1 is enabled"); 1690 #endif 1691 free($2); 1692 } 1693 ; 1694 server_val_log_level: VAR_VAL_LOG_LEVEL STRING_ARG 1695 { 1696 OUTYY(("P(server_val_log_level:%s)\n", $2)); 1697 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1698 yyerror("number expected"); 1699 else cfg_parser->cfg->val_log_level = atoi($2); 1700 free($2); 1701 } 1702 ; 1703 server_val_nsec3_keysize_iterations: VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG 1704 { 1705 OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", $2)); 1706 free(cfg_parser->cfg->val_nsec3_key_iterations); 1707 cfg_parser->cfg->val_nsec3_key_iterations = $2; 1708 } 1709 ; 1710 server_add_holddown: VAR_ADD_HOLDDOWN STRING_ARG 1711 { 1712 OUTYY(("P(server_add_holddown:%s)\n", $2)); 1713 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1714 yyerror("number expected"); 1715 else cfg_parser->cfg->add_holddown = atoi($2); 1716 free($2); 1717 } 1718 ; 1719 server_del_holddown: VAR_DEL_HOLDDOWN STRING_ARG 1720 { 1721 OUTYY(("P(server_del_holddown:%s)\n", $2)); 1722 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1723 yyerror("number expected"); 1724 else cfg_parser->cfg->del_holddown = atoi($2); 1725 free($2); 1726 } 1727 ; 1728 server_keep_missing: VAR_KEEP_MISSING STRING_ARG 1729 { 1730 OUTYY(("P(server_keep_missing:%s)\n", $2)); 1731 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1732 yyerror("number expected"); 1733 else cfg_parser->cfg->keep_missing = atoi($2); 1734 free($2); 1735 } 1736 ; 1737 server_permit_small_holddown: VAR_PERMIT_SMALL_HOLDDOWN STRING_ARG 1738 { 1739 OUTYY(("P(server_permit_small_holddown:%s)\n", $2)); 1740 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1741 yyerror("expected yes or no."); 1742 else cfg_parser->cfg->permit_small_holddown = 1743 (strcmp($2, "yes")==0); 1744 free($2); 1745 } 1746 server_key_cache_size: VAR_KEY_CACHE_SIZE STRING_ARG 1747 { 1748 OUTYY(("P(server_key_cache_size:%s)\n", $2)); 1749 if(!cfg_parse_memsize($2, &cfg_parser->cfg->key_cache_size)) 1750 yyerror("memory size expected"); 1751 free($2); 1752 } 1753 ; 1754 server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING_ARG 1755 { 1756 OUTYY(("P(server_key_cache_slabs:%s)\n", $2)); 1757 if(atoi($2) == 0) 1758 yyerror("number expected"); 1759 else { 1760 cfg_parser->cfg->key_cache_slabs = atoi($2); 1761 if(!is_pow2(cfg_parser->cfg->key_cache_slabs)) 1762 yyerror("must be a power of 2"); 1763 } 1764 free($2); 1765 } 1766 ; 1767 server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG 1768 { 1769 OUTYY(("P(server_neg_cache_size:%s)\n", $2)); 1770 if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size)) 1771 yyerror("memory size expected"); 1772 free($2); 1773 } 1774 ; 1775 server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG 1776 { 1777 OUTYY(("P(server_local_zone:%s %s)\n", $2, $3)); 1778 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && 1779 strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && 1780 strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 1781 && strcmp($3, "typetransparent")!=0 1782 && strcmp($3, "always_transparent")!=0 1783 && strcmp($3, "always_refuse")!=0 1784 && strcmp($3, "always_nxdomain")!=0 1785 && strcmp($3, "noview")!=0 1786 && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0 1787 && strcmp($3, "inform_redirect") != 0) { 1788 yyerror("local-zone type: expected static, deny, " 1789 "refuse, redirect, transparent, " 1790 "typetransparent, inform, inform_deny, " 1791 "inform_redirect, always_transparent, " 1792 "always_refuse, always_nxdomain, noview " 1793 "or nodefault"); 1794 free($2); 1795 free($3); 1796 } else if(strcmp($3, "nodefault")==0) { 1797 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1798 local_zones_nodefault, $2)) 1799 fatal_exit("out of memory adding local-zone"); 1800 free($3); 1801 } else { 1802 if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones, 1803 $2, $3)) 1804 fatal_exit("out of memory adding local-zone"); 1805 } 1806 } 1807 ; 1808 server_local_data: VAR_LOCAL_DATA STRING_ARG 1809 { 1810 OUTYY(("P(server_local_data:%s)\n", $2)); 1811 if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2)) 1812 fatal_exit("out of memory adding local-data"); 1813 } 1814 ; 1815 server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG 1816 { 1817 char* ptr; 1818 OUTYY(("P(server_local_data_ptr:%s)\n", $2)); 1819 ptr = cfg_ptr_reverse($2); 1820 free($2); 1821 if(ptr) { 1822 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1823 local_data, ptr)) 1824 fatal_exit("out of memory adding local-data"); 1825 } else { 1826 yyerror("local-data-ptr could not be reversed"); 1827 } 1828 } 1829 ; 1830 server_minimal_responses: VAR_MINIMAL_RESPONSES STRING_ARG 1831 { 1832 OUTYY(("P(server_minimal_responses:%s)\n", $2)); 1833 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1834 yyerror("expected yes or no."); 1835 else cfg_parser->cfg->minimal_responses = 1836 (strcmp($2, "yes")==0); 1837 free($2); 1838 } 1839 ; 1840 server_rrset_roundrobin: VAR_RRSET_ROUNDROBIN STRING_ARG 1841 { 1842 OUTYY(("P(server_rrset_roundrobin:%s)\n", $2)); 1843 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1844 yyerror("expected yes or no."); 1845 else cfg_parser->cfg->rrset_roundrobin = 1846 (strcmp($2, "yes")==0); 1847 free($2); 1848 } 1849 ; 1850 server_unknown_server_time_limit: VAR_UNKNOWN_SERVER_TIME_LIMIT STRING_ARG 1851 { 1852 OUTYY(("P(server_unknown_server_time_limit:%s)\n", $2)); 1853 cfg_parser->cfg->unknown_server_time_limit = atoi($2); 1854 free($2); 1855 } 1856 ; 1857 server_max_udp_size: VAR_MAX_UDP_SIZE STRING_ARG 1858 { 1859 OUTYY(("P(server_max_udp_size:%s)\n", $2)); 1860 cfg_parser->cfg->max_udp_size = atoi($2); 1861 free($2); 1862 } 1863 ; 1864 server_dns64_prefix: VAR_DNS64_PREFIX STRING_ARG 1865 { 1866 OUTYY(("P(dns64_prefix:%s)\n", $2)); 1867 free(cfg_parser->cfg->dns64_prefix); 1868 cfg_parser->cfg->dns64_prefix = $2; 1869 } 1870 ; 1871 server_dns64_synthall: VAR_DNS64_SYNTHALL STRING_ARG 1872 { 1873 OUTYY(("P(server_dns64_synthall:%s)\n", $2)); 1874 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1875 yyerror("expected yes or no."); 1876 else cfg_parser->cfg->dns64_synthall = (strcmp($2, "yes")==0); 1877 free($2); 1878 } 1879 ; 1880 server_dns64_ignore_aaaa: VAR_DNS64_IGNORE_AAAA STRING_ARG 1881 { 1882 OUTYY(("P(dns64_ignore_aaaa:%s)\n", $2)); 1883 if(!cfg_strlist_insert(&cfg_parser->cfg->dns64_ignore_aaaa, 1884 $2)) 1885 fatal_exit("out of memory adding dns64-ignore-aaaa"); 1886 } 1887 ; 1888 server_define_tag: VAR_DEFINE_TAG STRING_ARG 1889 { 1890 char* p, *s = $2; 1891 OUTYY(("P(server_define_tag:%s)\n", $2)); 1892 while((p=strsep(&s, " \t\n")) != NULL) { 1893 if(*p) { 1894 if(!config_add_tag(cfg_parser->cfg, p)) 1895 yyerror("could not define-tag, " 1896 "out of memory"); 1897 } 1898 } 1899 free($2); 1900 } 1901 ; 1902 server_local_zone_tag: VAR_LOCAL_ZONE_TAG STRING_ARG STRING_ARG 1903 { 1904 size_t len = 0; 1905 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3, 1906 &len); 1907 free($3); 1908 OUTYY(("P(server_local_zone_tag:%s)\n", $2)); 1909 if(!bitlist) { 1910 yyerror("could not parse tags, (define-tag them first)"); 1911 free($2); 1912 } 1913 if(bitlist) { 1914 if(!cfg_strbytelist_insert( 1915 &cfg_parser->cfg->local_zone_tags, 1916 $2, bitlist, len)) { 1917 yyerror("out of memory"); 1918 free($2); 1919 } 1920 } 1921 } 1922 ; 1923 server_access_control_tag: VAR_ACCESS_CONTROL_TAG STRING_ARG STRING_ARG 1924 { 1925 size_t len = 0; 1926 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3, 1927 &len); 1928 free($3); 1929 OUTYY(("P(server_access_control_tag:%s)\n", $2)); 1930 if(!bitlist) { 1931 yyerror("could not parse tags, (define-tag them first)"); 1932 free($2); 1933 } 1934 if(bitlist) { 1935 if(!cfg_strbytelist_insert( 1936 &cfg_parser->cfg->acl_tags, 1937 $2, bitlist, len)) { 1938 yyerror("out of memory"); 1939 free($2); 1940 } 1941 } 1942 } 1943 ; 1944 server_access_control_tag_action: VAR_ACCESS_CONTROL_TAG_ACTION STRING_ARG STRING_ARG STRING_ARG 1945 { 1946 OUTYY(("P(server_access_control_tag_action:%s %s %s)\n", $2, $3, $4)); 1947 if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_actions, 1948 $2, $3, $4)) { 1949 yyerror("out of memory"); 1950 free($2); 1951 free($3); 1952 free($4); 1953 } 1954 } 1955 ; 1956 server_access_control_tag_data: VAR_ACCESS_CONTROL_TAG_DATA STRING_ARG STRING_ARG STRING_ARG 1957 { 1958 OUTYY(("P(server_access_control_tag_data:%s %s %s)\n", $2, $3, $4)); 1959 if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_datas, 1960 $2, $3, $4)) { 1961 yyerror("out of memory"); 1962 free($2); 1963 free($3); 1964 free($4); 1965 } 1966 } 1967 ; 1968 server_local_zone_override: VAR_LOCAL_ZONE_OVERRIDE STRING_ARG STRING_ARG STRING_ARG 1969 { 1970 OUTYY(("P(server_local_zone_override:%s %s %s)\n", $2, $3, $4)); 1971 if(!cfg_str3list_insert(&cfg_parser->cfg->local_zone_overrides, 1972 $2, $3, $4)) { 1973 yyerror("out of memory"); 1974 free($2); 1975 free($3); 1976 free($4); 1977 } 1978 } 1979 ; 1980 server_access_control_view: VAR_ACCESS_CONTROL_VIEW STRING_ARG STRING_ARG 1981 { 1982 OUTYY(("P(server_access_control_view:%s %s)\n", $2, $3)); 1983 if(!cfg_str2list_insert(&cfg_parser->cfg->acl_view, 1984 $2, $3)) { 1985 yyerror("out of memory"); 1986 } 1987 } 1988 ; 1989 server_response_ip_tag: VAR_RESPONSE_IP_TAG STRING_ARG STRING_ARG 1990 { 1991 size_t len = 0; 1992 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3, 1993 &len); 1994 free($3); 1995 OUTYY(("P(response_ip_tag:%s)\n", $2)); 1996 if(!bitlist) { 1997 yyerror("could not parse tags, (define-tag them first)"); 1998 free($2); 1999 } 2000 if(bitlist) { 2001 if(!cfg_strbytelist_insert( 2002 &cfg_parser->cfg->respip_tags, 2003 $2, bitlist, len)) { 2004 yyerror("out of memory"); 2005 free($2); 2006 } 2007 } 2008 } 2009 ; 2010 server_ip_ratelimit: VAR_IP_RATELIMIT STRING_ARG 2011 { 2012 OUTYY(("P(server_ip_ratelimit:%s)\n", $2)); 2013 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2014 yyerror("number expected"); 2015 else cfg_parser->cfg->ip_ratelimit = atoi($2); 2016 free($2); 2017 } 2018 ; 2019 2020 server_ratelimit: VAR_RATELIMIT STRING_ARG 2021 { 2022 OUTYY(("P(server_ratelimit:%s)\n", $2)); 2023 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2024 yyerror("number expected"); 2025 else cfg_parser->cfg->ratelimit = atoi($2); 2026 free($2); 2027 } 2028 ; 2029 server_ip_ratelimit_size: VAR_IP_RATELIMIT_SIZE STRING_ARG 2030 { 2031 OUTYY(("P(server_ip_ratelimit_size:%s)\n", $2)); 2032 if(!cfg_parse_memsize($2, &cfg_parser->cfg->ip_ratelimit_size)) 2033 yyerror("memory size expected"); 2034 free($2); 2035 } 2036 ; 2037 server_ratelimit_size: VAR_RATELIMIT_SIZE STRING_ARG 2038 { 2039 OUTYY(("P(server_ratelimit_size:%s)\n", $2)); 2040 if(!cfg_parse_memsize($2, &cfg_parser->cfg->ratelimit_size)) 2041 yyerror("memory size expected"); 2042 free($2); 2043 } 2044 ; 2045 server_ip_ratelimit_slabs: VAR_IP_RATELIMIT_SLABS STRING_ARG 2046 { 2047 OUTYY(("P(server_ip_ratelimit_slabs:%s)\n", $2)); 2048 if(atoi($2) == 0) 2049 yyerror("number expected"); 2050 else { 2051 cfg_parser->cfg->ip_ratelimit_slabs = atoi($2); 2052 if(!is_pow2(cfg_parser->cfg->ip_ratelimit_slabs)) 2053 yyerror("must be a power of 2"); 2054 } 2055 free($2); 2056 } 2057 ; 2058 server_ratelimit_slabs: VAR_RATELIMIT_SLABS STRING_ARG 2059 { 2060 OUTYY(("P(server_ratelimit_slabs:%s)\n", $2)); 2061 if(atoi($2) == 0) 2062 yyerror("number expected"); 2063 else { 2064 cfg_parser->cfg->ratelimit_slabs = atoi($2); 2065 if(!is_pow2(cfg_parser->cfg->ratelimit_slabs)) 2066 yyerror("must be a power of 2"); 2067 } 2068 free($2); 2069 } 2070 ; 2071 server_ratelimit_for_domain: VAR_RATELIMIT_FOR_DOMAIN STRING_ARG STRING_ARG 2072 { 2073 OUTYY(("P(server_ratelimit_for_domain:%s %s)\n", $2, $3)); 2074 if(atoi($3) == 0 && strcmp($3, "0") != 0) { 2075 yyerror("number expected"); 2076 free($2); 2077 free($3); 2078 } else { 2079 if(!cfg_str2list_insert(&cfg_parser->cfg-> 2080 ratelimit_for_domain, $2, $3)) 2081 fatal_exit("out of memory adding " 2082 "ratelimit-for-domain"); 2083 } 2084 } 2085 ; 2086 server_ratelimit_below_domain: VAR_RATELIMIT_BELOW_DOMAIN STRING_ARG STRING_ARG 2087 { 2088 OUTYY(("P(server_ratelimit_below_domain:%s %s)\n", $2, $3)); 2089 if(atoi($3) == 0 && strcmp($3, "0") != 0) { 2090 yyerror("number expected"); 2091 free($2); 2092 free($3); 2093 } else { 2094 if(!cfg_str2list_insert(&cfg_parser->cfg-> 2095 ratelimit_below_domain, $2, $3)) 2096 fatal_exit("out of memory adding " 2097 "ratelimit-below-domain"); 2098 } 2099 } 2100 ; 2101 server_ip_ratelimit_factor: VAR_IP_RATELIMIT_FACTOR STRING_ARG 2102 { 2103 OUTYY(("P(server_ip_ratelimit_factor:%s)\n", $2)); 2104 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2105 yyerror("number expected"); 2106 else cfg_parser->cfg->ip_ratelimit_factor = atoi($2); 2107 free($2); 2108 } 2109 ; 2110 server_ratelimit_factor: VAR_RATELIMIT_FACTOR STRING_ARG 2111 { 2112 OUTYY(("P(server_ratelimit_factor:%s)\n", $2)); 2113 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2114 yyerror("number expected"); 2115 else cfg_parser->cfg->ratelimit_factor = atoi($2); 2116 free($2); 2117 } 2118 ; 2119 server_low_rtt: VAR_LOW_RTT STRING_ARG 2120 { 2121 OUTYY(("P(low-rtt option is deprecated, use fast-server-num instead)\n")); 2122 free($2); 2123 } 2124 ; 2125 server_fast_server_num: VAR_FAST_SERVER_NUM STRING_ARG 2126 { 2127 OUTYY(("P(server_fast_server_num:%s)\n", $2)); 2128 if(atoi($2) <= 0) 2129 yyerror("number expected"); 2130 else cfg_parser->cfg->fast_server_num = atoi($2); 2131 free($2); 2132 } 2133 ; 2134 server_fast_server_permil: VAR_FAST_SERVER_PERMIL STRING_ARG 2135 { 2136 OUTYY(("P(server_fast_server_permil:%s)\n", $2)); 2137 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2138 yyerror("number expected"); 2139 else cfg_parser->cfg->fast_server_permil = atoi($2); 2140 free($2); 2141 } 2142 ; 2143 server_qname_minimisation: VAR_QNAME_MINIMISATION STRING_ARG 2144 { 2145 OUTYY(("P(server_qname_minimisation:%s)\n", $2)); 2146 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2147 yyerror("expected yes or no."); 2148 else cfg_parser->cfg->qname_minimisation = 2149 (strcmp($2, "yes")==0); 2150 free($2); 2151 } 2152 ; 2153 server_qname_minimisation_strict: VAR_QNAME_MINIMISATION_STRICT STRING_ARG 2154 { 2155 OUTYY(("P(server_qname_minimisation_strict:%s)\n", $2)); 2156 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2157 yyerror("expected yes or no."); 2158 else cfg_parser->cfg->qname_minimisation_strict = 2159 (strcmp($2, "yes")==0); 2160 free($2); 2161 } 2162 ; 2163 server_ipsecmod_enabled: VAR_IPSECMOD_ENABLED STRING_ARG 2164 { 2165 #ifdef USE_IPSECMOD 2166 OUTYY(("P(server_ipsecmod_enabled:%s)\n", $2)); 2167 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2168 yyerror("expected yes or no."); 2169 else cfg_parser->cfg->ipsecmod_enabled = (strcmp($2, "yes")==0); 2170 #else 2171 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2172 #endif 2173 free($2); 2174 } 2175 ; 2176 server_ipsecmod_ignore_bogus: VAR_IPSECMOD_IGNORE_BOGUS STRING_ARG 2177 { 2178 #ifdef USE_IPSECMOD 2179 OUTYY(("P(server_ipsecmod_ignore_bogus:%s)\n", $2)); 2180 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2181 yyerror("expected yes or no."); 2182 else cfg_parser->cfg->ipsecmod_ignore_bogus = (strcmp($2, "yes")==0); 2183 #else 2184 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2185 #endif 2186 free($2); 2187 } 2188 ; 2189 server_ipsecmod_hook: VAR_IPSECMOD_HOOK STRING_ARG 2190 { 2191 #ifdef USE_IPSECMOD 2192 OUTYY(("P(server_ipsecmod_hook:%s)\n", $2)); 2193 free(cfg_parser->cfg->ipsecmod_hook); 2194 cfg_parser->cfg->ipsecmod_hook = $2; 2195 #else 2196 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2197 free($2); 2198 #endif 2199 } 2200 ; 2201 server_ipsecmod_max_ttl: VAR_IPSECMOD_MAX_TTL STRING_ARG 2202 { 2203 #ifdef USE_IPSECMOD 2204 OUTYY(("P(server_ipsecmod_max_ttl:%s)\n", $2)); 2205 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2206 yyerror("number expected"); 2207 else cfg_parser->cfg->ipsecmod_max_ttl = atoi($2); 2208 free($2); 2209 #else 2210 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2211 free($2); 2212 #endif 2213 } 2214 ; 2215 server_ipsecmod_whitelist: VAR_IPSECMOD_WHITELIST STRING_ARG 2216 { 2217 #ifdef USE_IPSECMOD 2218 OUTYY(("P(server_ipsecmod_whitelist:%s)\n", $2)); 2219 if(!cfg_strlist_insert(&cfg_parser->cfg->ipsecmod_whitelist, $2)) 2220 yyerror("out of memory"); 2221 #else 2222 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2223 free($2); 2224 #endif 2225 } 2226 ; 2227 server_ipsecmod_strict: VAR_IPSECMOD_STRICT STRING_ARG 2228 { 2229 #ifdef USE_IPSECMOD 2230 OUTYY(("P(server_ipsecmod_strict:%s)\n", $2)); 2231 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2232 yyerror("expected yes or no."); 2233 else cfg_parser->cfg->ipsecmod_strict = (strcmp($2, "yes")==0); 2234 free($2); 2235 #else 2236 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2237 free($2); 2238 #endif 2239 } 2240 ; 2241 stub_name: VAR_NAME STRING_ARG 2242 { 2243 OUTYY(("P(name:%s)\n", $2)); 2244 if(cfg_parser->cfg->stubs->name) 2245 yyerror("stub name override, there must be one name " 2246 "for one stub-zone"); 2247 free(cfg_parser->cfg->stubs->name); 2248 cfg_parser->cfg->stubs->name = $2; 2249 } 2250 ; 2251 stub_host: VAR_STUB_HOST STRING_ARG 2252 { 2253 OUTYY(("P(stub-host:%s)\n", $2)); 2254 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, $2)) 2255 yyerror("out of memory"); 2256 } 2257 ; 2258 stub_addr: VAR_STUB_ADDR STRING_ARG 2259 { 2260 OUTYY(("P(stub-addr:%s)\n", $2)); 2261 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, $2)) 2262 yyerror("out of memory"); 2263 } 2264 ; 2265 stub_first: VAR_STUB_FIRST STRING_ARG 2266 { 2267 OUTYY(("P(stub-first:%s)\n", $2)); 2268 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2269 yyerror("expected yes or no."); 2270 else cfg_parser->cfg->stubs->isfirst=(strcmp($2, "yes")==0); 2271 free($2); 2272 } 2273 ; 2274 stub_no_cache: VAR_STUB_NO_CACHE STRING_ARG 2275 { 2276 OUTYY(("P(stub-no-cache:%s)\n", $2)); 2277 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2278 yyerror("expected yes or no."); 2279 else cfg_parser->cfg->stubs->no_cache=(strcmp($2, "yes")==0); 2280 free($2); 2281 } 2282 ; 2283 stub_ssl_upstream: VAR_STUB_SSL_UPSTREAM STRING_ARG 2284 { 2285 OUTYY(("P(stub-ssl-upstream:%s)\n", $2)); 2286 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2287 yyerror("expected yes or no."); 2288 else cfg_parser->cfg->stubs->ssl_upstream = 2289 (strcmp($2, "yes")==0); 2290 free($2); 2291 } 2292 ; 2293 stub_prime: VAR_STUB_PRIME STRING_ARG 2294 { 2295 OUTYY(("P(stub-prime:%s)\n", $2)); 2296 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2297 yyerror("expected yes or no."); 2298 else cfg_parser->cfg->stubs->isprime = 2299 (strcmp($2, "yes")==0); 2300 free($2); 2301 } 2302 ; 2303 forward_name: VAR_NAME STRING_ARG 2304 { 2305 OUTYY(("P(name:%s)\n", $2)); 2306 if(cfg_parser->cfg->forwards->name) 2307 yyerror("forward name override, there must be one " 2308 "name for one forward-zone"); 2309 free(cfg_parser->cfg->forwards->name); 2310 cfg_parser->cfg->forwards->name = $2; 2311 } 2312 ; 2313 forward_host: VAR_FORWARD_HOST STRING_ARG 2314 { 2315 OUTYY(("P(forward-host:%s)\n", $2)); 2316 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, $2)) 2317 yyerror("out of memory"); 2318 } 2319 ; 2320 forward_addr: VAR_FORWARD_ADDR STRING_ARG 2321 { 2322 OUTYY(("P(forward-addr:%s)\n", $2)); 2323 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, $2)) 2324 yyerror("out of memory"); 2325 } 2326 ; 2327 forward_first: VAR_FORWARD_FIRST STRING_ARG 2328 { 2329 OUTYY(("P(forward-first:%s)\n", $2)); 2330 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2331 yyerror("expected yes or no."); 2332 else cfg_parser->cfg->forwards->isfirst=(strcmp($2, "yes")==0); 2333 free($2); 2334 } 2335 ; 2336 forward_no_cache: VAR_FORWARD_NO_CACHE STRING_ARG 2337 { 2338 OUTYY(("P(forward-no-cache:%s)\n", $2)); 2339 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2340 yyerror("expected yes or no."); 2341 else cfg_parser->cfg->forwards->no_cache=(strcmp($2, "yes")==0); 2342 free($2); 2343 } 2344 ; 2345 forward_ssl_upstream: VAR_FORWARD_SSL_UPSTREAM STRING_ARG 2346 { 2347 OUTYY(("P(forward-ssl-upstream:%s)\n", $2)); 2348 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2349 yyerror("expected yes or no."); 2350 else cfg_parser->cfg->forwards->ssl_upstream = 2351 (strcmp($2, "yes")==0); 2352 free($2); 2353 } 2354 ; 2355 auth_name: VAR_NAME STRING_ARG 2356 { 2357 OUTYY(("P(name:%s)\n", $2)); 2358 if(cfg_parser->cfg->auths->name) 2359 yyerror("auth name override, there must be one name " 2360 "for one auth-zone"); 2361 free(cfg_parser->cfg->auths->name); 2362 cfg_parser->cfg->auths->name = $2; 2363 } 2364 ; 2365 auth_zonefile: VAR_ZONEFILE STRING_ARG 2366 { 2367 OUTYY(("P(zonefile:%s)\n", $2)); 2368 free(cfg_parser->cfg->auths->zonefile); 2369 cfg_parser->cfg->auths->zonefile = $2; 2370 } 2371 ; 2372 auth_master: VAR_MASTER STRING_ARG 2373 { 2374 OUTYY(("P(master:%s)\n", $2)); 2375 if(!cfg_strlist_insert(&cfg_parser->cfg->auths->masters, $2)) 2376 yyerror("out of memory"); 2377 } 2378 ; 2379 auth_url: VAR_URL STRING_ARG 2380 { 2381 OUTYY(("P(url:%s)\n", $2)); 2382 if(!cfg_strlist_insert(&cfg_parser->cfg->auths->urls, $2)) 2383 yyerror("out of memory"); 2384 } 2385 ; 2386 auth_allow_notify: VAR_ALLOW_NOTIFY STRING_ARG 2387 { 2388 OUTYY(("P(allow-notify:%s)\n", $2)); 2389 if(!cfg_strlist_insert(&cfg_parser->cfg->auths->allow_notify, 2390 $2)) 2391 yyerror("out of memory"); 2392 } 2393 ; 2394 auth_for_downstream: VAR_FOR_DOWNSTREAM STRING_ARG 2395 { 2396 OUTYY(("P(for-downstream:%s)\n", $2)); 2397 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2398 yyerror("expected yes or no."); 2399 else cfg_parser->cfg->auths->for_downstream = 2400 (strcmp($2, "yes")==0); 2401 free($2); 2402 } 2403 ; 2404 auth_for_upstream: VAR_FOR_UPSTREAM STRING_ARG 2405 { 2406 OUTYY(("P(for-upstream:%s)\n", $2)); 2407 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2408 yyerror("expected yes or no."); 2409 else cfg_parser->cfg->auths->for_upstream = 2410 (strcmp($2, "yes")==0); 2411 free($2); 2412 } 2413 ; 2414 auth_fallback_enabled: VAR_FALLBACK_ENABLED STRING_ARG 2415 { 2416 OUTYY(("P(fallback-enabled:%s)\n", $2)); 2417 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2418 yyerror("expected yes or no."); 2419 else cfg_parser->cfg->auths->fallback_enabled = 2420 (strcmp($2, "yes")==0); 2421 free($2); 2422 } 2423 ; 2424 view_name: VAR_NAME STRING_ARG 2425 { 2426 OUTYY(("P(name:%s)\n", $2)); 2427 if(cfg_parser->cfg->views->name) 2428 yyerror("view name override, there must be one " 2429 "name for one view"); 2430 free(cfg_parser->cfg->views->name); 2431 cfg_parser->cfg->views->name = $2; 2432 } 2433 ; 2434 view_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG 2435 { 2436 OUTYY(("P(view_local_zone:%s %s)\n", $2, $3)); 2437 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && 2438 strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && 2439 strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 2440 && strcmp($3, "typetransparent")!=0 2441 && strcmp($3, "always_transparent")!=0 2442 && strcmp($3, "always_refuse")!=0 2443 && strcmp($3, "always_nxdomain")!=0 2444 && strcmp($3, "noview")!=0 2445 && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0) { 2446 yyerror("local-zone type: expected static, deny, " 2447 "refuse, redirect, transparent, " 2448 "typetransparent, inform, inform_deny, " 2449 "always_transparent, always_refuse, " 2450 "always_nxdomain, noview or nodefault"); 2451 free($2); 2452 free($3); 2453 } else if(strcmp($3, "nodefault")==0) { 2454 if(!cfg_strlist_insert(&cfg_parser->cfg->views-> 2455 local_zones_nodefault, $2)) 2456 fatal_exit("out of memory adding local-zone"); 2457 free($3); 2458 } else { 2459 if(!cfg_str2list_insert( 2460 &cfg_parser->cfg->views->local_zones, 2461 $2, $3)) 2462 fatal_exit("out of memory adding local-zone"); 2463 } 2464 } 2465 ; 2466 view_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG 2467 { 2468 OUTYY(("P(view_response_ip:%s %s)\n", $2, $3)); 2469 validate_respip_action($3); 2470 if(!cfg_str2list_insert( 2471 &cfg_parser->cfg->views->respip_actions, $2, $3)) 2472 fatal_exit("out of memory adding per-view " 2473 "response-ip action"); 2474 } 2475 ; 2476 view_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG 2477 { 2478 OUTYY(("P(view_response_ip_data:%s)\n", $2)); 2479 if(!cfg_str2list_insert( 2480 &cfg_parser->cfg->views->respip_data, $2, $3)) 2481 fatal_exit("out of memory adding response-ip-data"); 2482 } 2483 ; 2484 view_local_data: VAR_LOCAL_DATA STRING_ARG 2485 { 2486 OUTYY(("P(view_local_data:%s)\n", $2)); 2487 if(!cfg_strlist_insert(&cfg_parser->cfg->views->local_data, $2)) { 2488 fatal_exit("out of memory adding local-data"); 2489 } 2490 } 2491 ; 2492 view_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG 2493 { 2494 char* ptr; 2495 OUTYY(("P(view_local_data_ptr:%s)\n", $2)); 2496 ptr = cfg_ptr_reverse($2); 2497 free($2); 2498 if(ptr) { 2499 if(!cfg_strlist_insert(&cfg_parser->cfg->views-> 2500 local_data, ptr)) 2501 fatal_exit("out of memory adding local-data"); 2502 } else { 2503 yyerror("local-data-ptr could not be reversed"); 2504 } 2505 } 2506 ; 2507 view_first: VAR_VIEW_FIRST STRING_ARG 2508 { 2509 OUTYY(("P(view-first:%s)\n", $2)); 2510 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2511 yyerror("expected yes or no."); 2512 else cfg_parser->cfg->views->isfirst=(strcmp($2, "yes")==0); 2513 free($2); 2514 } 2515 ; 2516 rcstart: VAR_REMOTE_CONTROL 2517 { 2518 OUTYY(("\nP(remote-control:)\n")); 2519 } 2520 ; 2521 contents_rc: contents_rc content_rc 2522 | ; 2523 content_rc: rc_control_enable | rc_control_interface | rc_control_port | 2524 rc_server_key_file | rc_server_cert_file | rc_control_key_file | 2525 rc_control_cert_file | rc_control_use_cert 2526 ; 2527 rc_control_enable: VAR_CONTROL_ENABLE STRING_ARG 2528 { 2529 OUTYY(("P(control_enable:%s)\n", $2)); 2530 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2531 yyerror("expected yes or no."); 2532 else cfg_parser->cfg->remote_control_enable = 2533 (strcmp($2, "yes")==0); 2534 free($2); 2535 } 2536 ; 2537 rc_control_port: VAR_CONTROL_PORT STRING_ARG 2538 { 2539 OUTYY(("P(control_port:%s)\n", $2)); 2540 if(atoi($2) == 0) 2541 yyerror("control port number expected"); 2542 else cfg_parser->cfg->control_port = atoi($2); 2543 free($2); 2544 } 2545 ; 2546 rc_control_interface: VAR_CONTROL_INTERFACE STRING_ARG 2547 { 2548 OUTYY(("P(control_interface:%s)\n", $2)); 2549 if(!cfg_strlist_append(&cfg_parser->cfg->control_ifs, $2)) 2550 yyerror("out of memory"); 2551 } 2552 ; 2553 rc_control_use_cert: VAR_CONTROL_USE_CERT STRING_ARG 2554 { 2555 OUTYY(("P(control_use_cert:%s)\n", $2)); 2556 cfg_parser->cfg->control_use_cert = (strcmp($2, "yes")==0); 2557 free($2); 2558 } 2559 ; 2560 rc_server_key_file: VAR_SERVER_KEY_FILE STRING_ARG 2561 { 2562 OUTYY(("P(rc_server_key_file:%s)\n", $2)); 2563 free(cfg_parser->cfg->server_key_file); 2564 cfg_parser->cfg->server_key_file = $2; 2565 } 2566 ; 2567 rc_server_cert_file: VAR_SERVER_CERT_FILE STRING_ARG 2568 { 2569 OUTYY(("P(rc_server_cert_file:%s)\n", $2)); 2570 free(cfg_parser->cfg->server_cert_file); 2571 cfg_parser->cfg->server_cert_file = $2; 2572 } 2573 ; 2574 rc_control_key_file: VAR_CONTROL_KEY_FILE STRING_ARG 2575 { 2576 OUTYY(("P(rc_control_key_file:%s)\n", $2)); 2577 free(cfg_parser->cfg->control_key_file); 2578 cfg_parser->cfg->control_key_file = $2; 2579 } 2580 ; 2581 rc_control_cert_file: VAR_CONTROL_CERT_FILE STRING_ARG 2582 { 2583 OUTYY(("P(rc_control_cert_file:%s)\n", $2)); 2584 free(cfg_parser->cfg->control_cert_file); 2585 cfg_parser->cfg->control_cert_file = $2; 2586 } 2587 ; 2588 dtstart: VAR_DNSTAP 2589 { 2590 OUTYY(("\nP(dnstap:)\n")); 2591 } 2592 ; 2593 contents_dt: contents_dt content_dt 2594 | ; 2595 content_dt: dt_dnstap_enable | dt_dnstap_socket_path | 2596 dt_dnstap_send_identity | dt_dnstap_send_version | 2597 dt_dnstap_identity | dt_dnstap_version | 2598 dt_dnstap_log_resolver_query_messages | 2599 dt_dnstap_log_resolver_response_messages | 2600 dt_dnstap_log_client_query_messages | 2601 dt_dnstap_log_client_response_messages | 2602 dt_dnstap_log_forwarder_query_messages | 2603 dt_dnstap_log_forwarder_response_messages 2604 ; 2605 dt_dnstap_enable: VAR_DNSTAP_ENABLE STRING_ARG 2606 { 2607 OUTYY(("P(dt_dnstap_enable:%s)\n", $2)); 2608 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2609 yyerror("expected yes or no."); 2610 else cfg_parser->cfg->dnstap = (strcmp($2, "yes")==0); 2611 free($2); 2612 } 2613 ; 2614 dt_dnstap_socket_path: VAR_DNSTAP_SOCKET_PATH STRING_ARG 2615 { 2616 OUTYY(("P(dt_dnstap_socket_path:%s)\n", $2)); 2617 free(cfg_parser->cfg->dnstap_socket_path); 2618 cfg_parser->cfg->dnstap_socket_path = $2; 2619 } 2620 ; 2621 dt_dnstap_send_identity: VAR_DNSTAP_SEND_IDENTITY STRING_ARG 2622 { 2623 OUTYY(("P(dt_dnstap_send_identity:%s)\n", $2)); 2624 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2625 yyerror("expected yes or no."); 2626 else cfg_parser->cfg->dnstap_send_identity = (strcmp($2, "yes")==0); 2627 free($2); 2628 } 2629 ; 2630 dt_dnstap_send_version: VAR_DNSTAP_SEND_VERSION STRING_ARG 2631 { 2632 OUTYY(("P(dt_dnstap_send_version:%s)\n", $2)); 2633 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2634 yyerror("expected yes or no."); 2635 else cfg_parser->cfg->dnstap_send_version = (strcmp($2, "yes")==0); 2636 free($2); 2637 } 2638 ; 2639 dt_dnstap_identity: VAR_DNSTAP_IDENTITY STRING_ARG 2640 { 2641 OUTYY(("P(dt_dnstap_identity:%s)\n", $2)); 2642 free(cfg_parser->cfg->dnstap_identity); 2643 cfg_parser->cfg->dnstap_identity = $2; 2644 } 2645 ; 2646 dt_dnstap_version: VAR_DNSTAP_VERSION STRING_ARG 2647 { 2648 OUTYY(("P(dt_dnstap_version:%s)\n", $2)); 2649 free(cfg_parser->cfg->dnstap_version); 2650 cfg_parser->cfg->dnstap_version = $2; 2651 } 2652 ; 2653 dt_dnstap_log_resolver_query_messages: VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES STRING_ARG 2654 { 2655 OUTYY(("P(dt_dnstap_log_resolver_query_messages:%s)\n", $2)); 2656 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2657 yyerror("expected yes or no."); 2658 else cfg_parser->cfg->dnstap_log_resolver_query_messages = 2659 (strcmp($2, "yes")==0); 2660 free($2); 2661 } 2662 ; 2663 dt_dnstap_log_resolver_response_messages: VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES STRING_ARG 2664 { 2665 OUTYY(("P(dt_dnstap_log_resolver_response_messages:%s)\n", $2)); 2666 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2667 yyerror("expected yes or no."); 2668 else cfg_parser->cfg->dnstap_log_resolver_response_messages = 2669 (strcmp($2, "yes")==0); 2670 free($2); 2671 } 2672 ; 2673 dt_dnstap_log_client_query_messages: VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES STRING_ARG 2674 { 2675 OUTYY(("P(dt_dnstap_log_client_query_messages:%s)\n", $2)); 2676 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2677 yyerror("expected yes or no."); 2678 else cfg_parser->cfg->dnstap_log_client_query_messages = 2679 (strcmp($2, "yes")==0); 2680 free($2); 2681 } 2682 ; 2683 dt_dnstap_log_client_response_messages: VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES STRING_ARG 2684 { 2685 OUTYY(("P(dt_dnstap_log_client_response_messages:%s)\n", $2)); 2686 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2687 yyerror("expected yes or no."); 2688 else cfg_parser->cfg->dnstap_log_client_response_messages = 2689 (strcmp($2, "yes")==0); 2690 free($2); 2691 } 2692 ; 2693 dt_dnstap_log_forwarder_query_messages: VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES STRING_ARG 2694 { 2695 OUTYY(("P(dt_dnstap_log_forwarder_query_messages:%s)\n", $2)); 2696 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2697 yyerror("expected yes or no."); 2698 else cfg_parser->cfg->dnstap_log_forwarder_query_messages = 2699 (strcmp($2, "yes")==0); 2700 free($2); 2701 } 2702 ; 2703 dt_dnstap_log_forwarder_response_messages: VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES STRING_ARG 2704 { 2705 OUTYY(("P(dt_dnstap_log_forwarder_response_messages:%s)\n", $2)); 2706 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2707 yyerror("expected yes or no."); 2708 else cfg_parser->cfg->dnstap_log_forwarder_response_messages = 2709 (strcmp($2, "yes")==0); 2710 free($2); 2711 } 2712 ; 2713 pythonstart: VAR_PYTHON 2714 { 2715 OUTYY(("\nP(python:)\n")); 2716 } 2717 ; 2718 contents_py: contents_py content_py 2719 | ; 2720 content_py: py_script 2721 ; 2722 py_script: VAR_PYTHON_SCRIPT STRING_ARG 2723 { 2724 OUTYY(("P(python-script:%s)\n", $2)); 2725 free(cfg_parser->cfg->python_script); 2726 cfg_parser->cfg->python_script = $2; 2727 } 2728 server_disable_dnssec_lame_check: VAR_DISABLE_DNSSEC_LAME_CHECK STRING_ARG 2729 { 2730 OUTYY(("P(disable_dnssec_lame_check:%s)\n", $2)); 2731 if (strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2732 yyerror("expected yes or no."); 2733 else cfg_parser->cfg->disable_dnssec_lame_check = 2734 (strcmp($2, "yes")==0); 2735 free($2); 2736 } 2737 ; 2738 server_log_identity: VAR_LOG_IDENTITY STRING_ARG 2739 { 2740 OUTYY(("P(server_log_identity:%s)\n", $2)); 2741 free(cfg_parser->cfg->log_identity); 2742 cfg_parser->cfg->log_identity = $2; 2743 } 2744 ; 2745 server_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG 2746 { 2747 OUTYY(("P(server_response_ip:%s %s)\n", $2, $3)); 2748 validate_respip_action($3); 2749 if(!cfg_str2list_insert(&cfg_parser->cfg->respip_actions, 2750 $2, $3)) 2751 fatal_exit("out of memory adding response-ip"); 2752 } 2753 ; 2754 server_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG 2755 { 2756 OUTYY(("P(server_response_ip_data:%s)\n", $2)); 2757 if(!cfg_str2list_insert(&cfg_parser->cfg->respip_data, 2758 $2, $3)) 2759 fatal_exit("out of memory adding response-ip-data"); 2760 } 2761 ; 2762 dnscstart: VAR_DNSCRYPT 2763 { 2764 OUTYY(("\nP(dnscrypt:)\n")); 2765 } 2766 ; 2767 contents_dnsc: contents_dnsc content_dnsc 2768 | ; 2769 content_dnsc: 2770 dnsc_dnscrypt_enable | dnsc_dnscrypt_port | dnsc_dnscrypt_provider | 2771 dnsc_dnscrypt_secret_key | dnsc_dnscrypt_provider_cert | 2772 dnsc_dnscrypt_provider_cert_rotated | 2773 dnsc_dnscrypt_shared_secret_cache_size | 2774 dnsc_dnscrypt_shared_secret_cache_slabs | 2775 dnsc_dnscrypt_nonce_cache_size | 2776 dnsc_dnscrypt_nonce_cache_slabs 2777 ; 2778 dnsc_dnscrypt_enable: VAR_DNSCRYPT_ENABLE STRING_ARG 2779 { 2780 OUTYY(("P(dnsc_dnscrypt_enable:%s)\n", $2)); 2781 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2782 yyerror("expected yes or no."); 2783 else cfg_parser->cfg->dnscrypt = (strcmp($2, "yes")==0); 2784 free($2); 2785 } 2786 ; 2787 2788 dnsc_dnscrypt_port: VAR_DNSCRYPT_PORT STRING_ARG 2789 { 2790 OUTYY(("P(dnsc_dnscrypt_port:%s)\n", $2)); 2791 if(atoi($2) == 0) 2792 yyerror("port number expected"); 2793 else cfg_parser->cfg->dnscrypt_port = atoi($2); 2794 free($2); 2795 } 2796 ; 2797 dnsc_dnscrypt_provider: VAR_DNSCRYPT_PROVIDER STRING_ARG 2798 { 2799 OUTYY(("P(dnsc_dnscrypt_provider:%s)\n", $2)); 2800 free(cfg_parser->cfg->dnscrypt_provider); 2801 cfg_parser->cfg->dnscrypt_provider = $2; 2802 } 2803 ; 2804 dnsc_dnscrypt_provider_cert: VAR_DNSCRYPT_PROVIDER_CERT STRING_ARG 2805 { 2806 OUTYY(("P(dnsc_dnscrypt_provider_cert:%s)\n", $2)); 2807 if(cfg_strlist_find(cfg_parser->cfg->dnscrypt_provider_cert, $2)) 2808 log_warn("dnscrypt-provider-cert %s is a duplicate", $2); 2809 if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert, $2)) 2810 fatal_exit("out of memory adding dnscrypt-provider-cert"); 2811 } 2812 ; 2813 dnsc_dnscrypt_provider_cert_rotated: VAR_DNSCRYPT_PROVIDER_CERT_ROTATED STRING_ARG 2814 { 2815 OUTYY(("P(dnsc_dnscrypt_provider_cert_rotated:%s)\n", $2)); 2816 if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert_rotated, $2)) 2817 fatal_exit("out of memory adding dnscrypt-provider-cert-rotated"); 2818 } 2819 ; 2820 dnsc_dnscrypt_secret_key: VAR_DNSCRYPT_SECRET_KEY STRING_ARG 2821 { 2822 OUTYY(("P(dnsc_dnscrypt_secret_key:%s)\n", $2)); 2823 if(cfg_strlist_find(cfg_parser->cfg->dnscrypt_secret_key, $2)) 2824 log_warn("dnscrypt-secret-key: %s is a duplicate", $2); 2825 if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_secret_key, $2)) 2826 fatal_exit("out of memory adding dnscrypt-secret-key"); 2827 } 2828 ; 2829 dnsc_dnscrypt_shared_secret_cache_size: VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE STRING_ARG 2830 { 2831 OUTYY(("P(dnscrypt_shared_secret_cache_size:%s)\n", $2)); 2832 if(!cfg_parse_memsize($2, &cfg_parser->cfg->dnscrypt_shared_secret_cache_size)) 2833 yyerror("memory size expected"); 2834 free($2); 2835 } 2836 ; 2837 dnsc_dnscrypt_shared_secret_cache_slabs: VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS STRING_ARG 2838 { 2839 OUTYY(("P(dnscrypt_shared_secret_cache_slabs:%s)\n", $2)); 2840 if(atoi($2) == 0) 2841 yyerror("number expected"); 2842 else { 2843 cfg_parser->cfg->dnscrypt_shared_secret_cache_slabs = atoi($2); 2844 if(!is_pow2(cfg_parser->cfg->dnscrypt_shared_secret_cache_slabs)) 2845 yyerror("must be a power of 2"); 2846 } 2847 free($2); 2848 } 2849 ; 2850 dnsc_dnscrypt_nonce_cache_size: VAR_DNSCRYPT_NONCE_CACHE_SIZE STRING_ARG 2851 { 2852 OUTYY(("P(dnscrypt_nonce_cache_size:%s)\n", $2)); 2853 if(!cfg_parse_memsize($2, &cfg_parser->cfg->dnscrypt_nonce_cache_size)) 2854 yyerror("memory size expected"); 2855 free($2); 2856 } 2857 ; 2858 dnsc_dnscrypt_nonce_cache_slabs: VAR_DNSCRYPT_NONCE_CACHE_SLABS STRING_ARG 2859 { 2860 OUTYY(("P(dnscrypt_nonce_cache_slabs:%s)\n", $2)); 2861 if(atoi($2) == 0) 2862 yyerror("number expected"); 2863 else { 2864 cfg_parser->cfg->dnscrypt_nonce_cache_slabs = atoi($2); 2865 if(!is_pow2(cfg_parser->cfg->dnscrypt_nonce_cache_slabs)) 2866 yyerror("must be a power of 2"); 2867 } 2868 free($2); 2869 } 2870 ; 2871 cachedbstart: VAR_CACHEDB 2872 { 2873 OUTYY(("\nP(cachedb:)\n")); 2874 } 2875 ; 2876 contents_cachedb: contents_cachedb content_cachedb 2877 | ; 2878 content_cachedb: cachedb_backend_name | cachedb_secret_seed | 2879 redis_server_host | redis_server_port | redis_timeout 2880 ; 2881 cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG 2882 { 2883 #ifdef USE_CACHEDB 2884 OUTYY(("P(backend:%s)\n", $2)); 2885 if(cfg_parser->cfg->cachedb_backend) 2886 yyerror("cachedb backend override, there must be one " 2887 "backend"); 2888 free(cfg_parser->cfg->cachedb_backend); 2889 cfg_parser->cfg->cachedb_backend = $2; 2890 #else 2891 OUTYY(("P(Compiled without cachedb, ignoring)\n")); 2892 free($2); 2893 #endif 2894 } 2895 ; 2896 cachedb_secret_seed: VAR_CACHEDB_SECRETSEED STRING_ARG 2897 { 2898 #ifdef USE_CACHEDB 2899 OUTYY(("P(secret-seed:%s)\n", $2)); 2900 if(cfg_parser->cfg->cachedb_secret) 2901 yyerror("cachedb secret-seed override, there must be " 2902 "only one secret"); 2903 free(cfg_parser->cfg->cachedb_secret); 2904 cfg_parser->cfg->cachedb_secret = $2; 2905 #else 2906 OUTYY(("P(Compiled without cachedb, ignoring)\n")); 2907 free($2); 2908 #endif 2909 } 2910 ; 2911 redis_server_host: VAR_CACHEDB_REDISHOST STRING_ARG 2912 { 2913 #if defined(USE_CACHEDB) && defined(USE_REDIS) 2914 OUTYY(("P(redis_server_host:%s)\n", $2)); 2915 free(cfg_parser->cfg->redis_server_host); 2916 cfg_parser->cfg->redis_server_host = $2; 2917 #else 2918 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 2919 free($2); 2920 #endif 2921 } 2922 ; 2923 redis_server_port: VAR_CACHEDB_REDISPORT STRING_ARG 2924 { 2925 #if defined(USE_CACHEDB) && defined(USE_REDIS) 2926 int port; 2927 OUTYY(("P(redis_server_port:%s)\n", $2)); 2928 port = atoi($2); 2929 if(port == 0 || port < 0 || port > 65535) 2930 yyerror("valid redis server port number expected"); 2931 else cfg_parser->cfg->redis_server_port = port; 2932 #else 2933 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 2934 #endif 2935 free($2); 2936 } 2937 ; 2938 redis_timeout: VAR_CACHEDB_REDISTIMEOUT STRING_ARG 2939 { 2940 #if defined(USE_CACHEDB) && defined(USE_REDIS) 2941 OUTYY(("P(redis_timeout:%s)\n", $2)); 2942 if(atoi($2) == 0) 2943 yyerror("redis timeout value expected"); 2944 else cfg_parser->cfg->redis_timeout = atoi($2); 2945 #else 2946 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 2947 #endif 2948 free($2); 2949 } 2950 ; 2951 server_tcp_connection_limit: VAR_TCP_CONNECTION_LIMIT STRING_ARG STRING_ARG 2952 { 2953 OUTYY(("P(server_tcp_connection_limit:%s %s)\n", $2, $3)); 2954 if (atoi($3) < 0) 2955 yyerror("positive number expected"); 2956 else { 2957 if(!cfg_str2list_insert(&cfg_parser->cfg->tcp_connection_limits, $2, $3)) 2958 fatal_exit("out of memory adding tcp connection limit"); 2959 } 2960 } 2961 ; 2962 %% 2963 2964 /* parse helper routines could be here */ 2965 static void 2966 validate_respip_action(const char* action) 2967 { 2968 if(strcmp(action, "deny")!=0 && 2969 strcmp(action, "redirect")!=0 && 2970 strcmp(action, "inform")!=0 && 2971 strcmp(action, "inform_deny")!=0 && 2972 strcmp(action, "always_transparent")!=0 && 2973 strcmp(action, "always_refuse")!=0 && 2974 strcmp(action, "always_nxdomain")!=0) 2975 { 2976 yyerror("response-ip action: expected deny, redirect, " 2977 "inform, inform_deny, always_transparent, " 2978 "always_refuse or always_nxdomain"); 2979 } 2980 } 2981