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 LIMITED 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 %{ 39 #include "config.h" 40 41 #include <stdarg.h> 42 #include <stdio.h> 43 #include <string.h> 44 #include <stdlib.h> 45 #include <assert.h> 46 47 #include "util/configyyrename.h" 48 #include "util/config_file.h" 49 #include "util/net_help.h" 50 51 int ub_c_lex(void); 52 void ub_c_error(const char *message); 53 54 /* these need to be global, otherwise they cannot be used inside yacc */ 55 extern struct config_parser_state* cfg_parser; 56 57 #if 0 58 #define OUTYY(s) printf s /* used ONLY when debugging */ 59 #else 60 #define OUTYY(s) 61 #endif 62 63 %} 64 %union { 65 char* str; 66 }; 67 68 %token SPACE LETTER NEWLINE COMMENT COLON ANY ZONESTR 69 %token <str> STRING_ARG 70 %token VAR_SERVER VAR_VERBOSITY VAR_NUM_THREADS VAR_PORT 71 %token VAR_OUTGOING_RANGE VAR_INTERFACE 72 %token VAR_DO_IP4 VAR_DO_IP6 VAR_DO_UDP VAR_DO_TCP 73 %token VAR_CHROOT VAR_USERNAME VAR_DIRECTORY VAR_LOGFILE VAR_PIDFILE 74 %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD 75 %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP 76 %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS 77 %token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME 78 %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY 79 %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES 80 %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR 81 %token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION 82 %token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF 83 %token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE 84 %token VAR_BOGUS_TTL VAR_VAL_CLEAN_ADDITIONAL VAR_VAL_PERMISSIVE_MODE 85 %token VAR_INCOMING_NUM_TCP VAR_MSG_BUFFER_SIZE VAR_KEY_CACHE_SIZE 86 %token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE 87 %token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG 88 %token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST 89 %token VAR_CACHE_MAX_TTL VAR_HARDEN_DNSSEC_STRIPPED VAR_ACCESS_CONTROL 90 %token VAR_LOCAL_ZONE VAR_LOCAL_DATA VAR_INTERFACE_AUTOMATIC 91 %token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID 92 %token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT 93 %token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR 94 %token VAR_NEG_CACHE_SIZE VAR_HARDEN_REFERRAL_PATH VAR_PRIVATE_ADDRESS 95 %token VAR_PRIVATE_DOMAIN VAR_REMOTE_CONTROL VAR_CONTROL_ENABLE 96 %token VAR_CONTROL_INTERFACE VAR_CONTROL_PORT VAR_SERVER_KEY_FILE 97 %token VAR_SERVER_CERT_FILE VAR_CONTROL_KEY_FILE VAR_CONTROL_CERT_FILE 98 %token VAR_EXTENDED_STATISTICS VAR_LOCAL_DATA_PTR VAR_JOSTLE_TIMEOUT 99 %token VAR_STUB_PRIME VAR_UNWANTED_REPLY_THRESHOLD VAR_LOG_TIME_ASCII 100 %token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN 101 %token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL 102 %token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN 103 %token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE VAR_PREFETCH 104 %token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_HARDEN_BELOW_NXDOMAIN 105 %token VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES VAR_TCP_UPSTREAM VAR_SSL_UPSTREAM 106 %token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT 107 108 %% 109 toplevelvars: /* empty */ | toplevelvars toplevelvar ; 110 toplevelvar: serverstart contents_server | stubstart contents_stub | 111 forwardstart contents_forward | pythonstart contents_py | 112 rcstart contents_rc 113 ; 114 115 /* server: declaration */ 116 serverstart: VAR_SERVER 117 { 118 OUTYY(("\nP(server:)\n")); 119 } 120 ; 121 contents_server: contents_server content_server 122 | ; 123 content_server: server_num_threads | server_verbosity | server_port | 124 server_outgoing_range | server_do_ip4 | 125 server_do_ip6 | server_do_udp | server_do_tcp | 126 server_interface | server_chroot | server_username | 127 server_directory | server_logfile | server_pidfile | 128 server_msg_cache_size | server_msg_cache_slabs | 129 server_num_queries_per_thread | server_rrset_cache_size | 130 server_rrset_cache_slabs | server_outgoing_num_tcp | 131 server_infra_host_ttl | server_infra_lame_ttl | 132 server_infra_cache_slabs | server_infra_cache_numhosts | 133 server_infra_cache_lame_size | server_target_fetch_policy | 134 server_harden_short_bufsize | server_harden_large_queries | 135 server_do_not_query_address | server_hide_identity | 136 server_hide_version | server_identity | server_version | 137 server_harden_glue | server_module_conf | server_trust_anchor_file | 138 server_trust_anchor | server_val_override_date | server_bogus_ttl | 139 server_val_clean_additional | server_val_permissive_mode | 140 server_incoming_num_tcp | server_msg_buffer_size | 141 server_key_cache_size | server_key_cache_slabs | 142 server_trusted_keys_file | server_val_nsec3_keysize_iterations | 143 server_use_syslog | server_outgoing_interface | server_root_hints | 144 server_do_not_query_localhost | server_cache_max_ttl | 145 server_harden_dnssec_stripped | server_access_control | 146 server_local_zone | server_local_data | server_interface_automatic | 147 server_statistics_interval | server_do_daemonize | 148 server_use_caps_for_id | server_statistics_cumulative | 149 server_outgoing_port_permit | server_outgoing_port_avoid | 150 server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size | 151 server_harden_referral_path | server_private_address | 152 server_private_domain | server_extended_statistics | 153 server_local_data_ptr | server_jostle_timeout | 154 server_unwanted_reply_threshold | server_log_time_ascii | 155 server_domain_insecure | server_val_sig_skew_min | 156 server_val_sig_skew_max | server_cache_min_ttl | server_val_log_level | 157 server_auto_trust_anchor_file | server_add_holddown | 158 server_del_holddown | server_keep_missing | server_so_rcvbuf | 159 server_edns_buffer_size | server_prefetch | server_prefetch_key | 160 server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag | 161 server_log_queries | server_tcp_upstream | server_ssl_upstream | 162 server_ssl_service_key | server_ssl_service_pem | server_ssl_port 163 ; 164 stubstart: VAR_STUB_ZONE 165 { 166 struct config_stub* s; 167 OUTYY(("\nP(stub_zone:)\n")); 168 s = (struct config_stub*)calloc(1, sizeof(struct config_stub)); 169 if(s) { 170 s->next = cfg_parser->cfg->stubs; 171 cfg_parser->cfg->stubs = s; 172 } else 173 yyerror("out of memory"); 174 } 175 ; 176 contents_stub: contents_stub content_stub 177 | ; 178 content_stub: stub_name | stub_host | stub_addr | stub_prime 179 ; 180 forwardstart: VAR_FORWARD_ZONE 181 { 182 struct config_stub* s; 183 OUTYY(("\nP(forward_zone:)\n")); 184 s = (struct config_stub*)calloc(1, sizeof(struct config_stub)); 185 if(s) { 186 s->next = cfg_parser->cfg->forwards; 187 cfg_parser->cfg->forwards = s; 188 } else 189 yyerror("out of memory"); 190 } 191 ; 192 contents_forward: contents_forward content_forward 193 | ; 194 content_forward: forward_name | forward_host | forward_addr 195 ; 196 server_num_threads: VAR_NUM_THREADS STRING_ARG 197 { 198 OUTYY(("P(server_num_threads:%s)\n", $2)); 199 if(atoi($2) == 0 && strcmp($2, "0") != 0) 200 yyerror("number expected"); 201 else cfg_parser->cfg->num_threads = atoi($2); 202 free($2); 203 } 204 ; 205 server_verbosity: VAR_VERBOSITY STRING_ARG 206 { 207 OUTYY(("P(server_verbosity:%s)\n", $2)); 208 if(atoi($2) == 0 && strcmp($2, "0") != 0) 209 yyerror("number expected"); 210 else cfg_parser->cfg->verbosity = atoi($2); 211 free($2); 212 } 213 ; 214 server_statistics_interval: VAR_STATISTICS_INTERVAL STRING_ARG 215 { 216 OUTYY(("P(server_statistics_interval:%s)\n", $2)); 217 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0) 218 cfg_parser->cfg->stat_interval = 0; 219 else if(atoi($2) == 0) 220 yyerror("number expected"); 221 else cfg_parser->cfg->stat_interval = atoi($2); 222 free($2); 223 } 224 ; 225 server_statistics_cumulative: VAR_STATISTICS_CUMULATIVE STRING_ARG 226 { 227 OUTYY(("P(server_statistics_cumulative:%s)\n", $2)); 228 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 229 yyerror("expected yes or no."); 230 else cfg_parser->cfg->stat_cumulative = (strcmp($2, "yes")==0); 231 free($2); 232 } 233 ; 234 server_extended_statistics: VAR_EXTENDED_STATISTICS STRING_ARG 235 { 236 OUTYY(("P(server_extended_statistics:%s)\n", $2)); 237 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 238 yyerror("expected yes or no."); 239 else cfg_parser->cfg->stat_extended = (strcmp($2, "yes")==0); 240 free($2); 241 } 242 ; 243 server_port: VAR_PORT STRING_ARG 244 { 245 OUTYY(("P(server_port:%s)\n", $2)); 246 if(atoi($2) == 0) 247 yyerror("port number expected"); 248 else cfg_parser->cfg->port = atoi($2); 249 free($2); 250 } 251 ; 252 server_interface: VAR_INTERFACE STRING_ARG 253 { 254 OUTYY(("P(server_interface:%s)\n", $2)); 255 if(cfg_parser->cfg->num_ifs == 0) 256 cfg_parser->cfg->ifs = calloc(1, sizeof(char*)); 257 else cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs, 258 (cfg_parser->cfg->num_ifs+1)*sizeof(char*)); 259 if(!cfg_parser->cfg->ifs) 260 yyerror("out of memory"); 261 else 262 cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = $2; 263 } 264 ; 265 server_outgoing_interface: VAR_OUTGOING_INTERFACE STRING_ARG 266 { 267 OUTYY(("P(server_outgoing_interface:%s)\n", $2)); 268 if(cfg_parser->cfg->num_out_ifs == 0) 269 cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*)); 270 else cfg_parser->cfg->out_ifs = realloc( 271 cfg_parser->cfg->out_ifs, 272 (cfg_parser->cfg->num_out_ifs+1)*sizeof(char*)); 273 if(!cfg_parser->cfg->out_ifs) 274 yyerror("out of memory"); 275 else 276 cfg_parser->cfg->out_ifs[ 277 cfg_parser->cfg->num_out_ifs++] = $2; 278 } 279 ; 280 server_outgoing_range: VAR_OUTGOING_RANGE STRING_ARG 281 { 282 OUTYY(("P(server_outgoing_range:%s)\n", $2)); 283 if(atoi($2) == 0) 284 yyerror("number expected"); 285 else cfg_parser->cfg->outgoing_num_ports = atoi($2); 286 free($2); 287 } 288 ; 289 server_outgoing_port_permit: VAR_OUTGOING_PORT_PERMIT STRING_ARG 290 { 291 OUTYY(("P(server_outgoing_port_permit:%s)\n", $2)); 292 if(!cfg_mark_ports($2, 1, 293 cfg_parser->cfg->outgoing_avail_ports, 65536)) 294 yyerror("port number or range (\"low-high\") expected"); 295 free($2); 296 } 297 ; 298 server_outgoing_port_avoid: VAR_OUTGOING_PORT_AVOID STRING_ARG 299 { 300 OUTYY(("P(server_outgoing_port_avoid:%s)\n", $2)); 301 if(!cfg_mark_ports($2, 0, 302 cfg_parser->cfg->outgoing_avail_ports, 65536)) 303 yyerror("port number or range (\"low-high\") expected"); 304 free($2); 305 } 306 ; 307 server_outgoing_num_tcp: VAR_OUTGOING_NUM_TCP STRING_ARG 308 { 309 OUTYY(("P(server_outgoing_num_tcp:%s)\n", $2)); 310 if(atoi($2) == 0 && strcmp($2, "0") != 0) 311 yyerror("number expected"); 312 else cfg_parser->cfg->outgoing_num_tcp = atoi($2); 313 free($2); 314 } 315 ; 316 server_incoming_num_tcp: VAR_INCOMING_NUM_TCP STRING_ARG 317 { 318 OUTYY(("P(server_incoming_num_tcp:%s)\n", $2)); 319 if(atoi($2) == 0 && strcmp($2, "0") != 0) 320 yyerror("number expected"); 321 else cfg_parser->cfg->incoming_num_tcp = atoi($2); 322 free($2); 323 } 324 ; 325 server_interface_automatic: VAR_INTERFACE_AUTOMATIC STRING_ARG 326 { 327 OUTYY(("P(server_interface_automatic:%s)\n", $2)); 328 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 329 yyerror("expected yes or no."); 330 else cfg_parser->cfg->if_automatic = (strcmp($2, "yes")==0); 331 free($2); 332 } 333 ; 334 server_do_ip4: VAR_DO_IP4 STRING_ARG 335 { 336 OUTYY(("P(server_do_ip4:%s)\n", $2)); 337 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 338 yyerror("expected yes or no."); 339 else cfg_parser->cfg->do_ip4 = (strcmp($2, "yes")==0); 340 free($2); 341 } 342 ; 343 server_do_ip6: VAR_DO_IP6 STRING_ARG 344 { 345 OUTYY(("P(server_do_ip6:%s)\n", $2)); 346 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 347 yyerror("expected yes or no."); 348 else cfg_parser->cfg->do_ip6 = (strcmp($2, "yes")==0); 349 free($2); 350 } 351 ; 352 server_do_udp: VAR_DO_UDP STRING_ARG 353 { 354 OUTYY(("P(server_do_udp:%s)\n", $2)); 355 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 356 yyerror("expected yes or no."); 357 else cfg_parser->cfg->do_udp = (strcmp($2, "yes")==0); 358 free($2); 359 } 360 ; 361 server_do_tcp: VAR_DO_TCP STRING_ARG 362 { 363 OUTYY(("P(server_do_tcp:%s)\n", $2)); 364 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 365 yyerror("expected yes or no."); 366 else cfg_parser->cfg->do_tcp = (strcmp($2, "yes")==0); 367 free($2); 368 } 369 ; 370 server_tcp_upstream: VAR_TCP_UPSTREAM STRING_ARG 371 { 372 OUTYY(("P(server_tcp_upstream:%s)\n", $2)); 373 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 374 yyerror("expected yes or no."); 375 else cfg_parser->cfg->tcp_upstream = (strcmp($2, "yes")==0); 376 free($2); 377 } 378 ; 379 server_ssl_upstream: VAR_SSL_UPSTREAM STRING_ARG 380 { 381 OUTYY(("P(server_ssl_upstream:%s)\n", $2)); 382 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 383 yyerror("expected yes or no."); 384 else cfg_parser->cfg->ssl_upstream = (strcmp($2, "yes")==0); 385 free($2); 386 } 387 ; 388 server_ssl_service_key: VAR_SSL_SERVICE_KEY STRING_ARG 389 { 390 OUTYY(("P(server_ssl_service_key:%s)\n", $2)); 391 free(cfg_parser->cfg->ssl_service_key); 392 cfg_parser->cfg->ssl_service_key = $2; 393 } 394 ; 395 server_ssl_service_pem: VAR_SSL_SERVICE_PEM STRING_ARG 396 { 397 OUTYY(("P(server_ssl_service_pem:%s)\n", $2)); 398 free(cfg_parser->cfg->ssl_service_pem); 399 cfg_parser->cfg->ssl_service_pem = $2; 400 } 401 ; 402 server_ssl_port: VAR_SSL_PORT STRING_ARG 403 { 404 OUTYY(("P(server_ssl_port:%s)\n", $2)); 405 if(atoi($2) == 0) 406 yyerror("port number expected"); 407 else cfg_parser->cfg->ssl_port = atoi($2); 408 free($2); 409 } 410 ; 411 server_do_daemonize: VAR_DO_DAEMONIZE STRING_ARG 412 { 413 OUTYY(("P(server_do_daemonize:%s)\n", $2)); 414 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 415 yyerror("expected yes or no."); 416 else cfg_parser->cfg->do_daemonize = (strcmp($2, "yes")==0); 417 free($2); 418 } 419 ; 420 server_use_syslog: VAR_USE_SYSLOG STRING_ARG 421 { 422 OUTYY(("P(server_use_syslog:%s)\n", $2)); 423 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 424 yyerror("expected yes or no."); 425 else cfg_parser->cfg->use_syslog = (strcmp($2, "yes")==0); 426 #if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS) 427 if(strcmp($2, "yes") == 0) 428 yyerror("no syslog services are available. " 429 "(reconfigure and compile to add)"); 430 #endif 431 free($2); 432 } 433 ; 434 server_log_time_ascii: VAR_LOG_TIME_ASCII STRING_ARG 435 { 436 OUTYY(("P(server_log_time_ascii:%s)\n", $2)); 437 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 438 yyerror("expected yes or no."); 439 else cfg_parser->cfg->log_time_ascii = (strcmp($2, "yes")==0); 440 free($2); 441 } 442 ; 443 server_log_queries: VAR_LOG_QUERIES STRING_ARG 444 { 445 OUTYY(("P(server_log_queries:%s)\n", $2)); 446 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 447 yyerror("expected yes or no."); 448 else cfg_parser->cfg->log_queries = (strcmp($2, "yes")==0); 449 free($2); 450 } 451 ; 452 server_chroot: VAR_CHROOT STRING_ARG 453 { 454 OUTYY(("P(server_chroot:%s)\n", $2)); 455 free(cfg_parser->cfg->chrootdir); 456 cfg_parser->cfg->chrootdir = $2; 457 } 458 ; 459 server_username: VAR_USERNAME STRING_ARG 460 { 461 OUTYY(("P(server_username:%s)\n", $2)); 462 free(cfg_parser->cfg->username); 463 cfg_parser->cfg->username = $2; 464 } 465 ; 466 server_directory: VAR_DIRECTORY STRING_ARG 467 { 468 OUTYY(("P(server_directory:%s)\n", $2)); 469 free(cfg_parser->cfg->directory); 470 cfg_parser->cfg->directory = $2; 471 } 472 ; 473 server_logfile: VAR_LOGFILE STRING_ARG 474 { 475 OUTYY(("P(server_logfile:%s)\n", $2)); 476 free(cfg_parser->cfg->logfile); 477 cfg_parser->cfg->logfile = $2; 478 cfg_parser->cfg->use_syslog = 0; 479 } 480 ; 481 server_pidfile: VAR_PIDFILE STRING_ARG 482 { 483 OUTYY(("P(server_pidfile:%s)\n", $2)); 484 free(cfg_parser->cfg->pidfile); 485 cfg_parser->cfg->pidfile = $2; 486 } 487 ; 488 server_root_hints: VAR_ROOT_HINTS STRING_ARG 489 { 490 OUTYY(("P(server_root_hints:%s)\n", $2)); 491 if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, $2)) 492 yyerror("out of memory"); 493 } 494 ; 495 server_dlv_anchor_file: VAR_DLV_ANCHOR_FILE STRING_ARG 496 { 497 OUTYY(("P(server_dlv_anchor_file:%s)\n", $2)); 498 free(cfg_parser->cfg->dlv_anchor_file); 499 cfg_parser->cfg->dlv_anchor_file = $2; 500 } 501 ; 502 server_dlv_anchor: VAR_DLV_ANCHOR STRING_ARG 503 { 504 OUTYY(("P(server_dlv_anchor:%s)\n", $2)); 505 if(!cfg_strlist_insert(&cfg_parser->cfg->dlv_anchor_list, $2)) 506 yyerror("out of memory"); 507 } 508 ; 509 server_auto_trust_anchor_file: VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG 510 { 511 OUTYY(("P(server_auto_trust_anchor_file:%s)\n", $2)); 512 if(!cfg_strlist_insert(&cfg_parser->cfg-> 513 auto_trust_anchor_file_list, $2)) 514 yyerror("out of memory"); 515 } 516 ; 517 server_trust_anchor_file: VAR_TRUST_ANCHOR_FILE STRING_ARG 518 { 519 OUTYY(("P(server_trust_anchor_file:%s)\n", $2)); 520 if(!cfg_strlist_insert(&cfg_parser->cfg-> 521 trust_anchor_file_list, $2)) 522 yyerror("out of memory"); 523 } 524 ; 525 server_trusted_keys_file: VAR_TRUSTED_KEYS_FILE STRING_ARG 526 { 527 OUTYY(("P(server_trusted_keys_file:%s)\n", $2)); 528 if(!cfg_strlist_insert(&cfg_parser->cfg-> 529 trusted_keys_file_list, $2)) 530 yyerror("out of memory"); 531 } 532 ; 533 server_trust_anchor: VAR_TRUST_ANCHOR STRING_ARG 534 { 535 OUTYY(("P(server_trust_anchor:%s)\n", $2)); 536 if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, $2)) 537 yyerror("out of memory"); 538 } 539 ; 540 server_domain_insecure: VAR_DOMAIN_INSECURE STRING_ARG 541 { 542 OUTYY(("P(server_domain_insecure:%s)\n", $2)); 543 if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, $2)) 544 yyerror("out of memory"); 545 } 546 ; 547 server_hide_identity: VAR_HIDE_IDENTITY STRING_ARG 548 { 549 OUTYY(("P(server_hide_identity:%s)\n", $2)); 550 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 551 yyerror("expected yes or no."); 552 else cfg_parser->cfg->hide_identity = (strcmp($2, "yes")==0); 553 free($2); 554 } 555 ; 556 server_hide_version: VAR_HIDE_VERSION STRING_ARG 557 { 558 OUTYY(("P(server_hide_version:%s)\n", $2)); 559 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 560 yyerror("expected yes or no."); 561 else cfg_parser->cfg->hide_version = (strcmp($2, "yes")==0); 562 free($2); 563 } 564 ; 565 server_identity: VAR_IDENTITY STRING_ARG 566 { 567 OUTYY(("P(server_identity:%s)\n", $2)); 568 free(cfg_parser->cfg->identity); 569 cfg_parser->cfg->identity = $2; 570 } 571 ; 572 server_version: VAR_VERSION STRING_ARG 573 { 574 OUTYY(("P(server_version:%s)\n", $2)); 575 free(cfg_parser->cfg->version); 576 cfg_parser->cfg->version = $2; 577 } 578 ; 579 server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG 580 { 581 OUTYY(("P(server_so_rcvbuf:%s)\n", $2)); 582 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_rcvbuf)) 583 yyerror("buffer size expected"); 584 free($2); 585 } 586 ; 587 server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG 588 { 589 OUTYY(("P(server_so_sndbuf:%s)\n", $2)); 590 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_sndbuf)) 591 yyerror("buffer size expected"); 592 free($2); 593 } 594 ; 595 server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG 596 { 597 OUTYY(("P(server_edns_buffer_size:%s)\n", $2)); 598 if(atoi($2) == 0) 599 yyerror("number expected"); 600 else if (atoi($2) < 12) 601 yyerror("edns buffer size too small"); 602 else if (atoi($2) > 65535) 603 cfg_parser->cfg->edns_buffer_size = 65535; 604 else cfg_parser->cfg->edns_buffer_size = atoi($2); 605 free($2); 606 } 607 ; 608 server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG 609 { 610 OUTYY(("P(server_msg_buffer_size:%s)\n", $2)); 611 if(atoi($2) == 0) 612 yyerror("number expected"); 613 else if (atoi($2) < 4096) 614 yyerror("message buffer size too small (use 4096)"); 615 else cfg_parser->cfg->msg_buffer_size = atoi($2); 616 free($2); 617 } 618 ; 619 server_msg_cache_size: VAR_MSG_CACHE_SIZE STRING_ARG 620 { 621 OUTYY(("P(server_msg_cache_size:%s)\n", $2)); 622 if(!cfg_parse_memsize($2, &cfg_parser->cfg->msg_cache_size)) 623 yyerror("memory size expected"); 624 free($2); 625 } 626 ; 627 server_msg_cache_slabs: VAR_MSG_CACHE_SLABS STRING_ARG 628 { 629 OUTYY(("P(server_msg_cache_slabs:%s)\n", $2)); 630 if(atoi($2) == 0) 631 yyerror("number expected"); 632 else { 633 cfg_parser->cfg->msg_cache_slabs = atoi($2); 634 if(!is_pow2(cfg_parser->cfg->msg_cache_slabs)) 635 yyerror("must be a power of 2"); 636 } 637 free($2); 638 } 639 ; 640 server_num_queries_per_thread: VAR_NUM_QUERIES_PER_THREAD STRING_ARG 641 { 642 OUTYY(("P(server_num_queries_per_thread:%s)\n", $2)); 643 if(atoi($2) == 0) 644 yyerror("number expected"); 645 else cfg_parser->cfg->num_queries_per_thread = atoi($2); 646 free($2); 647 } 648 ; 649 server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG 650 { 651 OUTYY(("P(server_jostle_timeout:%s)\n", $2)); 652 if(atoi($2) == 0 && strcmp($2, "0") != 0) 653 yyerror("number expected"); 654 else cfg_parser->cfg->jostle_time = atoi($2); 655 free($2); 656 } 657 ; 658 server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG 659 { 660 OUTYY(("P(server_rrset_cache_size:%s)\n", $2)); 661 if(!cfg_parse_memsize($2, &cfg_parser->cfg->rrset_cache_size)) 662 yyerror("memory size expected"); 663 free($2); 664 } 665 ; 666 server_rrset_cache_slabs: VAR_RRSET_CACHE_SLABS STRING_ARG 667 { 668 OUTYY(("P(server_rrset_cache_slabs:%s)\n", $2)); 669 if(atoi($2) == 0) 670 yyerror("number expected"); 671 else { 672 cfg_parser->cfg->rrset_cache_slabs = atoi($2); 673 if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs)) 674 yyerror("must be a power of 2"); 675 } 676 free($2); 677 } 678 ; 679 server_infra_host_ttl: VAR_INFRA_HOST_TTL STRING_ARG 680 { 681 OUTYY(("P(server_infra_host_ttl:%s)\n", $2)); 682 if(atoi($2) == 0 && strcmp($2, "0") != 0) 683 yyerror("number expected"); 684 else cfg_parser->cfg->host_ttl = atoi($2); 685 free($2); 686 } 687 ; 688 server_infra_lame_ttl: VAR_INFRA_LAME_TTL STRING_ARG 689 { 690 OUTYY(("P(server_infra_lame_ttl:%s)\n", $2)); 691 verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option " 692 "removed, use infra-host-ttl)", $2); 693 free($2); 694 } 695 ; 696 server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING_ARG 697 { 698 OUTYY(("P(server_infra_cache_numhosts:%s)\n", $2)); 699 if(atoi($2) == 0) 700 yyerror("number expected"); 701 else cfg_parser->cfg->infra_cache_numhosts = atoi($2); 702 free($2); 703 } 704 ; 705 server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING_ARG 706 { 707 OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2)); 708 verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s " 709 "(option removed, use infra-cache-numhosts)", $2); 710 free($2); 711 } 712 ; 713 server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG 714 { 715 OUTYY(("P(server_infra_cache_slabs:%s)\n", $2)); 716 if(atoi($2) == 0) 717 yyerror("number expected"); 718 else { 719 cfg_parser->cfg->infra_cache_slabs = atoi($2); 720 if(!is_pow2(cfg_parser->cfg->infra_cache_slabs)) 721 yyerror("must be a power of 2"); 722 } 723 free($2); 724 } 725 ; 726 server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG 727 { 728 OUTYY(("P(server_target_fetch_policy:%s)\n", $2)); 729 free(cfg_parser->cfg->target_fetch_policy); 730 cfg_parser->cfg->target_fetch_policy = $2; 731 } 732 ; 733 server_harden_short_bufsize: VAR_HARDEN_SHORT_BUFSIZE STRING_ARG 734 { 735 OUTYY(("P(server_harden_short_bufsize:%s)\n", $2)); 736 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 737 yyerror("expected yes or no."); 738 else cfg_parser->cfg->harden_short_bufsize = 739 (strcmp($2, "yes")==0); 740 free($2); 741 } 742 ; 743 server_harden_large_queries: VAR_HARDEN_LARGE_QUERIES STRING_ARG 744 { 745 OUTYY(("P(server_harden_large_queries:%s)\n", $2)); 746 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 747 yyerror("expected yes or no."); 748 else cfg_parser->cfg->harden_large_queries = 749 (strcmp($2, "yes")==0); 750 free($2); 751 } 752 ; 753 server_harden_glue: VAR_HARDEN_GLUE STRING_ARG 754 { 755 OUTYY(("P(server_harden_glue:%s)\n", $2)); 756 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 757 yyerror("expected yes or no."); 758 else cfg_parser->cfg->harden_glue = 759 (strcmp($2, "yes")==0); 760 free($2); 761 } 762 ; 763 server_harden_dnssec_stripped: VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG 764 { 765 OUTYY(("P(server_harden_dnssec_stripped:%s)\n", $2)); 766 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 767 yyerror("expected yes or no."); 768 else cfg_parser->cfg->harden_dnssec_stripped = 769 (strcmp($2, "yes")==0); 770 free($2); 771 } 772 ; 773 server_harden_below_nxdomain: VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG 774 { 775 OUTYY(("P(server_harden_below_nxdomain:%s)\n", $2)); 776 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 777 yyerror("expected yes or no."); 778 else cfg_parser->cfg->harden_below_nxdomain = 779 (strcmp($2, "yes")==0); 780 free($2); 781 } 782 ; 783 server_harden_referral_path: VAR_HARDEN_REFERRAL_PATH STRING_ARG 784 { 785 OUTYY(("P(server_harden_referral_path:%s)\n", $2)); 786 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 787 yyerror("expected yes or no."); 788 else cfg_parser->cfg->harden_referral_path = 789 (strcmp($2, "yes")==0); 790 free($2); 791 } 792 ; 793 server_use_caps_for_id: VAR_USE_CAPS_FOR_ID STRING_ARG 794 { 795 OUTYY(("P(server_use_caps_for_id:%s)\n", $2)); 796 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 797 yyerror("expected yes or no."); 798 else cfg_parser->cfg->use_caps_bits_for_id = 799 (strcmp($2, "yes")==0); 800 free($2); 801 } 802 ; 803 server_private_address: VAR_PRIVATE_ADDRESS STRING_ARG 804 { 805 OUTYY(("P(server_private_address:%s)\n", $2)); 806 if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, $2)) 807 yyerror("out of memory"); 808 } 809 ; 810 server_private_domain: VAR_PRIVATE_DOMAIN STRING_ARG 811 { 812 OUTYY(("P(server_private_domain:%s)\n", $2)); 813 if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, $2)) 814 yyerror("out of memory"); 815 } 816 ; 817 server_prefetch: VAR_PREFETCH STRING_ARG 818 { 819 OUTYY(("P(server_prefetch:%s)\n", $2)); 820 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 821 yyerror("expected yes or no."); 822 else cfg_parser->cfg->prefetch = (strcmp($2, "yes")==0); 823 free($2); 824 } 825 ; 826 server_prefetch_key: VAR_PREFETCH_KEY STRING_ARG 827 { 828 OUTYY(("P(server_prefetch_key:%s)\n", $2)); 829 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 830 yyerror("expected yes or no."); 831 else cfg_parser->cfg->prefetch_key = (strcmp($2, "yes")==0); 832 free($2); 833 } 834 ; 835 server_unwanted_reply_threshold: VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG 836 { 837 OUTYY(("P(server_unwanted_reply_threshold:%s)\n", $2)); 838 if(atoi($2) == 0 && strcmp($2, "0") != 0) 839 yyerror("number expected"); 840 else cfg_parser->cfg->unwanted_threshold = atoi($2); 841 free($2); 842 } 843 ; 844 server_do_not_query_address: VAR_DO_NOT_QUERY_ADDRESS STRING_ARG 845 { 846 OUTYY(("P(server_do_not_query_address:%s)\n", $2)); 847 if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, $2)) 848 yyerror("out of memory"); 849 } 850 ; 851 server_do_not_query_localhost: VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG 852 { 853 OUTYY(("P(server_do_not_query_localhost:%s)\n", $2)); 854 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 855 yyerror("expected yes or no."); 856 else cfg_parser->cfg->donotquery_localhost = 857 (strcmp($2, "yes")==0); 858 free($2); 859 } 860 ; 861 server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG 862 { 863 OUTYY(("P(server_access_control:%s %s)\n", $2, $3)); 864 if(strcmp($3, "deny")!=0 && strcmp($3, "refuse")!=0 && 865 strcmp($3, "allow")!=0 && 866 strcmp($3, "allow_snoop")!=0) { 867 yyerror("expected deny, refuse, allow or allow_snoop " 868 "in access control action"); 869 } else { 870 if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3)) 871 fatal_exit("out of memory adding acl"); 872 } 873 } 874 ; 875 server_module_conf: VAR_MODULE_CONF STRING_ARG 876 { 877 OUTYY(("P(server_module_conf:%s)\n", $2)); 878 free(cfg_parser->cfg->module_conf); 879 cfg_parser->cfg->module_conf = $2; 880 } 881 ; 882 server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING_ARG 883 { 884 OUTYY(("P(server_val_override_date:%s)\n", $2)); 885 if(strlen($2) == 0 || strcmp($2, "0") == 0) { 886 cfg_parser->cfg->val_date_override = 0; 887 } else if(strlen($2) == 14) { 888 cfg_parser->cfg->val_date_override = 889 cfg_convert_timeval($2); 890 if(!cfg_parser->cfg->val_date_override) 891 yyerror("bad date/time specification"); 892 } else { 893 if(atoi($2) == 0) 894 yyerror("number expected"); 895 cfg_parser->cfg->val_date_override = atoi($2); 896 } 897 free($2); 898 } 899 ; 900 server_val_sig_skew_min: VAR_VAL_SIG_SKEW_MIN STRING_ARG 901 { 902 OUTYY(("P(server_val_sig_skew_min:%s)\n", $2)); 903 if(strlen($2) == 0 || strcmp($2, "0") == 0) { 904 cfg_parser->cfg->val_sig_skew_min = 0; 905 } else { 906 cfg_parser->cfg->val_sig_skew_min = atoi($2); 907 if(!cfg_parser->cfg->val_sig_skew_min) 908 yyerror("number expected"); 909 } 910 free($2); 911 } 912 ; 913 server_val_sig_skew_max: VAR_VAL_SIG_SKEW_MAX STRING_ARG 914 { 915 OUTYY(("P(server_val_sig_skew_max:%s)\n", $2)); 916 if(strlen($2) == 0 || strcmp($2, "0") == 0) { 917 cfg_parser->cfg->val_sig_skew_max = 0; 918 } else { 919 cfg_parser->cfg->val_sig_skew_max = atoi($2); 920 if(!cfg_parser->cfg->val_sig_skew_max) 921 yyerror("number expected"); 922 } 923 free($2); 924 } 925 ; 926 server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG 927 { 928 OUTYY(("P(server_cache_max_ttl:%s)\n", $2)); 929 if(atoi($2) == 0 && strcmp($2, "0") != 0) 930 yyerror("number expected"); 931 else cfg_parser->cfg->max_ttl = atoi($2); 932 free($2); 933 } 934 ; 935 server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG 936 { 937 OUTYY(("P(server_cache_min_ttl:%s)\n", $2)); 938 if(atoi($2) == 0 && strcmp($2, "0") != 0) 939 yyerror("number expected"); 940 else cfg_parser->cfg->min_ttl = atoi($2); 941 free($2); 942 } 943 ; 944 server_bogus_ttl: VAR_BOGUS_TTL STRING_ARG 945 { 946 OUTYY(("P(server_bogus_ttl:%s)\n", $2)); 947 if(atoi($2) == 0 && strcmp($2, "0") != 0) 948 yyerror("number expected"); 949 else cfg_parser->cfg->bogus_ttl = atoi($2); 950 free($2); 951 } 952 ; 953 server_val_clean_additional: VAR_VAL_CLEAN_ADDITIONAL STRING_ARG 954 { 955 OUTYY(("P(server_val_clean_additional:%s)\n", $2)); 956 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 957 yyerror("expected yes or no."); 958 else cfg_parser->cfg->val_clean_additional = 959 (strcmp($2, "yes")==0); 960 free($2); 961 } 962 ; 963 server_val_permissive_mode: VAR_VAL_PERMISSIVE_MODE STRING_ARG 964 { 965 OUTYY(("P(server_val_permissive_mode:%s)\n", $2)); 966 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 967 yyerror("expected yes or no."); 968 else cfg_parser->cfg->val_permissive_mode = 969 (strcmp($2, "yes")==0); 970 free($2); 971 } 972 ; 973 server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG 974 { 975 OUTYY(("P(server_ignore_cd_flag:%s)\n", $2)); 976 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 977 yyerror("expected yes or no."); 978 else cfg_parser->cfg->ignore_cd = (strcmp($2, "yes")==0); 979 free($2); 980 } 981 ; 982 server_val_log_level: VAR_VAL_LOG_LEVEL STRING_ARG 983 { 984 OUTYY(("P(server_val_log_level:%s)\n", $2)); 985 if(atoi($2) == 0 && strcmp($2, "0") != 0) 986 yyerror("number expected"); 987 else cfg_parser->cfg->val_log_level = atoi($2); 988 free($2); 989 } 990 ; 991 server_val_nsec3_keysize_iterations: VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG 992 { 993 OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", $2)); 994 free(cfg_parser->cfg->val_nsec3_key_iterations); 995 cfg_parser->cfg->val_nsec3_key_iterations = $2; 996 } 997 ; 998 server_add_holddown: VAR_ADD_HOLDDOWN STRING_ARG 999 { 1000 OUTYY(("P(server_add_holddown:%s)\n", $2)); 1001 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1002 yyerror("number expected"); 1003 else cfg_parser->cfg->add_holddown = atoi($2); 1004 free($2); 1005 } 1006 ; 1007 server_del_holddown: VAR_DEL_HOLDDOWN STRING_ARG 1008 { 1009 OUTYY(("P(server_del_holddown:%s)\n", $2)); 1010 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1011 yyerror("number expected"); 1012 else cfg_parser->cfg->del_holddown = atoi($2); 1013 free($2); 1014 } 1015 ; 1016 server_keep_missing: VAR_KEEP_MISSING STRING_ARG 1017 { 1018 OUTYY(("P(server_keep_missing:%s)\n", $2)); 1019 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1020 yyerror("number expected"); 1021 else cfg_parser->cfg->keep_missing = atoi($2); 1022 free($2); 1023 } 1024 ; 1025 server_key_cache_size: VAR_KEY_CACHE_SIZE STRING_ARG 1026 { 1027 OUTYY(("P(server_key_cache_size:%s)\n", $2)); 1028 if(!cfg_parse_memsize($2, &cfg_parser->cfg->key_cache_size)) 1029 yyerror("memory size expected"); 1030 free($2); 1031 } 1032 ; 1033 server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING_ARG 1034 { 1035 OUTYY(("P(server_key_cache_slabs:%s)\n", $2)); 1036 if(atoi($2) == 0) 1037 yyerror("number expected"); 1038 else { 1039 cfg_parser->cfg->key_cache_slabs = atoi($2); 1040 if(!is_pow2(cfg_parser->cfg->key_cache_slabs)) 1041 yyerror("must be a power of 2"); 1042 } 1043 free($2); 1044 } 1045 ; 1046 server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG 1047 { 1048 OUTYY(("P(server_neg_cache_size:%s)\n", $2)); 1049 if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size)) 1050 yyerror("memory size expected"); 1051 free($2); 1052 } 1053 ; 1054 server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG 1055 { 1056 OUTYY(("P(server_local_zone:%s %s)\n", $2, $3)); 1057 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && 1058 strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && 1059 strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 1060 && strcmp($3, "typetransparent")!=0) 1061 yyerror("local-zone type: expected static, deny, " 1062 "refuse, redirect, transparent, " 1063 "typetransparent or nodefault"); 1064 else if(strcmp($3, "nodefault")==0) { 1065 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1066 local_zones_nodefault, $2)) 1067 fatal_exit("out of memory adding local-zone"); 1068 free($3); 1069 } else { 1070 if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones, 1071 $2, $3)) 1072 fatal_exit("out of memory adding local-zone"); 1073 } 1074 } 1075 ; 1076 server_local_data: VAR_LOCAL_DATA STRING_ARG 1077 { 1078 OUTYY(("P(server_local_data:%s)\n", $2)); 1079 if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2)) 1080 fatal_exit("out of memory adding local-data"); 1081 } 1082 ; 1083 server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG 1084 { 1085 char* ptr; 1086 OUTYY(("P(server_local_data_ptr:%s)\n", $2)); 1087 ptr = cfg_ptr_reverse($2); 1088 free($2); 1089 if(ptr) { 1090 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1091 local_data, ptr)) 1092 fatal_exit("out of memory adding local-data"); 1093 } else { 1094 yyerror("local-data-ptr could not be reversed"); 1095 } 1096 } 1097 ; 1098 stub_name: VAR_NAME STRING_ARG 1099 { 1100 OUTYY(("P(name:%s)\n", $2)); 1101 if(cfg_parser->cfg->stubs->name) 1102 yyerror("stub name override, there must be one name " 1103 "for one stub-zone"); 1104 free(cfg_parser->cfg->stubs->name); 1105 cfg_parser->cfg->stubs->name = $2; 1106 } 1107 ; 1108 stub_host: VAR_STUB_HOST STRING_ARG 1109 { 1110 OUTYY(("P(stub-host:%s)\n", $2)); 1111 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, $2)) 1112 yyerror("out of memory"); 1113 } 1114 ; 1115 stub_addr: VAR_STUB_ADDR STRING_ARG 1116 { 1117 OUTYY(("P(stub-addr:%s)\n", $2)); 1118 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, $2)) 1119 yyerror("out of memory"); 1120 } 1121 ; 1122 stub_prime: VAR_STUB_PRIME STRING_ARG 1123 { 1124 OUTYY(("P(stub-prime:%s)\n", $2)); 1125 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1126 yyerror("expected yes or no."); 1127 else cfg_parser->cfg->stubs->isprime = 1128 (strcmp($2, "yes")==0); 1129 free($2); 1130 } 1131 ; 1132 forward_name: VAR_NAME STRING_ARG 1133 { 1134 OUTYY(("P(name:%s)\n", $2)); 1135 if(cfg_parser->cfg->forwards->name) 1136 yyerror("forward name override, there must be one " 1137 "name for one forward-zone"); 1138 free(cfg_parser->cfg->forwards->name); 1139 cfg_parser->cfg->forwards->name = $2; 1140 } 1141 ; 1142 forward_host: VAR_FORWARD_HOST STRING_ARG 1143 { 1144 OUTYY(("P(forward-host:%s)\n", $2)); 1145 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, $2)) 1146 yyerror("out of memory"); 1147 } 1148 ; 1149 forward_addr: VAR_FORWARD_ADDR STRING_ARG 1150 { 1151 OUTYY(("P(forward-addr:%s)\n", $2)); 1152 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, $2)) 1153 yyerror("out of memory"); 1154 } 1155 ; 1156 rcstart: VAR_REMOTE_CONTROL 1157 { 1158 OUTYY(("\nP(remote-control:)\n")); 1159 } 1160 ; 1161 contents_rc: contents_rc content_rc 1162 | ; 1163 content_rc: rc_control_enable | rc_control_interface | rc_control_port | 1164 rc_server_key_file | rc_server_cert_file | rc_control_key_file | 1165 rc_control_cert_file 1166 ; 1167 rc_control_enable: VAR_CONTROL_ENABLE STRING_ARG 1168 { 1169 OUTYY(("P(control_enable:%s)\n", $2)); 1170 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1171 yyerror("expected yes or no."); 1172 else cfg_parser->cfg->remote_control_enable = 1173 (strcmp($2, "yes")==0); 1174 free($2); 1175 } 1176 ; 1177 rc_control_port: VAR_CONTROL_PORT STRING_ARG 1178 { 1179 OUTYY(("P(control_port:%s)\n", $2)); 1180 if(atoi($2) == 0) 1181 yyerror("control port number expected"); 1182 else cfg_parser->cfg->control_port = atoi($2); 1183 free($2); 1184 } 1185 ; 1186 rc_control_interface: VAR_CONTROL_INTERFACE STRING_ARG 1187 { 1188 OUTYY(("P(control_interface:%s)\n", $2)); 1189 if(!cfg_strlist_insert(&cfg_parser->cfg->control_ifs, $2)) 1190 yyerror("out of memory"); 1191 } 1192 ; 1193 rc_server_key_file: VAR_SERVER_KEY_FILE STRING_ARG 1194 { 1195 OUTYY(("P(rc_server_key_file:%s)\n", $2)); 1196 free(cfg_parser->cfg->server_key_file); 1197 cfg_parser->cfg->server_key_file = $2; 1198 } 1199 ; 1200 rc_server_cert_file: VAR_SERVER_CERT_FILE STRING_ARG 1201 { 1202 OUTYY(("P(rc_server_cert_file:%s)\n", $2)); 1203 free(cfg_parser->cfg->server_cert_file); 1204 cfg_parser->cfg->server_cert_file = $2; 1205 } 1206 ; 1207 rc_control_key_file: VAR_CONTROL_KEY_FILE STRING_ARG 1208 { 1209 OUTYY(("P(rc_control_key_file:%s)\n", $2)); 1210 free(cfg_parser->cfg->control_key_file); 1211 cfg_parser->cfg->control_key_file = $2; 1212 } 1213 ; 1214 rc_control_cert_file: VAR_CONTROL_CERT_FILE STRING_ARG 1215 { 1216 OUTYY(("P(rc_control_cert_file:%s)\n", $2)); 1217 free(cfg_parser->cfg->control_cert_file); 1218 cfg_parser->cfg->control_cert_file = $2; 1219 } 1220 ; 1221 pythonstart: VAR_PYTHON 1222 { 1223 OUTYY(("\nP(python:)\n")); 1224 } 1225 ; 1226 contents_py: contents_py content_py 1227 | ; 1228 content_py: py_script 1229 ; 1230 py_script: VAR_PYTHON_SCRIPT STRING_ARG 1231 { 1232 OUTYY(("P(python-script:%s)\n", $2)); 1233 free(cfg_parser->cfg->python_script); 1234 cfg_parser->cfg->python_script = $2; 1235 } 1236 %% 1237 1238 /* parse helper routines could be here */ 1239