*** nsd-3.0.5/configlexer.lex	2007-02-15 09:43:48.000000000 -0600
--- nsd-3.0.5.kw/configlexer.lex	2007-04-03 16:57:36.593053017 -0500
***************
*** 100,105 ****
--- 100,106 ----
  name{COLON}		{ LEXOUT(("v(%s) ", yytext)); return VAR_NAME;}
  ip-address{COLON}	{ LEXOUT(("v(%s) ", yytext)); return VAR_IP_ADDRESS;}
  debug-mode{COLON}	{ LEXOUT(("v(%s) ", yytext)); return VAR_DEBUG_MODE;}
+ version-bind{COLON}	{ LEXOUT(("v(%s) ", yytext)); return VAR_VERSION_BIND;}
  ip4-only{COLON}		{ LEXOUT(("v(%s) ", yytext)); return VAR_IP4_ONLY;}
  ip6-only{COLON}		{ LEXOUT(("v(%s) ", yytext)); return VAR_IP6_ONLY;}
  database{COLON}		{ LEXOUT(("v(%s) ", yytext)); return VAR_DATABASE;}
*** nsd-3.0.5/configparser.y	2007-02-13 04:37:00.000000000 -0600
--- nsd-3.0.5.kw/configparser.y	2007-04-03 17:05:34.488391726 -0500
***************
*** 53,59 ****
  %token VAR_KEY
  %token VAR_ALGORITHM VAR_SECRET
  %token VAR_AXFR
! %token VAR_VERBOSITY
  
  %%
  toplevelvars: /* empty */ | toplevelvars toplevelvar ;
--- 53,59 ----
  %token VAR_KEY
  %token VAR_ALGORITHM VAR_SECRET
  %token VAR_AXFR
! %token VAR_VERBOSITY VAR_VERSION_BIND
  
  %%
  toplevelvars: /* empty */ | toplevelvars toplevelvar ;
***************
*** 75,81 ****
  	server_server_count | server_tcp_count | server_pidfile | server_port | 
  	server_statistics | server_chroot | server_username | server_zonesdir |
  	server_difffile | server_xfrdfile | server_xfrd_reload_timeout |
! 	server_verbosity;
  server_ip_address: VAR_IP_ADDRESS STRING 
  	{ 
  		OUTYY(("P(server_ip_address:%s)\n", $2)); 
--- 75,81 ----
  	server_server_count | server_tcp_count | server_pidfile | server_port | 
  	server_statistics | server_chroot | server_username | server_zonesdir |
  	server_difffile | server_xfrdfile | server_xfrd_reload_timeout |
! 	server_verbosity | server_version_bind;
  server_ip_address: VAR_IP_ADDRESS STRING 
  	{ 
  		OUTYY(("P(server_ip_address:%s)\n", $2)); 
***************
*** 114,119 ****
--- 114,127 ----
  		else cfg_parser->opt->verbosity = atoi($2);
  	}
  	;
+ server_version_bind: VAR_VERSION_BIND STRING 
+ 	{ 
+ 		OUTYY(("P(server_version_bind:%s)\n", $2)); 
+ 		if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
+ 			yyerror("expected yes or no.");
+ 		else cfg_parser->opt->version_bind = (strcmp($2, "yes")==0);
+ 	}
+ 	;
  server_ip4_only: VAR_IP4_ONLY STRING 
  	{ 
  		OUTYY(("P(server_ip4_only:%s)\n", $2)); 
*** nsd-3.0.5/nsd-checkconf.c	2007-02-15 05:26:30.000000000 -0600
--- nsd-3.0.5.kw/nsd-checkconf.c	2007-04-03 17:07:19.375498265 -0500
***************
*** 231,236 ****
--- 231,237 ----
  		SERV_GET_IP(ip_address, o);
  		/* bin */
  		SERV_GET_BIN(debug_mode, o);
+ 		SERV_GET_BIN(version_bind, o);
  		SERV_GET_BIN(ip4_only, o);
  		SERV_GET_BIN(ip6_only, o);
  		/* str */
***************
*** 270,275 ****
--- 271,277 ----
  	printf("# Config settings.\n");
  	printf("server:\n");
  	printf("\tdebug-mode: %s\n", opt->debug_mode?"yes":"no");
+ 	printf("\tversion-bind: %s\n", opt->version_bind?"yes":"no");
  	printf("\tip4-only: %s\n", opt->ip4_only?"yes":"no");
  	printf("\tip6-only: %s\n", opt->ip6_only?"yes":"no");
  	print_string_var("database:", opt->database);
*** nsd-3.0.5/nsd.conf.sample.in	2007-02-22 02:57:43.000000000 -0600
--- nsd-3.0.5.kw/nsd.conf.sample.in	2007-04-03 17:26:15.670846159 -0500
***************
*** 15,20 ****
--- 15,23 ----
  	# ip-address: 1.2.3.4
  	# ip-address: 12fe::8ef0
  
+         # Answer VERSION.BIND Chaos queries
+ 	# version-bind: yes
+ 
  	# enable debug mode for nsd, does not fork daemon process.
  	# (debug mode disables slave zone functionalities)
  	# debug-mode: no
*** nsd-3.0.5/options.c	2007-02-13 04:47:15.000000000 -0600
--- nsd-3.0.5.kw/options.c	2007-04-03 16:59:45.648566429 -0500
***************
*** 37,42 ****
--- 37,43 ----
  	opt->ip_addresses = NULL;
  	opt->debug_mode = 0;
  	opt->verbosity = 0;
+ 	opt->version_bind = 1;
  	opt->ip4_only = 0;
  	opt->ip6_only = 0;
  	opt->database = DBFILE;
*** nsd-3.0.5/options.h	2007-02-13 04:37:00.000000000 -0600
--- nsd-3.0.5.kw/options.h	2007-04-03 17:03:44.856186896 -0500
***************
*** 40,45 ****
--- 40,46 ----
  
  	int debug_mode;
  	int verbosity;
+ 	int version_bind;
  	int ip4_only;
  	int ip6_only;
  	const char* database;
*** nsd-3.0.5/query.c	2007-02-13 11:23:33.000000000 -0600
--- nsd-3.0.5.kw/query.c	2007-04-03 17:22:56.682618333 -0500
***************
*** 478,490 ****
  			   (q->qname->name_size == 14
  			    && memcmp(dname_name(q->qname), "\007version\004bind", 14) == 0))
  		{
! 			/* Add version */
! 			query_addtxt(q,
  				     buffer_begin(q->packet) + QHEADERSZ,
  				     CLASS_CH,
  				     0,
  				     nsd->version);
! 			ANCOUNT_SET(q->packet, ANCOUNT(q->packet) + 1);
  		}
  		break;
  	default:
--- 478,494 ----
  			   (q->qname->name_size == 14
  			    && memcmp(dname_name(q->qname), "\007version\004bind", 14) == 0))
  		{
! 			if(nsd->options->version_bind == 1) {
! 				/* Add version */
! 				query_addtxt(q,
  				     buffer_begin(q->packet) + QHEADERSZ,
  				     CLASS_CH,
  				     0,
  				     nsd->version);
! 				ANCOUNT_SET(q->packet, ANCOUNT(q->packet) + 1);
! 			} else {
! 				RCODE_SET(q->packet, RCODE_REFUSE);
! 			}
  		}
  		break;
  	default:
