diff options
Diffstat (limited to 'contrib/bind9/lib/isccfg/namedconf.c')
-rw-r--r-- | contrib/bind9/lib/isccfg/namedconf.c | 355 |
1 files changed, 248 insertions, 107 deletions
diff --git a/contrib/bind9/lib/isccfg/namedconf.c b/contrib/bind9/lib/isccfg/namedconf.c index d54bbe2..65e30a2 100644 --- a/contrib/bind9/lib/isccfg/namedconf.c +++ b/contrib/bind9/lib/isccfg/namedconf.c @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: namedconf.c,v 1.21.44.34 2006/03/02 00:37:20 marka Exp $ */ +/* $Id: namedconf.c,v 1.30.18.38 2006/05/03 01:46:40 marka Exp $ */ + +/*! \file */ #include <config.h> @@ -32,18 +34,18 @@ #define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base) -/* Check a return value. */ +/*% Check a return value. */ #define CHECK(op) \ do { result = (op); \ if (result != ISC_R_SUCCESS) goto cleanup; \ } while (0) -/* Clean up a configuration object if non-NULL. */ +/*% Clean up a configuration object if non-NULL. */ #define CLEANUP_OBJ(obj) \ do { if ((obj) != NULL) cfg_obj_destroy(pctx, &(obj)); } while (0) -/* +/*% * Forward declarations of static functions. */ @@ -71,10 +73,12 @@ static cfg_type_t cfg_type_addrmatchelt; static cfg_type_t cfg_type_bracketed_aml; static cfg_type_t cfg_type_bracketed_namesockaddrkeylist; static cfg_type_t cfg_type_bracketed_sockaddrlist; +static cfg_type_t cfg_type_bracketed_sockaddrnameportlist; static cfg_type_t cfg_type_controls; static cfg_type_t cfg_type_controls_sockaddr; static cfg_type_t cfg_type_destinationlist; static cfg_type_t cfg_type_dialuptype; +static cfg_type_t cfg_type_ixfrdifftype; static cfg_type_t cfg_type_key; static cfg_type_t cfg_type_logfile; static cfg_type_t cfg_type_logging; @@ -104,8 +108,35 @@ static cfg_type_t cfg_type_view; static cfg_type_t cfg_type_viewopts; static cfg_type_t cfg_type_zone; static cfg_type_t cfg_type_zoneopts; +static cfg_type_t cfg_type_dynamically_loadable_zones; +static cfg_type_t cfg_type_dynamically_loadable_zones_opts; + +/* + * Clauses that can be found in a 'dynamically loadable zones' statement + */ +static cfg_clausedef_t +dynamically_loadable_zones_clauses[] = { + { "database", &cfg_type_astring, 0 }, + { NULL, NULL, 0 } +}; + +/* + * A dynamically loadable zones statement. + */ +static cfg_tuplefielddef_t dynamically_loadable_zones_fields[] = { + { "name", &cfg_type_astring, 0 }, + { "options", &cfg_type_dynamically_loadable_zones_opts, 0 }, + { NULL, NULL, 0 } +}; + +static cfg_type_t cfg_type_dynamically_loadable_zones = { + "dlz", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, + &cfg_rep_tuple, + dynamically_loadable_zones_fields + }; -/* tkey-dhkey */ + +/*% tkey-dhkey */ static cfg_tuplefielddef_t tkey_dhkey_fields[] = { { "name", &cfg_type_qstring, 0 }, @@ -118,7 +149,7 @@ static cfg_type_t cfg_type_tkey_dhkey = { tkey_dhkey_fields }; -/* listen-on */ +/*% listen-on */ static cfg_tuplefielddef_t listenon_fields[] = { { "port", &cfg_type_optional_port, 0 }, @@ -128,7 +159,7 @@ static cfg_tuplefielddef_t listenon_fields[] = { static cfg_type_t cfg_type_listenon = { "listenon", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, listenon_fields }; -/* acl */ +/*% acl */ static cfg_tuplefielddef_t acl_fields[] = { { "name", &cfg_type_astring, 0 }, @@ -139,7 +170,7 @@ static cfg_tuplefielddef_t acl_fields[] = { static cfg_type_t cfg_type_acl = { "acl", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, acl_fields }; -/* masters */ +/*% masters */ static cfg_tuplefielddef_t masters_fields[] = { { "name", &cfg_type_astring, 0 }, { "port", &cfg_type_optional_port, 0 }, @@ -150,7 +181,7 @@ static cfg_tuplefielddef_t masters_fields[] = { static cfg_type_t cfg_type_masters = { "masters", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, masters_fields }; -/* +/*% * "sockaddrkeylist", a list of socket addresses with optional keys * and an optional default port, as used in the masters option. * E.g., @@ -183,7 +214,7 @@ static cfg_type_t cfg_type_namesockaddrkeylist = { namesockaddrkeylist_fields }; -/* +/*% * A list of socket addresses with an optional default port, * as used in the also-notify option. E.g., * "port 1234 { 10.0.0.1; 1::2 port 69; }" @@ -198,7 +229,7 @@ static cfg_type_t cfg_type_portiplist = { portiplist_fields }; -/* +/*% * A public key, as in the "pubkey" statement. */ static cfg_tuplefielddef_t pubkey_fields[] = { @@ -211,7 +242,7 @@ static cfg_tuplefielddef_t pubkey_fields[] = { static cfg_type_t cfg_type_pubkey = { "pubkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, pubkey_fields }; -/* +/*% * A list of RR types, used in grant statements. * Note that the old parser allows quotes around the RR type names. */ @@ -227,13 +258,13 @@ static cfg_type_t cfg_type_mode = { }; static const char *matchtype_enums[] = { - "name", "subdomain", "wildcard", "self", NULL }; + "name", "subdomain", "wildcard", "self", "selfsub", "selfwild", NULL }; static cfg_type_t cfg_type_matchtype = { "matchtype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string, &matchtype_enums }; -/* +/*% * A grant statement, used in the update policy. */ static cfg_tuplefielddef_t grant_fields[] = { @@ -252,7 +283,7 @@ static cfg_type_t cfg_type_updatepolicy = { &cfg_rep_list, &cfg_type_grant }; -/* +/*% * A view statement. */ static cfg_tuplefielddef_t view_fields[] = { @@ -264,7 +295,7 @@ static cfg_tuplefielddef_t view_fields[] = { static cfg_type_t cfg_type_view = { "view", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, view_fields }; -/* +/*% * A zone statement. */ static cfg_tuplefielddef_t zone_fields[] = { @@ -276,7 +307,7 @@ static cfg_tuplefielddef_t zone_fields[] = { static cfg_type_t cfg_type_zone = { "zone", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, zone_fields }; -/* +/*% * A "category" clause in the "logging" statement. */ static cfg_tuplefielddef_t category_fields[] = { @@ -288,7 +319,7 @@ static cfg_type_t cfg_type_category = { "category", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, category_fields }; -/* +/*% * A trusted key, as used in the "trusted-keys" statement. */ static cfg_tuplefielddef_t trustedkey_fields[] = { @@ -325,7 +356,7 @@ static cfg_type_t cfg_type_optional_wild_name = { print_keyvalue, doc_optional_keyvalue, &cfg_rep_string, &wild_name_kw }; -/* +/*% * An rrset ordering element. */ static cfg_tuplefielddef_t rrsetorderingelement_fields[] = { @@ -341,7 +372,7 @@ static cfg_type_t cfg_type_rrsetorderingelement = { rrsetorderingelement_fields }; -/* +/*% * A global or view "check-names" option. Note that the zone * "check-names" option has a different syntax. */ @@ -385,7 +416,7 @@ static cfg_type_t cfg_type_optional_port = { doc_optional_keyvalue, &cfg_rep_uint32, &port_kw }; -/* A list of keys, as in the "key" clause of the controls statement. */ +/*% A list of keys, as in the "key" clause of the controls statement. */ static cfg_type_t cfg_type_keylist = { "keylist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_astring @@ -405,8 +436,8 @@ static cfg_type_t cfg_type_forwardtype = { static const char *zonetype_enums[] = { "master", "slave", "stub", "hint", "forward", "delegation-only", NULL }; static cfg_type_t cfg_type_zonetype = { - "zonetype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string, - &zonetype_enums + "zonetype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, + &cfg_rep_string, &zonetype_enums }; static const char *loglevel_enums[] = { @@ -423,7 +454,7 @@ static cfg_type_t cfg_type_transferformat = { &transferformat_enums }; -/* +/*% * The special keyword "none", as used in the pid-file option. */ @@ -437,7 +468,7 @@ static cfg_type_t cfg_type_none = { "none", NULL, print_none, NULL, &cfg_rep_void, NULL }; -/* +/*% * A quoted string or the special keyword "none". Used in the pid-file option. */ static isc_result_t @@ -464,7 +495,7 @@ 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 */ @@ -478,7 +509,7 @@ static cfg_type_t cfg_type_hostname = { "hostname", NULL, print_hostname, NULL, &cfg_rep_boolean, NULL }; -/* +/*% * "server-id" argument. */ @@ -510,7 +541,7 @@ doc_serverid(cfg_printer_t *pctx, const cfg_type_t *type) { static cfg_type_t cfg_type_serverid = { "serverid", parse_serverid, NULL, doc_serverid, NULL, NULL }; -/* +/*% * Port list. */ static isc_result_t @@ -539,7 +570,7 @@ static cfg_type_t cfg_type_bracketed_portlist = { &cfg_rep_list, &cfg_type_port }; -/* +/*% * Clauses that can be found within the top level of the named.conf * file only. */ @@ -555,7 +586,7 @@ namedconf_clauses[] = { { NULL, NULL, 0 } }; -/* +/*% * Clauses that can occur at the top level or in the view * statement, but not in the options block. */ @@ -563,12 +594,14 @@ static cfg_clausedef_t namedconf_or_view_clauses[] = { { "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI }, { "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI }, + /* only 1 DLZ per view allowed */ + { "dlz", &cfg_type_dynamically_loadable_zones, 0 }, { "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI }, { "trusted-keys", &cfg_type_trustedkeys, CFG_CLAUSEFLAG_MULTI }, { NULL, NULL, 0 } }; -/* +/*% * Clauses that can be found within the 'options' statement. */ static cfg_clausedef_t @@ -660,7 +693,13 @@ static cfg_type_t cfg_type_mustbesecure = { &cfg_rep_tuple, mustbesecure_fields }; -/* +static const char *masterformat_enums[] = { "text", "raw", NULL }; +static cfg_type_t cfg_type_masterformat = { + "masterformat", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, + &cfg_rep_string, &masterformat_enums +}; + +/*% * dnssec-lookaside */ @@ -682,13 +721,14 @@ static cfg_type_t cfg_type_lookaside = { &cfg_rep_tuple, lookaside_fields }; -/* +/*% * Clauses that can be found within the 'view' statement, * with defaults in the 'options' statement. */ static cfg_clausedef_t view_clauses[] = { + { "allow-query-cache", &cfg_type_bracketed_aml, 0 }, { "allow-recursion", &cfg_type_bracketed_aml, 0 }, { "allow-v6-synthesis", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_OBSOLETE }, @@ -723,17 +763,31 @@ view_clauses[] = { { "preferred-glue", &cfg_type_astring, 0 }, { "dual-stack-servers", &cfg_type_nameportiplist, 0 }, { "edns-udp-size", &cfg_type_uint32, 0 }, + { "max-udp-size", &cfg_type_uint32, 0 }, { "root-delegation-only", &cfg_type_optional_exclude, 0 }, { "disable-algorithms", &cfg_type_disablealgorithm, CFG_CLAUSEFLAG_MULTI }, { "dnssec-enable", &cfg_type_boolean, 0 }, + { "dnssec-validation", &cfg_type_boolean, 0 }, { "dnssec-lookaside", &cfg_type_lookaside, CFG_CLAUSEFLAG_MULTI }, { "dnssec-must-be-secure", &cfg_type_mustbesecure, CFG_CLAUSEFLAG_MULTI }, + { "dnssec-accept-expired", &cfg_type_boolean, 0 }, + { "ixfr-from-differences", &cfg_type_ixfrdifftype, 0 }, + { "acache-enable", &cfg_type_boolean, 0 }, + { "acache-cleaning-interval", &cfg_type_uint32, 0 }, + { "max-acache-size", &cfg_type_sizenodefault, 0 }, + { "clients-per-query", &cfg_type_uint32, 0 }, + { "max-clients-per-query", &cfg_type_uint32, 0 }, + { "empty-server", &cfg_type_astring, 0 }, + { "empty-contact", &cfg_type_astring, 0 }, + { "empty-zones-enable", &cfg_type_boolean, 0 }, + { "disable-empty-zone", &cfg_type_astring, CFG_CLAUSEFLAG_MULTI }, + { "zero-no-soa-ttl-cache", &cfg_type_boolean, 0 }, { NULL, NULL, 0 } }; -/* +/*% * Clauses that can be found within the 'view' statement only. */ static cfg_clausedef_t @@ -744,7 +798,7 @@ view_only_clauses[] = { { NULL, NULL, 0 } }; -/* +/*% * Clauses that can be found in a 'zone' statement, * with defaults in the 'view' or 'options' statement. */ @@ -752,16 +806,18 @@ static cfg_clausedef_t zone_clauses[] = { { "allow-query", &cfg_type_bracketed_aml, 0 }, { "allow-transfer", &cfg_type_bracketed_aml, 0 }, + { "allow-update", &cfg_type_bracketed_aml, 0 }, { "allow-update-forwarding", &cfg_type_bracketed_aml, 0 }, { "allow-notify", &cfg_type_bracketed_aml, 0 }, + { "masterfile-format", &cfg_type_masterformat, 0 }, { "notify", &cfg_type_notifytype, 0 }, { "notify-source", &cfg_type_sockaddr4wild, 0 }, { "notify-source-v6", &cfg_type_sockaddr6wild, 0 }, { "also-notify", &cfg_type_portiplist, 0 }, + { "notify-delay", &cfg_type_uint32, 0 }, { "dialup", &cfg_type_dialuptype, 0 }, { "forward", &cfg_type_forwardtype, 0 }, { "forwarders", &cfg_type_portiplist, 0 }, - { "ixfr-from-differences", &cfg_type_boolean, 0 }, { "maintain-ixfr-base", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, { "max-ixfr-log-size", &cfg_type_size, CFG_CLAUSEFLAG_OBSOLETE }, { "max-journal-size", &cfg_type_sizenodefault, 0 }, @@ -782,18 +838,26 @@ zone_clauses[] = { { "use-alt-transfer-source", &cfg_type_boolean, 0 }, { "zone-statistics", &cfg_type_boolean, 0 }, { "key-directory", &cfg_type_qstring, 0 }, + { "check-wildcard", &cfg_type_boolean, 0 }, + { "check-integrity", &cfg_type_boolean, 0 }, + { "check-mx", &cfg_type_checkmode, 0 }, + { "check-mx-cname", &cfg_type_checkmode, 0 }, + { "check-srv-cname", &cfg_type_checkmode, 0 }, + { "check-sibling", &cfg_type_boolean, 0 }, + { "zero-no-soa-ttl", &cfg_type_boolean, 0 }, + { "update-check-ksk", &cfg_type_boolean, 0 }, { NULL, NULL, 0 } }; -/* +/*% * Clauses that can be found in a 'zone' statement * only. */ static cfg_clausedef_t zone_only_clauses[] = { { "type", &cfg_type_zonetype, 0 }, - { "allow-update", &cfg_type_bracketed_aml, 0 }, { "file", &cfg_type_qstring, 0 }, + { "journal", &cfg_type_qstring, 0 }, { "ixfr-base", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE }, { "ixfr-tmp-file", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE }, { "masters", &cfg_type_namesockaddrkeylist, 0 }, @@ -807,11 +871,12 @@ zone_only_clauses[] = { * the zone options and the global/view options. Ugh. */ { "check-names", &cfg_type_checkmode, 0 }, + { "ixfr-from-differences", &cfg_type_boolean, 0 }, { NULL, NULL, 0 } }; -/* The top-level named.conf syntax. */ +/*% The top-level named.conf syntax. */ static cfg_clausedef_t * namedconf_clausesets[] = { @@ -825,7 +890,7 @@ LIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_namedconf = { &cfg_rep_map, namedconf_clausesets }; -/* The "options" statement syntax. */ +/*% The "options" statement syntax. */ static cfg_clausedef_t * options_clausesets[] = { @@ -837,7 +902,7 @@ options_clausesets[] = { static cfg_type_t cfg_type_options = { "options", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, options_clausesets }; -/* The "view" statement syntax. */ +/*% The "view" statement syntax. */ static cfg_clausedef_t * view_clausesets[] = { @@ -845,12 +910,13 @@ view_clausesets[] = { namedconf_or_view_clauses, view_clauses, zone_clauses, + dynamically_loadable_zones_clauses, NULL }; static cfg_type_t cfg_type_viewopts = { "view", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, view_clausesets }; -/* The "zone" statement syntax. */ +/*% The "zone" statement syntax. */ static cfg_clausedef_t * zone_clausesets[] = { @@ -859,9 +925,23 @@ zone_clausesets[] = { NULL }; static cfg_type_t cfg_type_zoneopts = { - "zoneopts", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, zone_clausesets }; - -/* + "zoneopts", cfg_parse_map, cfg_print_map, + cfg_doc_map, &cfg_rep_map, zone_clausesets }; + +/*% The "dynamically loadable zones" statement syntax. */ + +static cfg_clausedef_t * +dynamically_loadable_zones_clausesets[] = { + dynamically_loadable_zones_clauses, + NULL +}; +static cfg_type_t cfg_type_dynamically_loadable_zones_opts = { + "dynamically_loadable_zones_opts", cfg_parse_map, + cfg_print_map, cfg_doc_map, &cfg_rep_map, + dynamically_loadable_zones_clausesets +}; + +/*% * Clauses that can be found within the 'key' statement. */ static cfg_clausedef_t @@ -877,10 +957,12 @@ key_clausesets[] = { NULL }; static cfg_type_t cfg_type_key = { - "key", cfg_parse_named_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, key_clausesets }; + "key", cfg_parse_named_map, cfg_print_map, + cfg_doc_map, &cfg_rep_map, key_clausesets +}; -/* +/*% * Clauses that can be found in a 'server' statement. */ static cfg_clausedef_t @@ -893,6 +975,12 @@ server_clauses[] = { { "transfer-format", &cfg_type_transferformat, 0 }, { "keys", &cfg_type_server_key_kludge, 0 }, { "edns", &cfg_type_boolean, 0 }, + { "edns-udp-size", &cfg_type_uint32, 0 }, + { "max-udp-size", &cfg_type_uint32, 0 }, + { "notify-source", &cfg_type_sockaddr4wild, 0 }, + { "notify-source-v6", &cfg_type_sockaddr6wild, 0 }, + { "query-source", &cfg_type_querysource4, 0 }, + { "query-source-v6", &cfg_type_querysource6, 0 }, { "transfer-source", &cfg_type_sockaddr4wild, 0 }, { "transfer-source-v6", &cfg_type_sockaddr6wild, 0 }, { NULL, NULL, 0 } @@ -903,12 +991,12 @@ server_clausesets[] = { NULL }; static cfg_type_t cfg_type_server = { - "server", cfg_parse_addressed_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, + "server", cfg_parse_netprefix_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, server_clausesets }; -/* +/*% * Clauses that can be found in a 'channel' clause in the * 'logging' statement. * @@ -941,12 +1029,12 @@ static cfg_type_t cfg_type_channel = { &cfg_rep_map, channel_clausesets }; -/* A list of log destination, used in the "category" clause. */ +/*% A list of log destination, used in the "category" clause. */ static cfg_type_t cfg_type_destinationlist = { "destinationlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_astring }; -/* +/*% * Clauses that can be found in a 'logging' statement. */ static cfg_clausedef_t @@ -1028,14 +1116,14 @@ parse_sizeval(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { return (result); } -/* +/*% * A size value (number + optional unit). */ static cfg_type_t cfg_type_sizeval = { "sizeval", parse_sizeval, cfg_print_uint64, cfg_doc_terminal, &cfg_rep_uint64, NULL }; -/* +/*% * A size, "unlimited", or "default". */ @@ -1050,7 +1138,7 @@ static cfg_type_t cfg_type_size = { &cfg_rep_string, size_enums }; -/* +/*% * A size or "unlimited", but not "default". */ static const char *sizenodefault_enums[] = { "unlimited", NULL }; @@ -1059,7 +1147,7 @@ static cfg_type_t cfg_type_sizenodefault = { &cfg_rep_string, sizenodefault_enums }; -/* +/*% * optional_keyvalue */ static isc_result_t @@ -1163,7 +1251,7 @@ static cfg_type_t cfg_type_dialuptype = { &cfg_rep_string, dialup_enums }; -static const char *notify_enums[] = { "explicit", NULL }; +static const char *notify_enums[] = { "explicit", "master-only", NULL }; static isc_result_t parse_notify_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret)); @@ -1173,6 +1261,16 @@ static cfg_type_t cfg_type_notifytype = { &cfg_rep_string, notify_enums, }; +static const char *ixfrdiff_enums[] = { "master", "slave", NULL }; +static isc_result_t +parse_ixfrdiff_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { + return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret)); +} +static cfg_type_t cfg_type_ixfrdifftype = { + "ixfrdiff", parse_ixfrdiff_type, cfg_print_ustring, doc_enum_or_other, + &cfg_rep_string, ixfrdiff_enums, +}; + static keyword_type_t key_kw = { "key", &cfg_type_astring }; LIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_keyref = { @@ -1185,14 +1283,14 @@ static cfg_type_t cfg_type_optional_keyref = { doc_optional_keyvalue, &cfg_rep_string, &key_kw }; -/* +/*% * A "controls" statement is represented as a map with the multivalued - * "inet" and "unix" clauses. Inet controls are tuples; unix controls - * are cfg_unsupported_t objects. + * "inet" and "unix" clauses. */ static keyword_type_t controls_allow_kw = { "allow", &cfg_type_bracketed_aml }; + static cfg_type_t cfg_type_controls_allow = { "controls_allow", parse_keyvalue, print_keyvalue, doc_keyvalue, @@ -1201,6 +1299,7 @@ static cfg_type_t cfg_type_controls_allow = { static keyword_type_t controls_keys_kw = { "keys", &cfg_type_keylist }; + static cfg_type_t cfg_type_controls_keys = { "controls_keys", parse_optional_keyvalue, print_keyvalue, doc_optional_keyvalue, @@ -1213,16 +1312,57 @@ static cfg_tuplefielddef_t inetcontrol_fields[] = { { "keys", &cfg_type_controls_keys, 0 }, { NULL, NULL, 0 } }; + static cfg_type_t cfg_type_inetcontrol = { "inetcontrol", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, inetcontrol_fields }; +static keyword_type_t controls_perm_kw = { + "perm", &cfg_type_uint32 }; + +static cfg_type_t cfg_type_controls_perm = { + "controls_perm", parse_keyvalue, + print_keyvalue, doc_keyvalue, + &cfg_rep_uint32, &controls_perm_kw +}; + +static keyword_type_t controls_owner_kw = { + "owner", &cfg_type_uint32 }; + +static cfg_type_t cfg_type_controls_owner = { + "controls_owner", parse_keyvalue, + print_keyvalue, doc_keyvalue, + &cfg_rep_uint32, &controls_owner_kw +}; + +static keyword_type_t controls_group_kw = { + "group", &cfg_type_uint32 }; + +static cfg_type_t cfg_type_controls_group = { + "controls_allow", parse_keyvalue, + print_keyvalue, doc_keyvalue, + &cfg_rep_uint32, &controls_group_kw +}; + +static cfg_tuplefielddef_t unixcontrol_fields[] = { + { "path", &cfg_type_qstring, 0 }, + { "perm", &cfg_type_controls_perm, 0 }, + { "owner", &cfg_type_controls_owner, 0 }, + { "group", &cfg_type_controls_group, 0 }, + { "keys", &cfg_type_controls_keys, 0 }, + { NULL, NULL, 0 } +}; + +static cfg_type_t cfg_type_unixcontrol = { + "unixcontrol", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, + unixcontrol_fields +}; + static cfg_clausedef_t controls_clauses[] = { { "inet", &cfg_type_inetcontrol, CFG_CLAUSEFLAG_MULTI }, - { "unix", &cfg_type_unsupported, - CFG_CLAUSEFLAG_MULTI|CFG_CLAUSEFLAG_NOTIMP }, + { "unix", &cfg_type_unixcontrol, CFG_CLAUSEFLAG_MULTI }, { NULL, NULL, 0 } }; @@ -1235,7 +1375,7 @@ static cfg_type_t cfg_type_controls = { "controls", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, &controls_clausesets }; -/* +/*% * An optional class, as used in view and zone statements. */ static isc_result_t @@ -1257,24 +1397,24 @@ static cfg_type_t cfg_type_optional_class = { }; static isc_result_t -parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) { +parse_querysource(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { isc_result_t result; cfg_obj_t *obj = NULL; isc_netaddr_t netaddr; in_port_t port; unsigned int have_address = 0; unsigned int have_port = 0; + const unsigned int *flagp = type->of; - if ((flags & CFG_ADDR_V4OK) != 0) + if ((*flagp & CFG_ADDR_V4OK) != 0) isc_netaddr_any(&netaddr); - else if ((flags & CFG_ADDR_V6OK) != 0) + else if ((*flagp & CFG_ADDR_V6OK) != 0) isc_netaddr_any6(&netaddr); else INSIST(0); port = 0; - CHECK(cfg_create_obj(pctx, &cfg_type_querysource, &obj)); for (;;) { CHECK(cfg_peektoken(pctx, 0)); if (pctx->token.type == isc_tokentype_string) { @@ -1283,8 +1423,7 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) { { /* read "address" */ CHECK(cfg_gettoken(pctx, 0)); - CHECK(cfg_parse_rawaddr(pctx, - flags | CFG_ADDR_WILDOK, + CHECK(cfg_parse_rawaddr(pctx, *flagp, &netaddr)); have_address++; } else if (strcasecmp(TOKEN_STRING(pctx), "port") == 0) @@ -1295,6 +1434,8 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) { CFG_ADDR_WILDOK, &port)); have_port++; + } else if (have_port == 0 && have_address == 0) { + return (cfg_parse_sockaddr(pctx, type, ret)); } else { cfg_parser_error(pctx, CFG_LOG_NEAR, "expected 'address' or 'port'"); @@ -1309,6 +1450,7 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) { return (ISC_R_UNEXPECTEDTOKEN); } + CHECK(cfg_create_obj(pctx, &cfg_type_querysource, &obj)); isc_sockaddr_fromnetaddr(&obj->value.sockaddr, &netaddr, port); *ret = obj; return (ISC_R_SUCCESS); @@ -1319,18 +1461,6 @@ parse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) { return (result); } -static isc_result_t -parse_querysource4(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { - UNUSED(type); - return (parse_querysource(pctx, CFG_ADDR_V4OK, ret)); -} - -static isc_result_t -parse_querysource6(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { - UNUSED(type); - return (parse_querysource(pctx, CFG_ADDR_V6OK, ret)); -} - static void print_querysource(cfg_printer_t *pctx, const cfg_obj_t *obj) { isc_netaddr_t na; @@ -1341,18 +1471,23 @@ print_querysource(cfg_printer_t *pctx, const cfg_obj_t *obj) { cfg_print_rawuint(pctx, isc_sockaddr_getport(&obj->value.sockaddr)); } +static unsigned int sockaddr4wild_flags = CFG_ADDR_WILDOK | CFG_ADDR_V4OK; +static unsigned int sockaddr6wild_flags = CFG_ADDR_WILDOK | CFG_ADDR_V6OK; static cfg_type_t cfg_type_querysource4 = { - "querysource4", parse_querysource4, NULL, cfg_doc_terminal, - NULL, NULL + "querysource4", parse_querysource, NULL, cfg_doc_terminal, + NULL, &sockaddr4wild_flags }; + static cfg_type_t cfg_type_querysource6 = { - "querysource6", parse_querysource6, NULL, cfg_doc_terminal, - NULL, NULL + "querysource6", parse_querysource, NULL, cfg_doc_terminal, + NULL, &sockaddr6wild_flags }; + static cfg_type_t cfg_type_querysource = { - "querysource", NULL, print_querysource, NULL, &cfg_rep_sockaddr, NULL }; + "querysource", NULL, print_querysource, NULL, &cfg_rep_sockaddr, NULL +}; -/* addrmatchelt */ +/*% addrmatchelt */ static isc_result_t parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { @@ -1396,7 +1531,7 @@ parse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) return (result); } -/* +/*% * A negated address match list element (like "! 10.0.0.1"). * Somewhat sneakily, the caller is expected to parse the * "!", but not to print it. @@ -1418,21 +1553,21 @@ static cfg_type_t cfg_type_negated = { &negated_fields }; -/* An address match list element */ +/*% An address match list element */ static cfg_type_t cfg_type_addrmatchelt = { "address_match_element", parse_addrmatchelt, NULL, cfg_doc_terminal, NULL, NULL }; -/* A bracketed address match list */ +/*% A bracketed address match list */ static cfg_type_t cfg_type_bracketed_aml = { "bracketed_aml", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_addrmatchelt }; -/* +/*% * The socket address syntax in the "controls" statement is silly. * It allows both socket address families, but also allows "*", * whis is gratuitously interpreted as the IPv4 wildcard address. @@ -1444,7 +1579,7 @@ static cfg_type_t cfg_type_controls_sockaddr = { cfg_doc_sockaddr, &cfg_rep_sockaddr, &controls_sockaddr_flags }; -/* +/*% * Handle the special kludge syntax of the "keys" clause in the "server" * statement, which takes a single key with or without braces and semicolon. */ @@ -1483,7 +1618,7 @@ static cfg_type_t cfg_type_server_key_kludge = { }; -/* +/*% * An optional logging facility. */ @@ -1509,7 +1644,7 @@ static cfg_type_t cfg_type_optional_facility = { NULL, NULL }; -/* +/*% * A log severity. Return as a string, except "debug N", * which is returned as a keyword object. */ @@ -1554,7 +1689,7 @@ static cfg_type_t cfg_type_logseverity = { "log_severity", parse_logseverity, NULL, cfg_doc_terminal, NULL, NULL }; -/* +/*% * The "file" clause of the "channel" statement. * This is yet another special case. */ @@ -1642,20 +1777,19 @@ static cfg_type_t cfg_type_logfile = { &cfg_rep_tuple, logfile_fields }; -/* An IPv4/IPv6 address with optional port, "*" accepted as wildcard. */ -static unsigned int sockaddr4wild_flags = CFG_ADDR_WILDOK | CFG_ADDR_V4OK; +/*% An IPv4 address with optional port, "*" accepted as wildcard. */ static cfg_type_t cfg_type_sockaddr4wild = { "sockaddr4wild", cfg_parse_sockaddr, cfg_print_sockaddr, cfg_doc_sockaddr, &cfg_rep_sockaddr, &sockaddr4wild_flags }; -static unsigned int sockaddr6wild_flags = CFG_ADDR_WILDOK | CFG_ADDR_V6OK; +/*% An IPv6 address with optional port, "*" accepted as wildcard. */ static cfg_type_t cfg_type_sockaddr6wild = { "v6addrportwild", cfg_parse_sockaddr, cfg_print_sockaddr, cfg_doc_sockaddr, &cfg_rep_sockaddr, &sockaddr6wild_flags }; -/* +/*% * lwres */ @@ -1688,17 +1822,21 @@ lwres_clausesets[] = { NULL }; static cfg_type_t cfg_type_lwres = { - "lwres", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, lwres_clausesets }; + "lwres", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, + lwres_clausesets +}; -/* +/*% * rndc */ static cfg_clausedef_t rndcconf_options_clauses[] = { - { "default-server", &cfg_type_astring, 0 }, { "default-key", &cfg_type_astring, 0 }, { "default-port", &cfg_type_uint32, 0 }, + { "default-server", &cfg_type_astring, 0 }, + { "default-source-address", &cfg_type_netaddr4wild, 0 }, + { "default-source-address-v6", &cfg_type_netaddr6wild, 0 }, { NULL, NULL, 0 } }; @@ -1709,14 +1847,17 @@ rndcconf_options_clausesets[] = { }; static cfg_type_t cfg_type_rndcconf_options = { - "rndcconf_options", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, - rndcconf_options_clausesets + "rndcconf_options", cfg_parse_map, cfg_print_map, cfg_doc_map, + &cfg_rep_map, rndcconf_options_clausesets }; static cfg_clausedef_t rndcconf_server_clauses[] = { { "key", &cfg_type_astring, 0 }, { "port", &cfg_type_uint32, 0 }, + { "source-address", &cfg_type_netaddr4wild, 0 }, + { "source-address-v6", &cfg_type_netaddr6wild, 0 }, + { "addresses", &cfg_type_bracketed_sockaddrnameportlist, 0 }, { NULL, NULL, 0 } }; @@ -1727,8 +1868,8 @@ rndcconf_server_clausesets[] = { }; static cfg_type_t cfg_type_rndcconf_server = { - "rndcconf_server", cfg_parse_named_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, - rndcconf_server_clausesets + "rndcconf_server", cfg_parse_named_map, cfg_print_map, cfg_doc_map, + &cfg_rep_map, rndcconf_server_clausesets }; static cfg_clausedef_t @@ -1841,7 +1982,7 @@ static cfg_type_t cfg_type_bracketed_sockaddrnameportlist = { &cfg_rep_list, &cfg_type_sockaddrnameport }; -/* +/*% * A list of socket addresses or name with an optional default port, * as used in the dual-stack-servers option. E.g., * "port 1234 { dual-stack-servers.net; 10.0.0.1; 1::2 port 69; }" @@ -1857,7 +1998,7 @@ static cfg_type_t cfg_type_nameportiplist = { &cfg_rep_tuple, nameportiplist_fields }; -/* +/*% * masters element. */ |