From: Mark Andrews Date: Mon, 20 Jan 2003 05:46:11 +0000 (+0000) Subject: 1417. [func] ID.SERVER/CHAOS is now a built in zone. X-Git-Tag: v9.2.3rc1~104^2~151 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=9bd478a5e6df956a79bbdb5c182d5b44763786ce;p=thirdparty%2Fbind9.git 1417. [func] ID.SERVER/CHAOS is now a built in zone. See "server-id" for how to configure. --- diff --git a/CHANGES b/CHANGES index 0473cd574f0..c0b486ecb3f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +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] diff --git a/bin/named/builtin.c b/bin/named/builtin.c index f0970f9085e..adf4d5523c2 100644 --- a/bin/named/builtin.c +++ b/bin/named/builtin.c @@ -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 @@ -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); diff --git a/bin/named/config.c b/bin/named/config.c index 73e435f3900..95fb39421c1 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -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 @@ -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\ "; diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h index b5906cc4173..6c9fa7b1181 100644 --- a/bin/named/include/named/server.h +++ b/bin/named/include/named/server.h @@ -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 diff --git a/bin/named/server.c b/bin/named/server.c index 291ee84bd05..aee520a387a 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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 @@ -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); diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index c2b07fbdadc..dac7ed88577 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -2,7 +2,7 @@ - + BIND 9 Administrator Reference Manual @@ -2690,6 +2690,7 @@ statement in the named.conf file: options { version version_string; hostname hostname_string; + server-id server_id_string; directory path_name; key-directory path_name; named-xfer path_name; @@ -4051,10 +4052,24 @@ with type TXT, class CHAOS. 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 hostname none +answering your queries. Specifying hostname none; disables processing of the queries. +server-id +The ID of the server should report via a query of +the name ID.SERVER +with type TXT, class CHAOS. +The primary purpose of such queries is to +identify which of a group of anycast servers is actually +answering your queries. Specifying server-id none; +disables processing of the queries. +Specifying server-id hostname; will cause named to +use the hostname as found by gethostname(). +The default server-id is none. + + + diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 5c7e7fece8c..1ae97d0ad98 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -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 @@ -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, "( | 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 },