Commit 9bd478a5 authored by Mark Andrews's avatar Mark Andrews

1417. [func] ID.SERVER/CHAOS is now a built in zone.

                       See "server-id" for how to configure.
parent 421e4cf6
1417. [func] ID.SERVER/CHAOS is now a built in zone.
See "server-id" for how to configure.
1416. [bug] Empty node should return NOERROR NODATA, not NXDOMAIN.
[RT #4715]
......
......@@ -15,10 +15,10 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: builtin.c,v 1.3 2002/02/20 03:33:06 marka Exp $ */
/* $Id: builtin.c,v 1.4 2003/01/20 05:46:09 marka Exp $ */
/*
* The built-in "version", "hostname", and "authors" databases.
* The built-in "version", "hostname", "id" and "authors" databases.
*/
#include <config.h>
......@@ -43,6 +43,7 @@ typedef struct builtin builtin_t;
static isc_result_t do_version_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_hostname_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_authors_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_id_lookup(dns_sdblookup_t *lookup);
/*
* We can't use function pointers as the db_data directly
......@@ -57,6 +58,7 @@ struct builtin {
static builtin_t version_builtin = { do_version_lookup };
static builtin_t hostname_builtin = { do_hostname_lookup };
static builtin_t authors_builtin = { do_authors_lookup };
static builtin_t id_builtin = { do_id_lookup };
static dns_sdbimplementation_t *builtin_impl;
......@@ -147,6 +149,23 @@ do_authors_lookup(dns_sdblookup_t *lookup) {
return (ISC_R_SUCCESS);
}
static isc_result_t
do_id_lookup(dns_sdblookup_t *lookup) {
if (ns_g_server->server_usehostname) {
char buf[256];
isc_result_t result = ns_os_gethostname(buf, sizeof(buf));
if (result != ISC_R_SUCCESS)
return (result);
return (put_txt(lookup, buf));
}
if (ns_g_server->server_id == NULL)
return (ISC_R_SUCCESS);
else
return (put_txt(lookup, ns_g_server->server_id));
}
static isc_result_t
builtin_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup) {
isc_result_t result;
......@@ -178,6 +197,8 @@ builtin_create(const char *zone, int argc, char **argv,
*dbdata = &hostname_builtin;
else if (strcmp(argv[0], "authors") == 0)
*dbdata = &authors_builtin;
else if (strcmp(argv[0], "id") == 0)
*dbdata = &id_builtin;
else
return (ISC_R_NOTIMPLEMENTED);
return (ISC_R_SUCCESS);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: config.c,v 1.34 2002/11/27 09:52:45 marka Exp $ */
/* $Id: config.c,v 1.35 2003/01/20 05:46:09 marka Exp $ */
#include <config.h>
......@@ -76,6 +76,7 @@ options {\n\
rrset-order {order cyclic;};\n\
serial-queries 20;\n\
serial-query-rate 20;\n\
server-id none;\n\
stacksize default;\n\
statistics-file \"named.stats\";\n\
statistics-interval 60;\n\
......@@ -166,6 +167,10 @@ view \"_bind\" chaos {\n\
type master;\n\
database \"_builtin authors\";\n\
};\n\
zone \"id.server\" chaos {\n\
type master;\n\
database \"_builtin id\";\n\
};\n\
};\n\
";
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.h,v 1.70 2002/09/10 04:45:54 marka Exp $ */
/* $Id: server.h,v 1.71 2003/01/20 05:46:10 marka Exp $ */
#ifndef NAMED_SERVER_H
#define NAMED_SERVER_H 1
......@@ -56,6 +56,9 @@ struct ns_server {
char * version; /* User-specified version */
isc_boolean_t hostname_set; /* User has set hostname */
char * hostname; /* User-specified hostname */
/* Use hostname for server id */
isc_boolean_t server_usehostname;
char * server_id; /* User-specified server id */
/*
* Current ACL environment. This defines the
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.392 2003/01/16 03:59:23 marka Exp $ */
/* $Id: server.c,v 1.393 2003/01/20 05:46:09 marka Exp $ */
#include <config.h>
......@@ -2259,6 +2259,18 @@ load_configuration(const char *filename, ns_server_t *server,
server->hostname_set = ISC_FALSE;
}
obj = NULL;
result = ns_config_get(maps, "server-id", &obj);
server->server_usehostname = ISC_FALSE;
if (result == ISC_R_SUCCESS && cfg_obj_isboolean(obj)) {
server->server_usehostname = ISC_TRUE;
} else if (result == ISC_R_SUCCESS) {
CHECKM(setoptstring(server, &server->server_id, obj), "strdup");
} else {
result = setoptstring(server, &server->server_id, NULL);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
}
obj = NULL;
result = ns_config_get(maps, "flush-zones-on-shutdown", &obj);
if (result == ISC_R_SUCCESS) {
......@@ -2571,6 +2583,8 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
server->hostname = NULL;
server->version_set = ISC_FALSE;
server->version = NULL;
server->server_usehostname = ISC_FALSE;
server->server_id = NULL;
CHECKFATAL(dns_stats_alloccounters(ns_g_mctx, &server->querystats),
"dns_stats_alloccounters");
......@@ -2603,6 +2617,8 @@ ns_server_destroy(ns_server_t **serverp) {
isc_mem_free(server->mctx, server->version);
if (server->hostname != NULL)
isc_mem_free(server->mctx, server->hostname);
if (server->server_id != NULL)
isc_mem_free(server->mctx, server->server_id);
dns_zonemgr_detach(&server->zonemgr);
......
......@@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
<!-- File: $Id: Bv9ARM-book.xml,v 1.212 2003/01/16 03:59:24 marka Exp $ -->
<!-- File: $Id: Bv9ARM-book.xml,v 1.213 2003/01/20 05:46:10 marka Exp $ -->
<book>
<title>BIND 9 Administrator Reference Manual</title>
......@@ -2690,6 +2690,7 @@ statement in the <filename>named.conf</filename> file:</para>
<programlisting>options {
<optional> version <replaceable>version_string</replaceable>; </optional>
<optional> hostname <replaceable>hostname_string</replaceable>; </optional>
<optional> server-id <replaceable>server_id_string</replaceable>; </optional>
<optional> directory <replaceable>path_name</replaceable>; </optional>
<optional> key-directory <replaceable>path_name</replaceable>; </optional>
<optional> named-xfer <replaceable>path_name</replaceable>; </optional>
......@@ -4051,10 +4052,24 @@ with type <command>TXT</command>, class <command>CHAOS</command>.
This defaults to the hostname of the machine hosting the name server as
found by gethostname(). The primary purpose of such queries is to
identify which of a group of anycast servers is actually
answering your queries. Specifying <command>hostname none</command>
answering your queries. Specifying <command>hostname none;</command>
disables processing of the queries.</para>
</listitem></varlistentry>
<varlistentry><term><command>server-id</command></term>
<listitem><para>The ID of the server should report via a query of
the name <filename>ID.SERVER</filename>
with type <command>TXT</command>, class <command>CHAOS</command>.
The primary purpose of such queries is to
identify which of a group of anycast servers is actually
answering your queries. Specifying <command>server-id none;</command>
disables processing of the queries.
Specifying <command>server-id hostname;</command> will cause named to
use the hostname as found by gethostname().
The default <command>server-id</command> is <command>none</command>.
</para>
</listitem></varlistentry>
</variablelist>
</sect3>
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: namedconf.c,v 1.12 2003/01/16 03:59:28 marka Exp $ */
/* $Id: namedconf.c,v 1.13 2003/01/20 05:46:11 marka Exp $ */
#include <config.h>
......@@ -442,6 +442,52 @@ doc_qstringornone(cfg_printer_t *pctx, const cfg_type_t *type) {
static cfg_type_t cfg_type_qstringornone = {
"qstringornone", parse_qstringornone, NULL, doc_qstringornone, NULL, NULL };
/*
* keyword hostname
*/
static void
print_hostname(cfg_printer_t *pctx, cfg_obj_t *obj) {
UNUSED(obj);
cfg_print_chars(pctx, "hostname", 4);
}
static cfg_type_t cfg_type_hostname = {
"hostname", NULL, print_hostname, NULL, &cfg_rep_boolean, NULL
};
/*
* "server-id" arguement.
*/
static isc_result_t
parse_serverid(cfg_parser_t *pctx, const cfg_type_t *type,
cfg_obj_t **ret)
{
isc_result_t result;
CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
if (pctx->token.type == isc_tokentype_string &&
strcasecmp(TOKEN_STRING(pctx), "none") == 0)
return (cfg_create_obj(pctx, &cfg_type_none, ret));
if (pctx->token.type == isc_tokentype_string &&
strcasecmp(TOKEN_STRING(pctx), "hostname") == 0) {
return (cfg_create_obj(pctx, &cfg_type_hostname, ret));
}
cfg_ungettoken(pctx);
return (cfg_parse_qstring(pctx, type, ret));
cleanup:
return (result);
}
static void
doc_serverid(cfg_printer_t *pctx, const cfg_type_t *type) {
UNUSED(type);
cfg_print_chars(pctx, "( <quoted_string> | none | hostname )", 26);
}
static cfg_type_t cfg_type_serverid = {
"serverid", parse_serverid, NULL, doc_serverid, NULL, NULL };
/*
* Clauses that can be found within the top level of the named.conf
* file only.
......@@ -501,6 +547,7 @@ options_clauses[] = {
{ "recursive-clients", &cfg_type_uint32, 0 },
{ "serial-queries", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },
{ "serial-query-rate", &cfg_type_uint32, 0 },
{ "server-id", &cfg_type_serverid, 0 },
{ "stacksize", &cfg_type_size, 0 },
{ "statistics-file", &cfg_type_qstring, 0 },
{ "statistics-interval", &cfg_type_uint32, CFG_CLAUSEFLAG_NYI },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment