From eabad792ebe727e8097f4afbe7400310ef8ae9c9 Mon Sep 17 00:00:00 2001 From: James Brister Date: Tue, 13 Jul 1999 14:24:29 +0000 Subject: [PATCH] Remove old config stuff from build. --- bin/named/Makefile.in | 17 +- bin/named/configctx.c | 559 ----------- bin/named/configctx.h | 246 ----- bin/named/confparser.h | 107 -- bin/named/confparser.y | 2152 ---------------------------------------- bin/named/lexer.l | 72 -- bin/named/parser.h | 100 -- bin/named/parser.y | 304 ------ bin/named/server.c | 12 - bin/named/zone.c | 292 ------ bin/named/zone.h | 134 --- 11 files changed, 2 insertions(+), 3993 deletions(-) delete mode 100644 bin/named/configctx.c delete mode 100644 bin/named/configctx.h delete mode 100644 bin/named/confparser.h delete mode 100644 bin/named/confparser.y delete mode 100644 bin/named/lexer.l delete mode 100644 bin/named/parser.h delete mode 100644 bin/named/parser.y delete mode 100644 bin/named/zone.c delete mode 100644 bin/named/zone.h diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in index bdcf7fc552..a5f5f906ba 100644 --- a/bin/named/Makefile.in +++ b/bin/named/Makefile.in @@ -38,7 +38,7 @@ LIBS = ${DEPLIBS} \ TARGETS = named OBJS = server.o udpclient.o tcpclient.o printmsg.o \ - zone.o configctx.o confparser.o interfacemgr.o + interfacemgr.o @BIND9_MAKE_RULES@ @@ -50,17 +50,4 @@ named: ${OBJS} ${DEPLIBS} ${LIBTOOL} ${CC} -o $@ ${OBJS} ${LIBS} clean distclean:: - rm -f ${TARGETS} confparser.c confparser_p.h - -confparser.c: ${srcdir}/confparser.y - ${YACC} -d ${srcdir}/confparser.y - mv y.tab.c confparser.c - mv y.tab.h confparser_p.h - -##confparser.c: confparser.y -## ${YACC} -d confparser.y -## rm -f confparser.c -## sed -e '/^\#line/d' < y.tab.c > confparser.c -## rm -f y.tab.c -## chmod a-w confparser.c -## mv y.tab.h confparser_p.h + rm -f ${TARGETS} diff --git a/bin/named/configctx.c b/bin/named/configctx.c deleted file mode 100644 index 2b0fb58a5b..0000000000 --- a/bin/named/configctx.c +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - - -#include - -#include -#include - -#include - -#include "configctx.h" - - -/* these are the bit definitions for the flag set 1 */ -#define NCACHE_TTL_BIT (1 << 1) -#define TRANSFERS_IN_BIT (1 << 2) -#define TRANSFERS_PER_NS_BIT (1 << 3) -#define TRANSFERS_OUT_BIT (1 << 4) -#define MAX_LOG_BIT (1 << 5) -#define CLEAN_INT_BIT (1 << 6) -#define INTERFACE_INT_BIT (1 << 7) -#define STATS_INT_BIT (1 << 8) -#define HEARDBEAT_INT_BIT (1 << 9) -#define MAX_TRANS_TIME_BIT (1 << 10) -#define DATA_SIZE_BIT (1 << 11) -#define STACK_SIZE_BIT (1 << 12) -#define CORE_SIZE_BIT (1 << 13) -#define FILES_BIT (1 << 14) -#define QUERY_SOURCE_BIT (1 << 15) -#define QUERY_ACL_BIT (1 << 16) -#define TRANSFER_ACL_BIT (1 << 17) -#define BLOCKHOLE_ACL_BIT (1 << 18) -#define TOPOLOGY_BIT (1 << 19) -#define TRANSFER_FORMAT_BIT (1 << 20) -#define FAKE_IQUERY_BIT (1 << 21) -#define RECURSION_BIT (1 << 22) -#define FETCH_GLUE_BIT (1 << 23) -#define NOTIFY_BIT (1 << 24) -#define HOSTSTATS_BIT (1 << 25) -#define DEALLOC_ON_EXIT_BIT (1 << 26) -#define USE_IXFR_BIT (1 << 27) -#define MAINTAIN_IXFR_BASE_BIT (1 << 28) -#define HAS_OLD_CLIENTS_BIT (1 << 29) -#define AUTH_NX_DOMAIN_BIT (1 << 30) -#define MULTIPLE_CNAMES_BIT (1 << 0) - -/* these are the bit definitions for the flag set 2 */ -#define CHECK_NAMES_BIT (1 << 1) -#define USE_ID_POOL_BIT (1 << 2) -#define DIALUP_BIT (1 << 3) - - - -#define CHECKBIT(bit,flags) (((flags) & (bit)) == (bit)) -#define SETBIT(bit, flags) ((flags) |= (bit)) -#define CLEARBIT(bit, flags) ((flags) &= ~(bit)) - -#define CHECKREGION(r) \ - INSIST(((r)->base == NULL && (r)->length == 0) || \ - ((r)->base != NULL && (r)->length > 0)) - -#define FREE_TEXT_REGION(r,m) \ - do { CHECKREGION(r) ; \ - if ((r)->base != NULL) { \ - isc_mem_put(m,(r)->base,(r)->length); \ - (r)->base = NULL; (r)->length = 0; \ - } \ - } while(0) - - -/* I don't much like this, but there's a huge amount of code duplication - * that these macros eliminate - */ - -#define FUNC_SET_FIELD(field, bit, bitset, type) \ -isc_result_t \ -isc_cfg_set_ ## field (isc_cfgctx_t *ctx, type value) \ -{ \ - INSIST(ctx != NULL); \ - INSIST(ctx->options != NULL); \ - \ - ctx->options->field = value; \ - \ - SETBIT(bit, ctx->options->bitset); \ - \ - return (ISC_R_SUCCESS); \ -} - -#define FUNC_GET_FIELD(field, bit, bitset, type) \ -isc_result_t \ -isc_cfg_get_ ## field (isc_cfgctx_t *ctx, type *result) \ -{ \ - INSIST(ctx != NULL); \ - INSIST(ctx->options != NULL); \ - INSIST(result != NULL); \ - \ - if (CHECKBIT(bit,ctx->options->bitset)) { \ - *result = ctx->options->field; \ - return (ISC_R_SUCCESS); \ - } else { \ - return (ISC_R_NOTFOUND); \ - } \ -} - - -#define FUNC_SET_TEXTFIELD(field) \ -isc_result_t \ -isc_cfg_set_ ## field(isc_cfgctx_t *ctx, const char *value) \ -{ \ - isc_result_t res; \ - \ - INSIST(ctx != NULL); \ - \ - res = set_text_region(ctx->mem, &ctx->options->field, value); \ - \ - return (res); \ -} - - -#define FUNC_GET_TEXTFIELD(field) \ -isc_result_t \ -isc_cfg_get_ ## field(isc_cfgctx_t *ctx, const char **result) \ -{ \ - INSIST(ctx != NULL); \ - INSIST(ctx->options != NULL); \ - INSIST(result != NULL); \ - \ - if (ctx->options->field.base != NULL) { \ - *result = ctx->options->field.base; \ - return (ISC_R_SUCCESS); \ - } else { \ - return (ISC_R_NOTFOUND); \ - } \ -} - - - - - -static void freeoptions(isc_cfgoptions_t *opts, isc_mem_t *mem); -static isc_result_t set_text_region(isc_mem_t *mem, - isc_textregion_t *region, - const char *value); -static void opt_print_textregion(FILE *fp, const char *name, - isc_textregion_t r); - - -/*** - *** PUBLIC - ***/ - -isc_result_t -isc_cfg_newctx(isc_mem_t *mem, isc_cfgctx_t **ctx) -{ - isc_cfgctx_t *cfg = NULL; - isc_cfgoptions_t *opts = NULL; - isc_zonectx_t *zonectx = NULL; - isc_result_t res; - - INSIST(mem != NULL); - - cfg = isc_mem_get(mem, sizeof *cfg); - if (cfg == NULL) { - return (ISC_R_NOMEMORY); - } - - memset(cfg, 0x0, sizeof *cfg); - - cfg->mem = mem; - - opts = isc_mem_get(mem, sizeof *opts); - if (opts == NULL) { - isc_mem_put(mem, cfg, sizeof *cfg); - return (ISC_R_NOMEMORY); - } - memset (opts, 0x0, sizeof *opts); - cfg->options = opts; - - if ((res = isc_zone_newcontext(mem, &zonectx)) != ISC_R_SUCCESS) { - isc_mem_put(mem, opts, sizeof *opts); - isc_mem_put(mem, cfg, sizeof *cfg); - - return (res); - } - cfg->zonecontext = zonectx; - - *ctx = cfg ; - - return (ISC_R_SUCCESS); -} - - - - -isc_result_t -isc_cfg_freectx(isc_cfgctx_t **ctx) -{ - isc_cfgctx_t *c ; - - INSIST(ctx != NULL); - - c = *ctx; - - INSIST(c->mem != NULL); - - - if (c->options != NULL) { - freeoptions(c->options, c->mem); - } - - isc_mem_put(c->mem, c, sizeof *c); - *ctx = NULL; - - return (ISC_R_SUCCESS); -} - - - - -isc_result_t -isc_cfg_erase_options(isc_cfgctx_t *ctx) -{ - INSIST(ctx != NULL); - INSIST(ctx->options != NULL); - - freeoptions(ctx->options, ctx->mem); - ctx->options = isc_mem_get(ctx->mem, sizeof *ctx->options); - if (ctx->options == NULL) { - return (ISC_R_NOMEMORY); - } - memset (ctx->options, 0x0, sizeof *ctx->options); - - return (ISC_R_SUCCESS); -} - - -void -isc_cfg_dump_config(FILE *fp, isc_cfgctx_t *cfg) -{ - INSIST(cfg != NULL); - INSIST(fp != NULL); - - isc_cfg_dump_options(fp, cfg->options); - if (cfg->zonecontext != NULL) { - isc_zonectx_dump(fp, cfg->zonecontext); - } -} - - -static void -print_in_units(FILE *fp, unsigned long val) -{ - unsigned long one_gig = (1024 * 1024 * 1024); - unsigned long one_meg = (1024 * 1024); - unsigned long one_k = 1024; - - if ((val % one_gig) == 0) - fprintf(fp, "%luG", val / one_gig); - else if ((val % one_meg) == 0) - fprintf(fp, "%luM", val / one_meg); - else if ((val % one_k) == 0) - fprintf(fp, "%luK", val / one_k); - else if (val == ULONG_MAX) - fprintf(fp, "unlimited"); - else - fprintf(fp, "%lu", val); -} - -void -isc_cfg_dump_options(FILE *fp, isc_cfgoptions_t *options) -{ - INSIST(options != NULL); - INSIST(fp != NULL); - -#define PRINT_AS_MINUTES(field, bit, name, bitfield) \ - if (CHECKBIT(bit, options->bitfield)) { \ - fprintf(fp, "\t%s %lu;\n",name, \ - (unsigned long)options->field / 60); \ - } - -#define PRINT_AS_BOOLEAN(field, bit, name, bitfield) \ - if (CHECKBIT(bit, options->bitfield)) { \ - fprintf(fp, "\t%s %s;\n",name, \ - (options->field ? "true" : "false")); \ - } - -#define PRINT_AS_SIZE_CLAUSE(field, bit, name, bitfield) \ - if (CHECKBIT(bit,options->bitfield)) { \ - fprintf(fp, "\t%s ",name); \ - if (options->field == 0) { \ - fprintf(fp, "default"); \ - } else { \ - print_in_units(fp,options->data_size); \ - } \ - fprintf(fp, ";\n"); \ - } - - - - fprintf (fp, "options {\n"); - opt_print_textregion(fp, "version", options->version); - opt_print_textregion(fp, "directory", options->directory); - opt_print_textregion(fp, "named-xfer", options->named_xfer); - opt_print_textregion(fp, "pid-file", options->pid_filename); - opt_print_textregion(fp, "statistics-file", options->stats_filename); - opt_print_textregion(fp, "memstatistics-file", - options->memstats_filename); - opt_print_textregion(fp, "dump-file", options->dump_filename); - - PRINT_AS_BOOLEAN(fake_iquery, FAKE_IQUERY_BIT, - "fake-iquery", set_flags1); - PRINT_AS_BOOLEAN(recursion, RECURSION_BIT, - "recursion", set_flags1); - PRINT_AS_BOOLEAN(fetch_glue, FETCH_GLUE_BIT, - "fetch-glue", set_flags1); - PRINT_AS_BOOLEAN(notify, NOTIFY_BIT, - "notify", set_flags1); - PRINT_AS_BOOLEAN(hoststats, HOSTSTATS_BIT, - "hoststats", set_flags1); - PRINT_AS_BOOLEAN(dealloc_on_exit, DEALLOC_ON_EXIT_BIT, - "deallocate-on-exit", set_flags1); - PRINT_AS_BOOLEAN(use_ixfr, USE_IXFR_BIT, - "use_ixfr", set_flags1); - PRINT_AS_BOOLEAN(maintain_ixfr_base, MAINTAIN_IXFR_BASE_BIT, - "maintain-ixfr-base", set_flags1); - PRINT_AS_BOOLEAN(has_old_clients, HAS_OLD_CLIENTS_BIT, - "has-old-clients", set_flags1); - PRINT_AS_BOOLEAN(auth_nx_domain, AUTH_NX_DOMAIN_BIT, - "auth-nxdomain", set_flags1); - PRINT_AS_BOOLEAN(multiple_cnames, MULTIPLE_CNAMES_BIT, - "multiple-cnames", set_flags1); - PRINT_AS_BOOLEAN(use_id_pool, USE_ID_POOL_BIT, - "use-id-pool", set_flags2); - PRINT_AS_BOOLEAN(dialup, DIALUP_BIT, - "dialup", set_flags2); - - PRINT_AS_SIZE_CLAUSE(data_size, DATA_SIZE_BIT, "datasize", - set_flags1); - PRINT_AS_SIZE_CLAUSE(stack_size, STACK_SIZE_BIT, "stacksize", - set_flags1); - PRINT_AS_SIZE_CLAUSE(core_size, CORE_SIZE_BIT, "coresize", - set_flags1); - PRINT_AS_SIZE_CLAUSE(files, FILES_BIT, "files", - set_flags1); - - PRINT_AS_MINUTES(max_transfer_time_in, MAX_TRANS_TIME_BIT, - "max-transfer-time-in", set_flags1); - PRINT_AS_MINUTES(clean_interval, CLEAN_INT_BIT, - "cleaning-interval", set_flags1); - PRINT_AS_MINUTES(interface_interval, INTERFACE_INT_BIT, - "interface-interval", set_flags1); - PRINT_AS_MINUTES(stats_interval, STATS_INT_BIT, - "statistics-interval", set_flags1); - - fprintf(fp,"};\n"); -} - - - -/**** - **** ACCESSORS/MODIFIERS - ****/ - -/* This is seriously ugly, but we have nothing like C++ templates here.... */ - -FUNC_SET_TEXTFIELD(directory) -FUNC_GET_TEXTFIELD(directory) - -FUNC_SET_TEXTFIELD(version) -FUNC_GET_TEXTFIELD(version) - -FUNC_SET_TEXTFIELD(dump_filename) -FUNC_GET_TEXTFIELD(dump_filename) - -FUNC_SET_TEXTFIELD(pid_filename) -FUNC_GET_TEXTFIELD(pid_filename) - -FUNC_SET_TEXTFIELD(stats_filename) -FUNC_GET_TEXTFIELD(stats_filename) - -FUNC_SET_TEXTFIELD(memstats_filename) -FUNC_GET_TEXTFIELD(memstats_filename) - -FUNC_SET_TEXTFIELD(named_xfer) -FUNC_GET_TEXTFIELD(named_xfer) - -FUNC_SET_FIELD(max_ncache_ttl, NCACHE_TTL_BIT, set_flags1, unsigned int) -FUNC_GET_FIELD(max_ncache_ttl, NCACHE_TTL_BIT, set_flags1, unsigned int) - -FUNC_SET_FIELD(transfers_in, TRANSFERS_IN_BIT, set_flags1, int) -FUNC_GET_FIELD(transfers_in, TRANSFERS_IN_BIT, set_flags1, int) - -FUNC_SET_FIELD(transfers_per_ns, TRANSFERS_PER_NS_BIT, set_flags1, int) -FUNC_GET_FIELD(transfers_per_ns, TRANSFERS_PER_NS_BIT, set_flags1, int) - -FUNC_SET_FIELD(transfers_out, TRANSFERS_OUT_BIT, set_flags1, int) -FUNC_GET_FIELD(transfers_out, TRANSFERS_OUT_BIT, set_flags1, int) - -FUNC_SET_FIELD(max_log_size_ixfr, MAX_LOG_BIT, set_flags1, int) -FUNC_GET_FIELD(max_log_size_ixfr, MAX_LOG_BIT, set_flags1, int) - -FUNC_SET_FIELD(clean_interval, CLEAN_INT_BIT, set_flags1, int) -FUNC_GET_FIELD(clean_interval, CLEAN_INT_BIT, set_flags1, int) - -FUNC_SET_FIELD(interface_interval, INTERFACE_INT_BIT, set_flags1, int) -FUNC_GET_FIELD(interface_interval, INTERFACE_INT_BIT, set_flags1, int) - -FUNC_SET_FIELD(stats_interval, STATS_INT_BIT, set_flags1, int) -FUNC_GET_FIELD(stats_interval, STATS_INT_BIT, set_flags1, int) - -FUNC_SET_FIELD(heartbeat_interval, HEARDBEAT_INT_BIT, set_flags1, int) -FUNC_GET_FIELD(heartbeat_interval, HEARDBEAT_INT_BIT, set_flags1, int) - -FUNC_SET_FIELD(max_transfer_time_in,MAX_TRANS_TIME_BIT, set_flags1, long) -FUNC_GET_FIELD(max_transfer_time_in,MAX_TRANS_TIME_BIT, set_flags1, long) - -FUNC_SET_FIELD(data_size, DATA_SIZE_BIT, set_flags1, unsigned long) -FUNC_GET_FIELD(data_size, DATA_SIZE_BIT, set_flags1, unsigned long) - -FUNC_SET_FIELD(stack_size, STACK_SIZE_BIT, set_flags1, unsigned long) -FUNC_GET_FIELD(stack_size, STACK_SIZE_BIT, set_flags1, unsigned long) - -FUNC_SET_FIELD(core_size, CORE_SIZE_BIT, set_flags1, unsigned long) -FUNC_GET_FIELD(core_size, CORE_SIZE_BIT, set_flags1, unsigned long) - -FUNC_SET_FIELD(files, FILES_BIT, set_flags1, unsigned long) -FUNC_GET_FIELD(files, FILES_BIT, set_flags1, unsigned long) - -FUNC_SET_FIELD(fake_iquery, FAKE_IQUERY_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(fake_iquery, FAKE_IQUERY_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(recursion, RECURSION_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(recursion, RECURSION_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(fetch_glue, FETCH_GLUE_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(fetch_glue, FETCH_GLUE_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(notify, NOTIFY_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(notify, NOTIFY_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(hoststats, HOSTSTATS_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(hoststats, HOSTSTATS_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(dealloc_on_exit, DEALLOC_ON_EXIT_BIT, set_flags1, - isc_boolean_t) -FUNC_GET_FIELD(dealloc_on_exit, DEALLOC_ON_EXIT_BIT, set_flags1, - isc_boolean_t) - -FUNC_SET_FIELD(use_ixfr, USE_IXFR_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(use_ixfr, USE_IXFR_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(maintain_ixfr_base, MAINTAIN_IXFR_BASE_BIT, set_flags1, - isc_boolean_t) -FUNC_GET_FIELD(maintain_ixfr_base, MAINTAIN_IXFR_BASE_BIT, set_flags1, - isc_boolean_t) - -FUNC_SET_FIELD(has_old_clients, HAS_OLD_CLIENTS_BIT, set_flags1, - isc_boolean_t) -FUNC_GET_FIELD(has_old_clients, HAS_OLD_CLIENTS_BIT, set_flags1, - isc_boolean_t) - -FUNC_SET_FIELD(auth_nx_domain, AUTH_NX_DOMAIN_BIT, set_flags1, isc_boolean_t) -FUNC_GET_FIELD(auth_nx_domain, AUTH_NX_DOMAIN_BIT, set_flags1, isc_boolean_t) - -FUNC_SET_FIELD(multiple_cnames, MULTIPLE_CNAMES_BIT, set_flags1, - isc_boolean_t) -FUNC_GET_FIELD(multiple_cnames, MULTIPLE_CNAMES_BIT, set_flags1, - isc_boolean_t) - -FUNC_SET_FIELD(use_id_pool, USE_ID_POOL_BIT, set_flags2, isc_boolean_t) -FUNC_GET_FIELD(use_id_pool, USE_ID_POOL_BIT, set_flags2, isc_boolean_t) - -FUNC_SET_FIELD(dialup, DIALUP_BIT, set_flags2, isc_boolean_t) -FUNC_GET_FIELD(dialup, DIALUP_BIT, set_flags2, isc_boolean_t) - - - - -/*** - *** PRIVATE - ***/ - -static isc_result_t -set_text_region(isc_mem_t *mem, isc_textregion_t *region, const char *value) -{ - size_t len; - - INSIST(mem != NULL); - INSIST(value != NULL); - INSIST(region != NULL); - - len = strlen(value) + 1; - - INSIST(len > 1); - CHECKREGION(region); - - if (region->base != NULL && region->length < len) { - isc_mem_put(mem, region->base, region->length); - region->base = NULL; - region->length = 0; - } - - if (region->base == NULL) { - region->base = isc_mem_get(mem, len); - if (region->base == NULL) { - return (ISC_R_NOMEMORY); - } - region->length = len; - } - - strcpy(region->base, value); - - return (ISC_R_SUCCESS); -} - - - - -static void -freeoptions(isc_cfgoptions_t *opts, isc_mem_t *mem) -{ - INSIST(opts != NULL); - - FREE_TEXT_REGION(&opts->directory, mem); - FREE_TEXT_REGION(&opts->version, mem); - FREE_TEXT_REGION(&opts->dump_filename, mem); - FREE_TEXT_REGION(&opts->pid_filename, mem); - FREE_TEXT_REGION(&opts->stats_filename, mem); - FREE_TEXT_REGION(&opts->memstats_filename, mem); - FREE_TEXT_REGION(&opts->named_xfer, mem); - - isc_mem_put(mem, opts, sizeof *opts); -} - - -static void -opt_print_textregion(FILE *fp, const char *name, isc_textregion_t r) -{ - CHECKREGION(&r); - - if (r.length > 0) { - fprintf(fp,"\t%s \"%s\";\n", name, r.base); - } -} diff --git a/bin/named/configctx.h b/bin/named/configctx.h deleted file mode 100644 index 5f021cbf54..0000000000 --- a/bin/named/configctx.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/**** - **** MODULE INFO - ****/ - -/* - * Top level Data structure and accessors for the data defined in the - * config file. - * - * MP: - * - * Caller must do necessary locking. - * - * Reliability: - * - * - * Resources: - * - * - * Security: - * - * - * Standards: - * - */ - -#if !defined(CONFIGCTX_H) -#define CONFIGCTX_H 1 - -#include - -#include "zone.h" - -/* Data from an 'options' config file statement */ -typedef struct isc_cfgoptions -{ - isc_textregion_t directory; - isc_textregion_t version; - isc_textregion_t dump_filename; - isc_textregion_t pid_filename; - isc_textregion_t stats_filename; - isc_textregion_t memstats_filename; - isc_textregion_t named_xfer; - - unsigned int flags; - unsigned int max_ncache_ttl; - - int transfers_in; - int transfers_per_ns; - int transfers_out; - int max_log_size_ixfr; - int clean_interval; - int interface_interval; - int stats_interval; - int heartbeat_interval; - - isc_boolean_t fake_iquery; - isc_boolean_t recursion; - isc_boolean_t fetch_glue; - isc_boolean_t notify; - isc_boolean_t hoststats; - isc_boolean_t dealloc_on_exit; - isc_boolean_t use_ixfr; - isc_boolean_t maintain_ixfr_base; - isc_boolean_t has_old_clients; - isc_boolean_t auth_nx_domain; - isc_boolean_t multiple_cnames; - isc_boolean_t use_id_pool; - isc_boolean_t dialup; - - long max_transfer_time_in; - - unsigned long data_size; - unsigned long stack_size; - unsigned long core_size; - unsigned long files; - -#if 0 - struct sockaddr_in query_source; - ip_match_list query_acl; - ip_match_list transfer_acl; - ip_match_list blackhole_acl; - ip_match_list topology; -#ifdef SORT_RESPONSE - ip_match_list sortlist; -#endif /* SORT_RESPONSE */ - - enum axfr_format transfer_format; - - enum severity check_names[num_trans]; - listen_info_list listen_list; - struct fwdinfo *fwdtab; - - rrset_order_list ordering; -#endif - - /* For the non-pointer members of the struct a bit will be set in - * this field if a value was explicitly set. - */ - isc_uint64_t set_flags1; - isc_uint64_t set_flags2; -} isc_cfgoptions_t; - - -/* Master config structure. All the information defined in a config file is - * reachable through here. - */ -typedef struct isc_cfgctx -{ - int warnings; /* number of parse warnings */ - int errors; /* number of parse semantic errors */ - - isc_mem_t *mem; /* where we get our memory from */ - - isc_cfgoptions_t *options; - isc_zonectx_t *zonecontext; - - /* XXX other config stuff like trusted keys, acls, logging etc. */ -} isc_cfgctx_t; - - -isc_result_t isc_cfg_newctx(isc_mem_t *mem, isc_cfgctx_t **ctx); -isc_result_t isc_cfg_freectx(isc_cfgctx_t **ctx); - -/* Reset the options back to virgin state. */ -isc_result_t isc_cfg_erase_options(isc_cfgctx_t *ctx); - -/* Send a properly formatted context to the given stream */ -void isc_cfg_dump_config(FILE *fp, isc_cfgctx_t *ctx); -void isc_cfg_dump_options(FILE *fp, isc_cfgoptions_t *options); - - -/* Set functions for all the options fields. */ - -isc_result_t isc_cfg_set_directory(isc_cfgctx_t *ctx, const char *directory); -isc_result_t isc_cfg_set_version(isc_cfgctx_t *ctx, const char *directory); -isc_result_t isc_cfg_set_dump_filename(isc_cfgctx_t *ctx, - const char *directory); -isc_result_t isc_cfg_set_pid_filename(isc_cfgctx_t *ctx, - const char *directory); -isc_result_t isc_cfg_set_stats_filename(isc_cfgctx_t *ctx, - const char *directory); -isc_result_t isc_cfg_set_memstats_filename(isc_cfgctx_t *ctx, - const char *directory); -isc_result_t isc_cfg_set_named_xfer(isc_cfgctx_t *ctx, const char *directory); -isc_result_t isc_cfg_set_max_ncache_ttl(isc_cfgctx_t*ctx, unsigned int value); -isc_result_t isc_cfg_set_transfers_in(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_transfers_per_ns(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_transfers_out(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_max_log_size_ixfr(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_clean_interval(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_interface_interval(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_stats_interval(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_heartbeat_interval(isc_cfgctx_t*ctx, int value); -isc_result_t isc_cfg_set_max_transfer_time_in(isc_cfgctx_t*ctx, long value); -isc_result_t isc_cfg_set_data_size(isc_cfgctx_t *ctx, unsigned long value); -isc_result_t isc_cfg_set_stack_size(isc_cfgctx_t *ctx, unsigned long value); -isc_result_t isc_cfg_set_core_size(isc_cfgctx_t *ctx, unsigned long value); -isc_result_t isc_cfg_set_files(isc_cfgctx_t *ctx, unsigned long value); - -isc_result_t isc_cfg_set_fake_iquery(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_recursion(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_fetch_glue(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_notify(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_hoststats(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_dealloc_on_exit(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_use_ixfr(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_maintain_ixfr_base(isc_cfgctx_t *ctx, - isc_boolean_t bv); -isc_result_t isc_cfg_set_has_old_clients(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_auth_nx_domain(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_multiple_cnames(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_use_id_pool(isc_cfgctx_t *ctx, isc_boolean_t bv); -isc_result_t isc_cfg_set_dialup(isc_cfgctx_t *ctx, isc_boolean_t bv); - - -/* Get functions for all the option fields. Caller must not modify the - * results. If the fields was not set, the ISC_R_NOTFOUND is returned, - * otherwise ISC_R_SUCCESS - */ -isc_result_t isc_cfg_get_named_xfer(isc_cfgctx_t *ctx, const char **result); -isc_result_t isc_cfg_get_directory(isc_cfgctx_t *ctx, const char **result); -isc_result_t isc_cfg_get_version(isc_cfgctx_t *ctx, const char **result); -isc_result_t isc_cfg_get_dump_filename(isc_cfgctx_t *ctx, - const char **result); -isc_result_t isc_cfg_get_pid_filename(isc_cfgctx_t *ctx, - const char **result); -isc_result_t isc_cfg_get_stats_filename(isc_cfgctx_t *ctx, - const char **result); -isc_result_t isc_cfg_get_memstats_filename(isc_cfgctx_t *ctx, - const char **result); -isc_result_t isc_cfg_get_max_ncache_ttl(isc_cfgctx_t *ctx, - unsigned int *result); -isc_result_t isc_cfg_get_transfers_in(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_transfers_per_ns(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_transfers_out(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_max_log_size_ixfr(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_clean_interval(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_interface_interval(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_stats_interval(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_heartbeat_interval(isc_cfgctx_t *ctx, int *result); -isc_result_t isc_cfg_get_max_transfer_time_in(isc_cfgctx_t *ctx, long *result); -isc_result_t isc_cfg_get_data_size(isc_cfgctx_t *ctx, unsigned long *result); -isc_result_t isc_cfg_get_stack_size(isc_cfgctx_t *ctx, unsigned long *result); -isc_result_t isc_cfg_get_core_size(isc_cfgctx_t *ctx, unsigned long *result); -isc_result_t isc_cfg_get_files(isc_cfgctx_t *ctx, unsigned long *result); - -isc_result_t isc_cfg_get_fake_iquery(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_recursion(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_fetch_glue(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_notify(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_hoststats(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_dealloc_on_exit(isc_cfgctx_t *ctx, - isc_boolean_t *result); -isc_result_t isc_cfg_get_use_ixfr(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_maintain_ixfr_base(isc_cfgctx_t *ctx, - isc_boolean_t *result); -isc_result_t isc_cfg_get_has_old_clients(isc_cfgctx_t *ctx, - isc_boolean_t *result); -isc_result_t isc_cfg_get_auth_nx_domain(isc_cfgctx_t *ctx, - isc_boolean_t *result); -isc_result_t isc_cfg_get_multiple_cnames(isc_cfgctx_t *ctx, - isc_boolean_t *result); -isc_result_t isc_cfg_get_use_id_pool(isc_cfgctx_t *ctx, isc_boolean_t *result); -isc_result_t isc_cfg_get_dialup(isc_cfgctx_t *ctx, isc_boolean_t *result); - - - - -#endif diff --git a/bin/named/confparser.h b/bin/named/confparser.h deleted file mode 100644 index 27c9af36a3..0000000000 --- a/bin/named/confparser.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/***** - ***** Module Info - *****/ - -/* - * Parser - * - * The parser module handles the parsing of config files. Two entry points - * are provided: - * - * parser_init() - * - * parse_configuration(const char *filename, - * isc_mem_t *mem, isc_cfgctx_t **configctx); - * - * - * MP: - * Only a single thread is let through the module at once. - * - * The program *MUST* first call parser_init() one time. Calling - * parser_init() more than once may result in abort() dump (best case) - * or undefined behaviour (worst case). - * - * Reliability: - * No anticipated impact. - * - * Resources: - * - * - * Security: - * - * - * Standards: - * None. - */ - - -/*** - *** Imports - ***/ - -#include - -#include "configctx.h" - -/*** - *** Functions - ***/ - -isc_result_t parser_init(void); -/* - * Does parser intitialization. Must be called before - * isc_parse_configuration() is called - * - * Requires: - * The caller do necessary locking to prevent multiple threads from - * calling it at once. - * - * Ensures: - * Nothing. - * - * Returns: - * ISC_R_SUCCESS - * ISC_R_FAILURE something broke - */ - - -isc_result_t parse_configuration(const char *filename, isc_mem_t *mem, - isc_cfgctx_t **configctx); - -/* - * Parse the confile file. Fills up the config context with the new config - * data. All memory allocations for the contents of configctx are done - * using the MEM argument. - * - * Requires: - * *filename is a valid filename. - * *mem is a valid memory manager. - * *configctx is a valid isc_config_ctx_t pointer - * - * Ensures: - * On success, *configctx is attached to the newly created config context. - * - * Returns: - * ISC_R_SUCCESS - * ISC_R_NOMEMORY - * ISC_R_INVALIDFILE file doesn't exist or is unreadable - * ISC_R_FAILURE file contains errors. - */ - diff --git a/bin/named/confparser.y b/bin/named/confparser.y deleted file mode 100644 index 858fda2d4d..0000000000 --- a/bin/named/confparser.y +++ /dev/null @@ -1,2152 +0,0 @@ -%{ -#if !defined(lint) && !defined(SABER) -static char rcsid[] = "$Id: confparser.y,v 1.4 1999/06/08 13:27:36 brister Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/**** - **** MODULE INFO - ****/ - -/* - * This is the parser for the named.conf file. API is: - * - * parser_init() - * To be called one time only to do global - * initialzation *before* calling isc_parse_configuration(). - * Caller is responsible for thread locking. - * - * parse_configuration() - * The main parsing routine. Will parse the config file and - * will return a structure containing all the relevant - * information. Only one thread can go through it at a time, - * and the function handles locking itself. - * - * MP: - * - * Caller must prevent parallel calls. - * - * Reliability: - * - * - * Resources: - * - * Uses memory allocaters provided by the caller. - * - * Security: - * - * - * Standards: - * - */ - -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "confparser.h" -#include "zone.h" -#include "configctx.h" - -static int onetime; -static isc_mutex_t yacc_mutex; - -/* All these statics are protected by the above yacc_mutex */ -static int seen_options; -static int seen_topology; - -static isc_zonectx_t *currzonectx; -static isc_zoneinfo_t *currzone; -static isc_cfgctx_t *currcfg; -static const char *currfile; - -static isc_mem_t *memctx; /* used for internal allocations */ -static isc_lex_t *mylexer; -static isc_symtab_t *keywords; -static isc_lexspecials_t specials; - -/* Type keys used in symbol table element instances. */ -static int keyword_type = 1; -static int class_sym_type = 2; - - -#define NS_DEFAULTPORT 53 /* XXX this should be imported NOT defined */ - -#define CONF_MAX_IDENT 1024 -#define SYMTAB_SIZE 499 /* bigest prime less than 500 */ - -/* This should be sufficient to permit multiple parsers and lexers if needed */ -#define yyparse confyyparse -#define yylex confyylex - -static void parser_error(char *fmt, ...); -static void parser_warning(char *fmt, ...); -static void print_msg(const char *fmt, va_list args); -static void free_textregion(isc_textregion_t region, isc_mem_t *mem); -static int intuit_token(isc_symtab_t *symtable, const char *string); -static isc_result_t symtable_init(void); - -static void yyerror(const char *); -static int yylex(void); -static isc_result_t copy_textregion(isc_mem_t *mem, - isc_textregion_t region, - isc_textregion_t *newregion); -static int unit_to_ulong(char *in, unsigned long *out); -static void debug_print(const char *fmt, ...); - -int yyparse(void); - -static isc_result_t tmpres; -static int debug_lexer; -static int debugging_stuff; - - -%} - -%union { - isc_textregion_t text; - int number; - long l_int; - unsigned long ul_int; - isc_uint16_t port_int; - isc_zonet_t ztype; - struct in_addr ip_addr; - isc_boolean_t boolean; - isc_rrclass_t rrclass; - - /* NOT IMPLEMENTED YET */ -/* - ip_match_element ime; - ip_match_list iml; - rrset_order_list rol; - rrset_order_element roe; - struct dst_key * keyi; - enum axfr_format axfr_fmt; -*/ -} - -%token L_LBRACE -%token L_RBRACE -%token L_EOS -%token L_SLASH -%token L_BANG -%token L_STAR -%token L_QUOTE - -/* Misc */ -%token L_STRING -%token L_QSTRING -%token L_INTEGER -%token L_IPADDR - - -%token L_MASTER -%token L_SLAVE -%token L_SORTLIST -%token L_HINT -%token L_STUB -%token L_FORWARD - -%token L_INCLUDE -%token L_END_INCLUDE - -/* options statement */ -%token L_OPTIONS -%token L_DIRECTORY -%token L_DIRECTORY -%token L_PIDFILE -%token L_NAMED_XFER -%token L_DUMP_FILE -%token L_STATS_FILE -%token L_MEMSTATS_FILE -%token L_FAKE_IQUERY -%token L_RECURSION -%token L_FETCH_GLUE -%token L_QUERY_SOURCE -%token L_LISTEN_ON -%token L_PORT -%token L_ACL -%token L_ADDRESS -%token L_ALGID -%token L_ALLOW_QUERY -%token L_ALLOW_TRANSFER -%token L_ALLOW_UPDATE -%token L_ALSO_NOTIFY -%token L_BLACKHOLE -%token L_BOGUS -%token L_CATEGORY -%token L_CHANNEL -%token L_CHECK_NAMES -%token L_DEBUG -%token L_DIALUP -%token L_DYNAMIC -%token L_FAIL -%token L_FIRST -%token L_FORWARDERS -%token L_IF_NO_ANSWER -%token L_IF_NO_DOMAIN -%token L_IGNORE -%token L_FILE_IXFR -%token L_IXFR_TMP -%token L_SEC_KEY -%token L_KEYS -%token L_LOGGING -%token L_MASTERS -%token L_NULL_OUTPUT -%token L_ONLY -%token L_PRINT_CATEGORY -%token L_PRINT_SEVERITY -%token L_PRINT_TIME -%token L_PUBKEY -%token L_RESPONSE -%token L_SECRET -%token L_SERVER -%token L_SEVERITY -%token L_SIZE -%token L_SUPPORT_IXFR -%token L_SYSLOG -%token L_TOPOLOGY -%token L_TRANSFER_SOURCE -%token L_TRANSFERS -%token L_TRUSTED_KEYS -%token L_VERSIONS -%token L_WARN -%token L_RRSET_ORDER -%token L_ORDER -%token L_NAME -%token L_CLASS -%token L_CONTROLS -%token L_INET -%token L_UNIX -%token L_PERM -%token L_OWNER -%token L_GROUP -%token L_ALLOW -%token L_DATASIZE -%token L_STACKSIZE -%token L_CORESIZE -%token L_DEFAULT -%token L_UNLIMITED -%token L_FILES -%token L_VERSION -%token L_HOSTSTATS -%token L_DEALLOC_ON_EXIT -%token L_TRANSFERS_IN -%token L_TRANSFERS_OUT -%token L_TRANSFERS_PER_NS -%token L_TRANSFER_FORMAT -%token L_MAX_TRANSFER_TIME_IN -%token L_ONE_ANSWER -%token L_MANY_ANSWERS -%token L_NOTIFY -%token L_AUTH_NXDOMAIN -%token L_MULTIPLE_CNAMES -%token L_USE_IXFR -%token L_MAINTAIN_IXFR_BASE -%token L_CLEAN_INTERVAL -%token L_INTERFACE_INTERVAL -%token L_STATS_INTERVAL -%token L_MAX_LOG_SIZE_IXFR -%token L_HEARTBEAT -%token L_USE_ID_POOL -%token L_MAX_NCACHE_TTL -%token L_HAS_OLD_CLIENTS - -%type size_spec -%type any_string - -%type in_port -%type maybe_wild_port -%type maybe_zero_port -%type maybe_port - -%type maybe_wild_addr -%type facility_name -%type maybe_syslog_facility -%type channel_name -%type category_name - -%type ordering_class -%type optional_class - -/* Zone statements */ -%token L_ZONE -%token L_TYPE -%token L_FILE -%type zone_type - - -/* Items used for yes/no responses: */ -%type yea_or_nay -%token L_YES -%token L_TRUE -%token L_NO -%token L_FALSE - -/* Miscellaneous items (used in several places): */ - -%% - -config_file: statement_list - { - /* XXX Do post-read validations etc. */ - } - ; - -statement_list: statement - | statement_list statement - ; - -statement: include_stmt L_EOS - | options_stmt L_EOS - | controls_stmt L_EOS - | logging_stmt L_EOS - | server_stmt L_EOS - | zone_stmt L_EOS - | trusted_keys_stmt L_EOS - | acl_stmt L_EOS - | key_stmt L_EOS - | L_END_INCLUDE - | error L_EOS - | error L_END_INCLUDE - ; - - -include_stmt: L_INCLUDE L_QSTRING - { - /* XXX */ - fprintf(stderr, - "include files are currently broken (memory leak)\n"); - exit(1); - isc_lex_openfile(mylexer, $2.base); - free_textregion($2, memctx); - } - ; - -options_stmt: L_OPTIONS - { - debug_print( "debug: getting options"); - if (seen_options) { - parser_error("cannot redefine options"); - RUNTIME_CHECK(isc_cfg_erase_options(currcfg) == - ISC_R_SUCCESS); - } - } - L_LBRACE options L_RBRACE - { - seen_options = 1; - } - ; - -options: option L_EOS - | options option L_EOS - ; - - -option: /* Empty */ - | L_VERSION L_QSTRING - { - debug_print( "debug: setting options version %s", $2.base); - tmpres = isc_cfg_set_version(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set version error %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_DIRECTORY L_QSTRING - { - debug_print( "debug: setting options directory %s", $2.base); - tmpres = isc_cfg_set_directory(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set directory error: %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_NAMED_XFER L_QSTRING - { - debug_print( "debug: setting options named-xfer %s", - $2.base); - tmpres = isc_cfg_set_named_xfer(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set named-xfer error: %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_PIDFILE L_QSTRING - { - debug_print( "debug: setting options pidfilename %s", - $2.base); - tmpres = isc_cfg_set_pid_filename(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set pidfile error %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_STATS_FILE L_QSTRING - { - debug_print( "debug: setting options statsfilename %s", - $2.base); - tmpres = isc_cfg_set_stats_filename(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set statsfile error %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_MEMSTATS_FILE L_QSTRING - { - debug_print("debug: setting options memstatsfilename %s", - $2.base); - tmpres = isc_cfg_set_memstats_filename(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set memstatsfile error %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_DUMP_FILE L_QSTRING - { - debug_print("debug: setting options dumpfilename %s", - $2.base); - tmpres = isc_cfg_set_dump_filename(currcfg, $2.base); - if (tmpres != ISC_R_SUCCESS) { - parser_error("set dumpfile error %s: %s", - isc_result_totext(tmpres), $2.base); - } - free_textregion($2, memctx); - } - | L_FAKE_IQUERY yea_or_nay - { - isc_cfg_set_fake_iquery(currcfg, $2); - } - | L_RECURSION yea_or_nay - { - isc_cfg_set_recursion(currcfg, $2); - } - | L_FETCH_GLUE yea_or_nay /* XXX */ - { - isc_cfg_set_fetch_glue(currcfg, $2); - } - | L_NOTIFY yea_or_nay - { - isc_cfg_set_notify(currcfg, $2); - } - | L_HOSTSTATS yea_or_nay - { - isc_cfg_set_hoststats(currcfg, $2); - } - | L_DEALLOC_ON_EXIT yea_or_nay - { - isc_cfg_set_dealloc_on_exit(currcfg, $2); - } - | L_USE_IXFR yea_or_nay - { - isc_cfg_set_use_ixfr(currcfg, $2); - } - | L_MAINTAIN_IXFR_BASE yea_or_nay - { - isc_cfg_set_maintain_ixfr_base(currcfg, $2); - } - | L_HAS_OLD_CLIENTS yea_or_nay - { - isc_cfg_set_has_old_clients(currcfg, $2); - } - | L_AUTH_NXDOMAIN yea_or_nay - { - isc_cfg_set_auth_nx_domain(currcfg, $2); - } - | L_MULTIPLE_CNAMES yea_or_nay - { - isc_cfg_set_multiple_cnames(currcfg, $2); - } - | L_CHECK_NAMES check_names_type check_names_opt - { - /* XXX stuff here */ - } - | L_USE_ID_POOL yea_or_nay - { - isc_cfg_set_use_id_pool(currcfg, $2); - } - | L_LISTEN_ON maybe_port L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_FORWARD forward_opt - | L_FORWARDERS - { - /* XXX stuff here */ - } L_LBRACE opt_forwarders_list L_RBRACE - | L_QUERY_SOURCE query_source - | L_ALLOW_QUERY L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_ALLOW_TRANSFER L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_SORTLIST L_LBRACE address_match_list L_RBRACE - | L_BLACKHOLE L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_TOPOLOGY L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | size_clause - { - /* To get around the $$ = $1 default rule. */ - } - | transfer_clause - /* XXX L_TRANSFER_FORMAT goes here */ - | L_MAX_TRANSFER_TIME_IN L_INTEGER - { - isc_cfg_set_max_transfer_time_in(currcfg, $2 * 60); - } - | L_CLEAN_INTERVAL L_INTEGER - { - isc_cfg_set_clean_interval(currcfg, $2 * 60); - } - | L_INTERFACE_INTERVAL L_INTEGER - { - isc_cfg_set_interface_interval(currcfg, $2 * 60); - } - | L_STATS_INTERVAL L_INTEGER - { - isc_cfg_set_stats_interval(currcfg, $2 * 60); - } - | L_MAX_LOG_SIZE_IXFR L_INTEGER - { - isc_cfg_set_max_log_size_ixfr(currcfg, $2); - } - | L_MAX_NCACHE_TTL L_INTEGER - { - isc_cfg_set_max_ncache_ttl(currcfg, $2); - } - | L_HEARTBEAT L_INTEGER - { - isc_cfg_set_heartbeat_interval(currcfg, $2 * 60); - } - | L_DIALUP yea_or_nay - { - isc_cfg_set_dialup(currcfg, $2); - } - | L_RRSET_ORDER L_LBRACE rrset_ordering_list L_RBRACE - { - /* XXX stuff here */ - } - | error - ; - - -/* - * Controls. - */ -controls_stmt: L_CONTROLS L_LBRACE controls L_RBRACE - ; - -controls: control L_EOS - | controls control L_EOS - ; - -control: /* Empty */ - | L_INET maybe_wild_addr L_PORT in_port - L_ALLOW L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_UNIX L_QSTRING L_PERM L_INTEGER L_OWNER L_INTEGER L_GROUP L_INTEGER - { - /* XXX stuff here */ - } - | error - ; - -rrset_ordering_list: rrset_ordering_element L_EOS - { - /* XXX stuff here */ - } - | rrset_ordering_list rrset_ordering_element L_EOS - { - /* XXX stuff here */ - } - ; - -ordering_class: /* nothing */ - { - $$ = class_any; - } - | L_CLASS any_string - { - isc_symvalue_t classtok; - tmpres = isc_symtab_lookup(keywords, $2.base, - class_sym_type, &classtok); - if (tmpres != ISC_R_SUCCESS) { - parser_error("unknown type '%s'. Assuming ANY\n", - $2.base); - $$ = class_any; - } else { - $$ = (isc_rrclass_t) classtok.as_integer; - } - free_textregion($2, memctx); - } - ; - -ordering_type: /* nothing */ - { - /* XXX stuff here */ - } - | L_TYPE any_string - { - /* XXX stuff here */ - } - -ordering_name: /* nothing */ - { - /* XXX stuff here */ - } - | L_NAME L_QSTRING - { - /* XXX stuff here */ - } - - -rrset_ordering_element: ordering_class ordering_type ordering_name L_ORDER L_STRING - { - /* XXX stuff here */ - } - - -transfer_format: L_ONE_ANSWER - { - /* XXX stuff here */ - } - | L_MANY_ANSWERS - { - /* XXX stuff here */ - } - ; - - -maybe_wild_addr: L_IPADDR - { - $$ = $1; - } - | '*' - { - $$.s_addr = htonl(INADDR_ANY); - } - ; - -maybe_wild_port: in_port - { - $$ = $1; - } - | '*' - { - $$ = htons(0); - } - ; - -query_source_address: L_ADDRESS maybe_wild_addr - { - /* XXX stuff here */ - } - ; - -query_source_port: L_PORT maybe_wild_port - { - /* XXX stuff here */ - } - ; - -query_source: query_source_address - | query_source_port - | query_source_address query_source_port - | query_source_port query_source_address - ; - -maybe_port: /* nothing */ - { - $$ = htons(NS_DEFAULTPORT); - } - | L_PORT in_port - { - $$ = $2; - } - ; - -maybe_zero_port : /* nothing */ - { - $$ = htons(0); - } - | L_PORT in_port - { - $$ = $2; - } - ; - -yea_or_nay: L_YES - { - $$ = isc_boolean_true; - } - | L_TRUE - { - $$ = isc_boolean_true; - } - | L_NO - { - $$ = isc_boolean_false; - } - | L_FALSE - { - $$ = isc_boolean_false; - } - | L_INTEGER - { - if ($1 == 1) { - $$ = isc_boolean_true; - } else if ($1 == 0) { - $$ = isc_boolean_false; - } else { - parser_warning("number should be 0 or 1; assuming 1"); - $$ = isc_boolean_true; - } - } - ; - -check_names_type: L_MASTER - { - /* XXX stuff here */ - } - | L_SLAVE - { - /* XXX stuff here */ - } - | L_RESPONSE - { - /* XXX stuff here */ - } - ; - -check_names_opt: L_WARN - { - /* XXX stuff here */ - } - | L_FAIL - { - /* XXX stuff here */ - } - | L_IGNORE - { - /* XXX stuff here */ - } - ; - -forward_opt: L_ONLY - { - /* XXX stuff here */ - } - | L_FIRST - { - /* XXX stuff here */ - } - | L_IF_NO_ANSWER - { - /* XXX stuff here */ - } - | L_IF_NO_DOMAIN - { - /* XXX stuff here */ - } - ; - - - -size_clause: L_DATASIZE size_spec - { - debug_print( "debug: setting options datasize %ld", $2); - isc_cfg_set_data_size(currcfg, $2); - } - | L_STACKSIZE size_spec - { - debug_print( "debug: setting options stacksize %ld", $2); - isc_cfg_set_stack_size(currcfg, $2); - } - | L_CORESIZE size_spec - { - debug_print( "debug: setting options coresize %ld", $2); - isc_cfg_set_core_size(currcfg, $2); - } - | L_FILES size_spec - { - debug_print("debug: setting options files %ld", $2); - isc_cfg_set_files(currcfg, $2); - } - ; - - -size_spec: any_string - { - u_long result; - - fprintf(stderr, "geting size\n"); - if (unit_to_ulong($1.base, &result)) - $$ = result; - else { - parser_error("invalid unit string '%s'", $1); - /* 0 means "use default" */ - $$ = 0; - } - free_textregion($1, memctx); - } - | L_INTEGER - { - $$ = (unsigned long)$1; - } - | L_DEFAULT - { - $$ = 0; - } - | L_UNLIMITED - { - $$ = ULONG_MAX; - } - ; - - - -transfer_clause: L_TRANSFERS_IN L_INTEGER - { - isc_cfg_set_transfers_in(currcfg, (unsigned long)$2); - } - | L_TRANSFERS_OUT L_INTEGER - { - isc_cfg_set_transfers_out(currcfg, (unsigned long)$2); - } - | L_TRANSFERS_PER_NS L_INTEGER - { - isc_cfg_set_transfers_per_ns(currcfg, (unsigned long) $2); - } - ; - - -opt_forwarders_list: /* nothing */ - | forwarders_in_addr_list - ; - -forwarders_in_addr_list: forwarders_in_addr L_EOS - { - /* nothing */ - } - | forwarders_in_addr_list forwarders_in_addr L_EOS - { - /* nothing */ - } - ; - -forwarders_in_addr: L_IPADDR - { - /* XXX stuff here */ - } - ; - -/* - * Logging - */ - -logging_stmt: L_LOGGING - { - /* XXX stuff here */ - } - L_LBRACE logging_opts_list L_RBRACE - { - /* XXX stuff here */ - } - ; - -logging_opts_list: logging_opt L_EOS - | logging_opts_list logging_opt L_EOS - | error - ; - -logging_opt: L_CATEGORY category - { - /* XXX stuff here */ - } - L_LBRACE channel_list L_RBRACE - | L_CHANNEL channel_name - { - /* XXX stuff here */ - } - L_LBRACE channel_opt_list L_RBRACE - { - /* XXX stuff here */ - } - ; - -channel_severity: any_string - { - /* XXX stuff here */ - } - | L_DEBUG - { - /* XXX stuff here */ - } - | L_DEBUG L_INTEGER - { - /* XXX stuff here */ - } - | L_DYNAMIC - { - /* XXX stuff here */ - } - ; - -version_modifier: L_VERSIONS L_INTEGER - { - /* XXX stuff here */ - } - | L_VERSIONS L_UNLIMITED - { - /* XXX stuff here */ - } - ; - -size_modifier: L_SIZE size_spec - { - /* XXX stuff here */ - } - ; - -maybe_file_modifiers: /* nothing */ - { - /* XXX stuff here */ - } - | version_modifier - { - /* XXX stuff here */ - } - | size_modifier - { - /* XXX stuff here */ - } - | version_modifier size_modifier - | size_modifier version_modifier - ; - -channel_file: L_FILE L_QSTRING maybe_file_modifiers - { - /* XXX stuff here */ - } - ; - - -facility_name: any_string - { - $$ = $1; - } - | L_SYSLOG - { - /* XXX stuff here */ - } - ; - -maybe_syslog_facility: /* nothing */ - { - $$ = LOG_DAEMON; - } - | facility_name - { - /* XXX stuff here */ - } - ; - -channel_syslog: L_SYSLOG maybe_syslog_facility - { - /* XXX stuff here */ - } - ; - -channel_opt: channel_file { /* nothing to do */ } - | channel_syslog { /* nothing to do */ } - | L_NULL_OUTPUT - { - /* XXX stuff here */ - } - | L_SEVERITY channel_severity { /* nothing to do */ } - | L_PRINT_TIME yea_or_nay - { - /* XXX stuff here */ - } - | L_PRINT_CATEGORY yea_or_nay - { - /* XXX stuff here */ - } - | L_PRINT_SEVERITY yea_or_nay - { - /* XXX stuff here */ - } - ; - -channel_opt_list: channel_opt L_EOS - | channel_opt_list channel_opt L_EOS - | error - ; - -channel_name: any_string - | L_NULL_OUTPUT - { - /* XXX stuff here */ - } - ; - -channel: channel_name - { - /* XXX stuff here */ - } - ; - -channel_list: channel L_EOS - | channel_list channel L_EOS - | error - ; - -category_name: any_string - | L_DEFAULT - { - /* XXX stuff here */ - } - | L_NOTIFY - { - /* XXX stuff here */ - } - ; - -category: category_name - { - /* XXX stuff here */ - } - ; - - -/* - * Server Information - */ - -server_stmt: L_SERVER L_IPADDR - { - /* XXX stuff here */ - } - L_LBRACE server_info_list L_RBRACE - { - /* XXX stuff here */ - } - ; - -server_info_list: server_info L_EOS - | server_info_list server_info L_EOS - ; - -server_info: L_BOGUS yea_or_nay - { - /* XXX stuff here */ - } - | L_SUPPORT_IXFR yea_or_nay - { - /* XXX stuff here */ - } - | L_TRANSFERS L_INTEGER - { - /* XXX stuff here */ - } - | L_TRANSFER_FORMAT transfer_format - { - /* XXX stuff here */ - } - | L_KEYS L_LBRACE key_list L_RBRACE - | error - ; - -/* - * Address Matching - */ - -address_match_list: address_match_element L_EOS - { - /* XXX stuff here */ - } - | address_match_list address_match_element L_EOS - { - /* XXX stuff here */ - } - ; - -address_match_element: address_match_simple - | '!' address_match_simple - { - /* XXX stuff here */ - } - | L_SEC_KEY L_STRING - { - /* XXX stuff here */ - } - ; - -address_match_simple: L_IPADDR - { - /* XXX stuff here */ - } - | L_IPADDR L_SLASH L_INTEGER - { - /* XXX stuff here */ - } - | L_INTEGER L_SLASH L_INTEGER - { - /* XXX stuff here */ - } - | address_name - | L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - ; - -address_name: any_string - { - /* XXX stuff here */ - } - ; - -/* - * Keys - */ - -key_ref: any_string - { - /* XXX stuff here */ - } - ; - -key_list_element: key_ref - { - /* XXX stuff here */ - } - ; - -key_list: key_list_element L_EOS - | key_list key_list_element L_EOS - | error - ; - -key_stmt: L_SEC_KEY - { - /* XXX stuff here */ - } - any_string L_LBRACE key_definition L_RBRACE - { - /* XXX stuff here */ - } - ; - -key_definition: algorithm_id secret - { - /* XXX stuff here */ - } - | secret algorithm_id - { - /* XXX stuff here */ - } - | error - { - /* XXX stuff here */ - } - ; - -algorithm_id: L_ALGID any_string L_EOS - { - /* XXX stuff here */ - } - ; - -secret: L_SECRET any_string L_EOS - { - /* XXX stuff here */ - } - ; - -/* - * ACLs - */ - -acl_stmt: L_ACL any_string L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - ; - - -/* - * Zones - */ - -zone_stmt: L_ZONE L_QSTRING optional_class - { - isc_zoneinfo_t *zi = NULL; - - debug_print( "debug: zone statement %s", $2.base); - if (isc_zone_newinfo(currzonectx, &zi) != ISC_R_SUCCESS) { - debug_print( "newzone error"); - return (1); - } - - isc_zone_setorigin(zi, $2.base); - - currzone = zi; - - isc_zone_setclass(currzone, $3); - - free_textregion($2, memctx); - } optional_zone_options_list { - /* XXX install zone if parsed correctly and remove - it if not. */ - } - ; - -optional_zone_options_list: /* Empty */ - | L_LBRACE zone_option_list L_RBRACE - ; - -optional_class: /* Empty */ - { - $$ = class_in; - } - | any_string - { - isc_symvalue_t classtok; - tmpres = isc_symtab_lookup(keywords, $1.base, - class_sym_type, &classtok); - if (tmpres != ISC_R_SUCCESS) { - parser_error("unknown type '%s'. Assuming ANY\n", - $1.base); - $$ = class_none; - } else { - $$ = (isc_rrclass_t)classtok.as_integer; - } - free_textregion($1, memctx); - } - ; - -zone_type: L_MASTER - { - $$ = zone_master; - } - | L_SLAVE - { - $$ = zone_slave; - } - | L_HINT - { - $$ = zone_hint; - } - | L_STUB - { - $$ = zone_stub; - } - | L_FORWARD - { - $$ = zone_forward; - } - ; - - - -zone_option_list: zone_option L_EOS - | zone_option_list zone_option L_EOS - ; - -zone_option: L_TYPE zone_type - { - INSIST(currzone != NULL); - currzone->type = $2; - } - | L_FILE L_QSTRING - { - INSIST(currzone != NULL); - if (currzone->source.base != NULL) { - parser_warning("zone filename already set; skipping"); - } else { - isc_zone_setsource(currzone, $2.base); - } - free_textregion($2, memctx); - } - | L_FILE_IXFR L_QSTRING - { - /* XXX stuff here */ - } - | L_IXFR_TMP L_QSTRING - { - /* XXX stuff here */ - } - | L_MASTERS maybe_zero_port L_LBRACE master_in_addr_list L_RBRACE - { - /* XXX stuff here */ - } - | L_TRANSFER_SOURCE maybe_wild_addr - { - /* XXX stuff here */ - } - | L_CHECK_NAMES check_names_opt - { - /* XXX stuff here */ - } - | L_ALLOW_UPDATE L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_ALLOW_QUERY L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_ALLOW_TRANSFER L_LBRACE address_match_list L_RBRACE - { - /* XXX stuff here */ - } - | L_FORWARD zone_forward_opt - | L_FORWARDERS { - /* XXX stuff here */ - } L_LBRACE opt_zone_forwarders_list L_RBRACE - | L_MAX_TRANSFER_TIME_IN L_INTEGER - { - /* XXX stuff here */ - } - | L_MAX_LOG_SIZE_IXFR L_INTEGER - { - /* XXX stuff here */ - } - | L_NOTIFY yea_or_nay - { - /* XXX stuff here */ - } - | L_MAINTAIN_IXFR_BASE yea_or_nay - { - /* XXX stuff here */ - } - | L_PUBKEY L_INTEGER L_INTEGER L_INTEGER L_QSTRING - { - /* XXX stuff here */ - } - | L_ALSO_NOTIFY L_LBRACE opt_notify_in_addr_list L_RBRACE - | L_DIALUP yea_or_nay - { - /* XXX stuff here */ - } - | error - ; - - -master_in_addr_list: master_in_addr L_EOS - { - /* nothing */ - } - | master_in_addr_list master_in_addr L_EOS - { - /* nothing */ - } - ; - -master_in_addr: L_IPADDR - { - /* XXX stuff here */ - } - ; - -opt_notify_in_addr_list: /* nothing */ - | notify_in_addr_list - ; - -notify_in_addr_list: notify_in_addr L_EOS - { - /* nothing */ - } - | notify_in_addr_list notify_in_addr L_EOS - { - /* nothing */ - } - ; - -notify_in_addr: L_IPADDR - { - /* XXX stuff here */ - } - ; - -zone_forward_opt: L_ONLY - { - /* XXX stuff here */ - } - | L_FIRST - { - /* XXX stuff here */ - } - ; - -opt_zone_forwarders_list: /* nothing */ - | zone_forwarders_in_addr_list - ; - -zone_forwarders_in_addr_list: zone_forwarders_in_addr L_EOS - { - /* nothing */ - } - | zone_forwarders_in_addr_list zone_forwarders_in_addr L_EOS - { - /* nothing */ - } - ; - -zone_forwarders_in_addr: L_IPADDR - { - /* XXX stuff here */ - } - ; - -/* - * Trusted Key statement - */ - -trusted_keys_stmt: L_TRUSTED_KEYS L_LBRACE trusted_keys_list L_RBRACE - { - /* XXX stuff here */ - } - ; -trusted_keys_list: trusted_key L_EOS - { - /* nothing */ - } - | trusted_keys_list trusted_key L_EOS - { - /* nothing */ - } - ; -trusted_key: L_STRING L_INTEGER L_INTEGER L_INTEGER L_QSTRING - { - /* XXX stuff here */ - } - ; - -/* - * Misc. - */ - -in_port: L_INTEGER - { - if ($1 < 0 || $1 > 65535) { - parser_warning( - "invalid IP port number '%d'; setting port to 0", - $1); - $1 = 0; - } else - $$ = htons($1); - } - ; - - - -any_string: L_STRING - | L_QSTRING - ; - -%% - -/* - * Definition of all unique keyword tokens to be recognised by the - * lexer. All the ``L_'' tokens defined in parser.y must be defined here too. - */ -struct token -{ - char *token; - int yaccval; -}; - -static struct token keyword_tokens [] = { - { "{", L_LBRACE }, - { "}", L_RBRACE }, - { ";", L_EOS }, - { "/", L_SLASH }, - { "!", L_BANG }, - { "*", L_STAR }, - - { "acl", L_ACL }, - { "address", L_ADDRESS }, - { "algorithm", L_ALGID }, - { "allow", L_ALLOW }, - { "allow-query", L_ALLOW_QUERY }, - { "allow-transfer", L_ALLOW_TRANSFER }, - { "allow-update", L_ALLOW_UPDATE }, - { "also-notify", L_ALSO_NOTIFY }, - { "auth-nxdomain", L_AUTH_NXDOMAIN }, - { "blackhole", L_BLACKHOLE }, - { "bogus", L_BOGUS }, - { "category", L_CATEGORY }, - { "class", L_CLASS }, - { "channel", L_CHANNEL }, - { "check-names", L_CHECK_NAMES }, - { "cleaning-interval", L_CLEAN_INTERVAL }, - { "controls", L_CONTROLS }, - { "coresize", L_CORESIZE }, - { "datasize", L_DATASIZE }, - { "deallocate-on-exit", L_DEALLOC_ON_EXIT }, - { "debug", L_DEBUG }, - { "default", L_DEFAULT }, - { "dialup", L_DIALUP }, - { "directory", L_DIRECTORY }, - { "dump-file", L_DUMP_FILE }, - { "dynamic", L_DYNAMIC }, - { "fail", L_FAIL }, - { "fake-iquery", L_FAKE_IQUERY }, - { "false", L_FALSE }, - { "fetch-glue", L_FETCH_GLUE }, - { "file", L_FILE }, - { "files", L_FILES }, - { "first", L_FIRST }, - { "forward", L_FORWARD }, - { "forwarders", L_FORWARDERS }, - { "group", L_GROUP }, - { "has-old-clients", L_HAS_OLD_CLIENTS }, - { "heartbeat-interval", L_HEARTBEAT }, - { "hint", L_HINT }, - { "host-statistics", L_HOSTSTATS }, - { "if-no-answer", L_IF_NO_ANSWER }, - { "if-no-domain", L_IF_NO_DOMAIN }, - { "ignore", L_IGNORE }, - { "include", L_INCLUDE }, - { "inet", L_INET }, - { "interface-interval", L_INTERFACE_INTERVAL }, - { "ixfr-base", L_FILE_IXFR }, - { "ixfr-tmp-file", L_IXFR_TMP }, - { "key", L_SEC_KEY }, - { "keys", L_KEYS }, - { "listen-on", L_LISTEN_ON }, - { "logging", L_LOGGING }, - { "maintain-ixfr-base", L_MAINTAIN_IXFR_BASE }, - { "many-answers", L_MANY_ANSWERS }, - { "master", L_MASTER }, - { "masters", L_MASTERS }, - { "max-ixfr-log-size", L_MAX_LOG_SIZE_IXFR }, - { "max-ncache-ttl", L_MAX_NCACHE_TTL }, - { "max-transfer-time-in", L_MAX_TRANSFER_TIME_IN }, - { "memstatistics-file", L_MEMSTATS_FILE }, - { "multiple-cnames", L_MULTIPLE_CNAMES }, - { "name", L_NAME }, - { "named-xfer", L_NAMED_XFER }, - { "no", L_NO }, - { "notify", L_NOTIFY }, - { "null", L_NULL_OUTPUT }, - { "one-answer", L_ONE_ANSWER }, - { "only", L_ONLY }, - { "order", L_ORDER }, - { "options", L_OPTIONS }, - { "owner", L_OWNER }, - { "perm", L_PERM }, - { "pid-file", L_PIDFILE }, - { "port", L_PORT }, - { "print-category", L_PRINT_CATEGORY }, - { "print-severity", L_PRINT_SEVERITY }, - { "print-time", L_PRINT_TIME }, - { "pubkey", L_PUBKEY }, - { "query-source", L_QUERY_SOURCE }, - { "rrset-order", L_RRSET_ORDER }, - { "recursion", L_RECURSION }, - { "response", L_RESPONSE }, - { "secret", L_SECRET }, - { "server", L_SERVER }, - { "severity", L_SEVERITY }, - { "size", L_SIZE }, - { "slave", L_SLAVE }, -#ifdef SORT_RESPONSE - { "sortlist", L_SORTLIST }, -#endif /* SORT_RESPONSE */ - { "stacksize", L_STACKSIZE }, - { "statistics-file", L_STATS_FILE }, - { "statistics-interval", L_STATS_INTERVAL }, - { "stub", L_STUB }, - { "support-ixfr", L_SUPPORT_IXFR }, - { "syslog", L_SYSLOG }, - { "topology", L_TOPOLOGY }, - { "transfer-format", L_TRANSFER_FORMAT }, - { "transfer-source", L_TRANSFER_SOURCE }, - { "transfers", L_TRANSFERS }, - { "transfers-in", L_TRANSFERS_IN }, - { "transfers-out", L_TRANSFERS_OUT }, - { "transfers-per-ns", L_TRANSFERS_PER_NS }, - { "true", L_TRUE }, - { "trusted-keys", L_TRUSTED_KEYS }, - { "type", L_TYPE }, - { "unix", L_UNIX }, - { "unlimited", L_UNLIMITED }, - { "use-id-pool", L_USE_ID_POOL }, - { "use-ixfr", L_USE_IXFR }, - { "version", L_VERSION }, - { "versions", L_VERSIONS }, - { "warn", L_WARN }, - { "yes", L_YES }, - { "zone", L_ZONE }, - - { NULL, 0 } -}; - - -static struct token class_symbol_tokens[] = { - { "IN", class_in }, - { "CHAOS", class_chaos }, - { "HS", class_hs }, - { "HESIOD", class_hesiod }, - { "ANY", class_any }, - { "NONE", class_none }, - { NULL, 0 } -}; - - -static void undef_symtab_entry(char *key, unsigned int type, - isc_symvalue_t value, void *arg); -static int token_value(isc_token_t *token, isc_symtab_t *symtable); - - - -isc_result_t -parser_init(void) -{ - isc_result_t res; - - INSIST(onetime == 0); - - /* our caller is (better be) locking us */ - res = isc_mutex_init(&yacc_mutex); - onetime++; - - specials['{'] = 1; - specials['}'] = 1; - specials[';'] = 1; - specials['/'] = 1; - specials['"'] = 1; - specials['!'] = 1; - specials['*'] = 1; - - return (res); -} - - -isc_result_t -parse_configuration(const char *filename, isc_mem_t *mem, - isc_cfgctx_t **configctx) -{ - isc_result_t res; - const char *funcname = "parse_configuration"; - - REQUIRE(currcfg == NULL); - REQUIRE(filename != NULL); - REQUIRE(strlen(filename) > 0); - REQUIRE(configctx != NULL); - INSIST(memctx == NULL); - INSIST(mylexer == NULL); - INSIST(keywords == NULL); - - /* Lock down whole parser. */ - if (isc_mutex_lock(&yacc_mutex) != ISC_R_SUCCESS) { - return (ISC_R_UNEXPECTED); - } - - if (getenv("DEBUG_LEXER") != NULL) { - debug_lexer++; - } - - seen_options = 0; - seen_topology = 0; - - /* It would be better to do this create in parse_init and let the - * object live across calls, but doing it here lets us catch memory - * leaks (in the destroy method) - */ - RUNTIME_CHECK(isc_mem_create(0, 0, &memctx) == ISC_R_SUCCESS); - - RUNTIME_CHECK(symtable_init() == ISC_R_SUCCESS); - - RUNTIME_CHECK(isc_lex_create(memctx, CONF_MAX_IDENT, &mylexer) - == ISC_R_SUCCESS); - - isc_lex_setspecials(mylexer, specials); - isc_lex_setcomments(mylexer, (ISC_LEXCOMMENT_C | - ISC_LEXCOMMENT_CPLUSPLUS | - ISC_LEXCOMMENT_SHELL)); - - res = isc_lex_openfile(mylexer, (char *)filename) ; /* remove const */ - if (res != ISC_R_SUCCESS) { - debug_print("%s: Error opening file %s: %s", - funcname, filename, isc_result_totext(res)); - goto done; - } - - if ((res = isc_cfg_newctx(mem, &currcfg)) != ISC_R_SUCCESS) { - debug_print("%s: Error creating config context: %s", - funcname, isc_result_totext(res)); - goto done; - } - - currfile = filename; - currzonectx = currcfg->zonecontext; - - if (yyparse() != 0) { - res = ISC_R_FAILURE; - isc_cfg_freectx(&currcfg); - currcfg = NULL; - } else { - res = ISC_R_SUCCESS; - } - - - done: - if (keywords != NULL) - isc_symtab_destroy(&keywords); - if (mylexer != NULL) - isc_lex_destroy(&mylexer); - isc_mem_destroy(&memctx); - - *configctx = currcfg; - - currcfg = NULL; - memctx = NULL; - keywords = NULL; - mylexer = NULL; - - RUNTIME_CHECK(isc_mutex_unlock(&yacc_mutex) == ISC_R_SUCCESS); - - if (*configctx != NULL) /* XXX DEBUG */ - isc_cfg_dump_config(stderr,*configctx); - - return (res); -} - - - -/*** - *** PRIVATE - ***/ - - -static int -yylex(void) -{ - isc_token_t token; - isc_result_t res; - int options = (ISC_LEXOPT_EOF | - ISC_LEXOPT_NUMBER | - ISC_LEXOPT_QSTRING | - ISC_LEXOPT_NOMORE); - - INSIST(mylexer != NULL); - - res = isc_lex_gettoken(mylexer, options, &token); - - switch(res) { - case ISC_R_SUCCESS: - res = token_value(&token, keywords); /* modifies yylval */ - break; - - case ISC_R_EOF: - res = 0; - break; - - case ISC_R_UNBALANCED: - parser_error("%s: %d: unbalanced parentheses", - isc_lex_getsourcename(mylexer), - isc_lex_getsourceline(mylexer)); - res = -1; - break; - - case ISC_R_NOSPACE: - parser_error("%s: %d: token too big.", - isc_lex_getsourcename(mylexer), - isc_lex_getsourceline(mylexer)); - res = -1; - break; - - case ISC_R_UNEXPECTEDEND: - parser_error("%s: %d: unexpected EOF", - isc_lex_getsourcename(mylexer), - isc_lex_getsourceline(mylexer)); - res = -1; - break; - - default: - parser_error("%s: %d unknown lexer error (%d)", - isc_lex_getsourcename(mylexer), - isc_lex_getsourceline(mylexer), - res); - res = -1; - break; - } - - return (res); -} - - - -static void -undef_symtab_entry(char *key, unsigned int type, isc_symvalue_t value, - void *arg) -{ - /* XXX nothing yet */ -} - - -/* XXX this should switch to using logging stuff. */ -static void -print_msg(const char *fmt, va_list args) -{ - fprintf(stderr," %s: %d: ", - isc_lex_getsourcename(mylexer), - isc_lex_getsourceline(mylexer)); - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); -} - - -static void -debug_print(const char *fmt, ...) -{ - va_list args; - - /* XXX probably want to print based on some debug level */ - - if (debugging_stuff) { - va_start(args, fmt); - print_msg(fmt, args); - va_end(args); - } -} - - - -/* - * For reporting items that are semantic, but not syntactic errors - */ -static void -parser_error(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - print_msg(fmt, args); - va_end(args); - - currcfg->errors++; -} - - -static void -parser_warning(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - print_msg(fmt, args); - va_end(args); - - currcfg->warnings++; -} - -static void -yyerror_helper(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - print_msg(fmt, args); - va_end(args); - - currcfg->warnings++; -} - - -static void -yyerror(const char *string) -{ - yyerror_helper("%s",string); -} - - -static int -token_value(isc_token_t *token, isc_symtab_t *symtable) -{ - int res = -1; - const char *tokstring; - char tmpident [2]; - isc_symvalue_t keywordtok; - - switch (token->type) { - case isc_tokentype_unknown: - res = -1; - break; - - case isc_tokentype_special: - case isc_tokentype_string: - if (token->type == isc_tokentype_special) { - tmpident[0] = token->value.as_char; - tmpident[1] = '\0'; - tokstring = tmpident; - } else { - tokstring = token->value.as_textregion.base; - } - - if (debug_lexer) { - fprintf(stderr, "lexer token: %s / %s\n", - (token->type == isc_tokentype_special ? - "special" : "string"), tokstring); - } - - res = isc_symtab_lookup(symtable, tokstring, - keyword_type, &keywordtok); - - if (res != ISC_R_SUCCESS) { - res = intuit_token(symtable, tmpident); - /* XXX */ - res = copy_textregion(memctx, - token->value.as_textregion, - &yylval.text); - if (res != ISC_R_SUCCESS) { - res = -1; - } else { - res = L_STRING; - } - } else { - res = keywordtok.as_integer; - } - break; - - case isc_tokentype_number: - yylval.ul_int = token->value.as_ulong; - res = L_INTEGER; - - if(debug_lexer) { - fprintf(stderr, "lexer token: number / %ld\n", - yylval.ul_int); - } - - break; - - case isc_tokentype_qstring: - res = copy_textregion(memctx,token->value.as_textregion, - &yylval.text); - if (res != ISC_R_SUCCESS) { - res = -1; - } else { - res = L_QSTRING; - } - - if (debug_lexer) { - fprintf(stderr, "lexer token: qstring \"%s\"\n", - yylval.text.base); - } - - break; - - case isc_tokentype_eof: - if (debug_lexer) { - fprintf(stderr, "lexer token: EOF\n"); - } - res = isc_lex_close(mylexer); - INSIST(res == ISC_R_NOMORE || res == ISC_R_SUCCESS); - - if (isc_lex_getsourcename(mylexer) == NULL) { - /* the only way to tell that we - closed the main file and not an included file */ - res = 0; - } else { - res = L_END_INCLUDE; - } - break; - - case isc_tokentype_initialws: - case isc_tokentype_eol: - case isc_tokentype_nomore: - res = -1; - break; - } - - return (res); -} - - -/* - * Allocate a new buffer and copy the data to it. Add an extra byte for a null. - */ -static isc_result_t -copy_textregion(isc_mem_t *mem, - isc_textregion_t region, isc_textregion_t *newregion) -{ - INSIST(mem != NULL); - - newregion->base = isc_mem_get(mem, region.length + 1); - if (newregion->base == NULL) { - return (ISC_R_NOMEMORY); - } - - newregion->length = region.length + 1; - memcpy(newregion->base, region.base, region.length); - newregion->base[region.length] = '\0'; - - return (ISC_R_SUCCESS); -} - - -static void -free_textregion(isc_textregion_t region, isc_mem_t *mem) -{ - INSIST(mem != NULL); - INSIST(region.base != NULL); - INSIST(region.length > 0); - - isc_mem_put(mem, region.base, region.length); - - return; -} - - - -static int -intuit_token(isc_symtab_t *symtab, const char *string) -{ - /* XXX given a string that's something other than a keyword, figure - * out the type of data is represents. - */ - return -1; -} - - -/* - * Conversion Routines - */ - -static int -unit_to_ulong(char *in, unsigned long *out) { - int c, units_done = 0; - unsigned long result = 0L; - - INSIST(in != NULL); - - for (; (c = *in) != '\0'; in++) { - if (units_done) - return (0); - if (isdigit(c)) { - result *= 10; - result += (c - '0'); - } else { - switch (c) { - case 'k': - case 'K': - result *= 1024; - units_done = 1; - break; - case 'm': - case 'M': - result *= (1024*1024); - units_done = 1; - break; - case 'g': - case 'G': - result *= (1024*1024*1024); - units_done = 1; - break; - default: - return (0); - } - } - } - - *out = result; - return (1); -} - -static isc_result_t -define_symbol(isc_symtab_t *symtable, const char *key, int type, int value) { - isc_symvalue_t symval; - isc_result_t res; - - symval.as_integer = value; - res = isc_symtab_define(symtable, /* dump const */ (char *) key, - type, symval, isc_symexists_reject); - - if (res != ISC_R_SUCCESS) { - debug_print("Error installing keyword: %s: %s", - key, isc_result_totext(res)); - return (res); - } - - return (ISC_R_SUCCESS); -} - - - -static isc_result_t -symtable_init(void) -{ - struct token *tok; - - RUNTIME_CHECK(isc_symtab_create(memctx, SYMTAB_SIZE, - undef_symtab_entry, NULL, - ISC_FALSE, &keywords) == - ISC_R_SUCCESS); - - - /* Stick all the keywords into the main symbol table. */ - for (tok = &keyword_tokens[0] ; tok->token != NULL ; tok++) { - RUNTIME_CHECK(define_symbol(keywords, tok->token, - keyword_type, tok->yaccval) == - ISC_R_SUCCESS); - } - - /* Now the class names */ - for (tok = &class_symbol_tokens[0] ; tok->token != NULL ; tok++) { - RUNTIME_CHECK(define_symbol(keywords, tok->token, - class_sym_type, tok->yaccval) == - ISC_R_SUCCESS); - } - - return (ISC_R_SUCCESS); -} diff --git a/bin/named/lexer.l b/bin/named/lexer.l deleted file mode 100644 index 59ece735d4..0000000000 --- a/bin/named/lexer.l +++ /dev/null @@ -1,72 +0,0 @@ -%{ -#if !defined(lint) && !defined(SABER) -static char rcsid[] = "$Id: lexer.l,v 1.1 1999/01/30 00:50:10 brister Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include - -#include -#include - -#include "zone.h" -#include "parser_p.h" - -int yylex(void); - -%} - -qstring \"[^\"\n]*[\"\n] -intnum -?[0-9]+ -ws [ \t]+ - -%% - -"{" { return (L_LBRACE); } -"}" { return (L_RBRACE); } -";" { return (L_EOS); } - - - -"options" { return (L_OPTIONS); } -"directory" { return (L_DIRECTORY); } -"zone" { return (L_ZONE); } -"type" { return (L_TYPE); } -"file" { return (L_FILE); } -"master" { return (L_MASTER); } -"slave" { return (L_SLAVE); } -"hint" { return (L_HINT); } -"stub" { return (L_STUB); } -"forward" { return (L_FORWARD); } - -{intnum} { - yylval.num = strtol(yytext, NULL, 10); - return (L_INTEGER); -} - -{qstring} { - yylval.cp = strdup(yytext + 1); /* skip open quote */ - if (yylval.cp[yyleng - 2] != '"') { - /* XXX use an isc log function. */ - fprintf(stderr, "Unterminated string"); - } else { - yylval.cp[yyleng - 2] = '\0'; - return L_QSTRING; - } -} diff --git a/bin/named/parser.h b/bin/named/parser.h deleted file mode 100644 index 1ef2641772..0000000000 --- a/bin/named/parser.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/***** - ***** Module Info - *****/ - -/* - * Parser - * - * The parser module handles the parsing of config files. - * - * MP: - * Only a single thread is let through the modules at once. - * access. - * - * Reliability: - * No anticipated impact. - * - * Resources: - * - * - * Security: - * - * - * Standards: - * None. - */ - - -/*** - *** Imports - ***/ - -#include - -#include "configctx.h" - -/*** - *** Functions - ***/ - -isc_result_t -isc_parser_init(void); -/* - * Does parser intitialization. Must be called before - * isc_parse_configuration() is called - * - * Requires: - * The caller do necessary locking to prevent multiple threads from - * calling it at once. - * - * Ensures: - * Nothing. - * - * Returns: - * ISC_R_SUCCESS - * ISC_R_FAILURE something broke - */ - - -isc_result_t -isc_parse_configuration(const char *filename, - isc_mem_t *mem, - isc_cfgctx_t **configctx); - -/* - * Parse the confile file. Fills up the config context with the new config - * data. All memory allocations for the contents of configctx are done - * using the MEM argument. - * - * Requires: - * *filename is a valid filename. - * *mem is a valid memory manager. - * *configctx is a valid isc_config_ctx_t pointer - * - * Ensures: - * On success, *configctx is attached to the newly created config context. - * - * Returns: - * ISC_R_SUCCESS - * ISC_R_NOMEMORY - * ISC_R_INVALIDFILE file doesn't exist or is unreadable - * ISC_R_FAILURE file contains errors. - */ - diff --git a/bin/named/parser.y b/bin/named/parser.y deleted file mode 100644 index e03d63dddb..0000000000 --- a/bin/named/parser.y +++ /dev/null @@ -1,304 +0,0 @@ -%{ -#if !defined(lint) && !defined(SABER) -static char rcsid[] = "$Id: parser.y,v 1.1 1999/01/30 00:50:10 brister Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include - -#include -#include - -#include -#include - -#include "parser.h" -#include "zone.h" -#include "configctx.h" - -static int onetime ; -static isc_mutex_t yacc_mutex; - -static isc_zonectx_t *currzonectx; -static isc_zoneinfo_t *currzone; -static isc_cfgctx_t *currcfg; -static const char *currfile; - - -static void parser_cleanup(void); -static void print_msg(char *fmt, va_list args); -static void parser_warning(char *fmt, ...); -static void parser_error(char *fmt, ...); - -int yyparse(void); -void yyerror(const char *); -int yylex(void); - - - -%} - -%union { - char * cp; - long num; - isc_zonet_t ztype; -} - - -%token L_LBRACE -%token L_RBRACE -%token L_EOS -%token L_MASTER -%token L_SLAVE -%token L_HINT -%token L_STUB -%token L_FORWARD - - -/* options statement */ -%token L_OPTIONS -%token L_DIRECTORY - - -/* Zone statements */ -%token L_ZONE -%type zone_type -%token L_TYPE -%token L_FILE - - -/* Misc */ -%token L_STRING -%token L_QSTRING -%token L_INTEGER - - -%% - -config_file: statement_list - { - /* XXX Do post-read validations etc. */ - } - ; - -statement_list: statement - | statement_list statement - ; - -statement: options_stmt L_EOS - | zone L_EOS - ; - -options_stmt: L_OPTIONS L_LBRACE options_list L_RBRACE - ; - -options_list: option L_EOS - | options_list option L_EOS - ; - - -option: /* Empty */ - | L_DIRECTORY L_QSTRING - { - printf("doing the option\n"); - if (isc_cfg_setdirectory(currcfg, $2) != ISC_R_SUCCESS) { - parser_cleanup(); - fprintf(stderr, "setdirectory error\n"); - return (1); - } - } - ; - -zone: L_ZONE L_QSTRING - { - isc_zoneinfo_t *zi = NULL; - - if (isc_zone_newinfo(currzonectx, &zi) != ISC_R_SUCCESS) { - parser_cleanup(); - fprintf(stderr, "newzone error\n"); - return (1); - } - - isc_zone_setorigin(zi, $2); - - currzone = zi; - } optional_zone_options_list { - /* XXX install zone if parsed correctly and remove - it if not. */ - } - ; - -optional_zone_options_list: /* Empty */ - | L_LBRACE zone_option_list L_RBRACE - ; - -zone_option_list: zone_option L_EOS - | zone_option_list zone_option L_EOS - ; - -zone_option: L_TYPE zone_type - { - } - | L_FILE L_QSTRING - { - INSIST(currzone != NULL); - if (currzone->source != NULL) { - parser_warning("zone filename already set; skipping"); - } else { - isc_zone_setsource(currzone, $2); - } - } - ; - - -zone_type: L_MASTER - { - $$ = zone_master; - } - | L_SLAVE - { - $$ = zone_slave; - } - | L_HINT - { - $$ = zone_hint; - } - | L_STUB - { - $$ = zone_stub; - } - | L_FORWARD - { - $$ = zone_forward; - } - ; - - - -%% - -isc_result_t -isc_parser_init() -{ - isc_result_t res = ISC_R_SUCCESS; - - if (onetime == 0) { - /* our caller is locking us */ - res = isc_mutex_init(&yacc_mutex); - - onetime++; - } - - return (res); -} - - -isc_result_t -isc_parse_configuration(const char *filename, - isc_mem_t *mem, - isc_cfgctx_t **configctx) { - isc_result_t res ; - isc_result_t t; - FILE *fp; - extern FILE *yyin; - - /* Take out mutex on whole parser. */ - if (isc_mutex_lock(&yacc_mutex) != ISC_R_SUCCESS) { - return (ISC_R_UNEXPECTED); - } - - INSIST(currcfg == NULL); - - if ((res = isc_cfg_newctx(mem, &currcfg)) != ISC_R_SUCCESS) { - isc_mutex_unlock(&yacc_mutex); - return (res); - } - - if ((fp = fopen(filename, "r")) == NULL) { - isc_mutex_unlock(&yacc_mutex); - return (ISC_R_INVALIDFILE); - } - - yyin = fp ; - currfile = filename; - currzonectx = currcfg->zonecontext; - - if (yyparse() != 0) { - res = ISC_R_FAILURE; - } - - fclose(fp); - - *configctx = currcfg; - currcfg = NULL; - - if ((t = isc_mutex_unlock(&yacc_mutex)) != ISC_R_SUCCESS) { - res = t; - } - - return (res); -} - - - -/*** - *** PRIVATE - ***/ - -static void -parser_cleanup(void) -{ - /* XXX destroy the config context */ -} - - -static void -print_msg(char *fmt, va_list args) -{ - fprintf(stderr," %s: \n", currfile); - vfprintf(stderr, fmt, args); -} - -static void -parser_warning(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - print_msg(fmt, args); - va_end(args); - - currcfg->warnings++; -} - - -static void -parser_error(char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - print_msg(fmt, args); - va_end(args); - - currcfg->errors++; -} - - - diff --git a/bin/named/server.c b/bin/named/server.c index 53f8f5c4a6..2296dcb321 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -52,7 +52,6 @@ #include -#include "confparser.h" #include "udpclient.h" #include "tcpclient.h" #include "interfacemgr.h" @@ -430,11 +429,6 @@ main(int argc, char *argv[]) RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS); -#if 0 /* brister */ - isc_cfgctx_t *configctx = NULL; - const char *conffile = "/etc/named.conf"; /* XXX hardwired */ -#endif - RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); RUNTIME_CHECK(dns_dbtable_create(mctx, dns_rdataclass_in, &dbtable) == DNS_R_SUCCESS); @@ -482,12 +476,6 @@ main(int argc, char *argv[]) workers = 2; printf("%d workers\n", workers); -#if 0 /* brister */ - parser_init(); - RUNTIME_CHECK(parse_configuration(conffile, mctx, &configctx) == - ISC_R_SUCCESS); -#endif - RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) == ISC_R_SUCCESS); diff --git a/bin/named/zone.c b/bin/named/zone.c deleted file mode 100644 index 01e2815282..0000000000 --- a/bin/named/zone.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include - -#include -#include - -#include - -#include -#include - -#include "zone.h" - -/* - * NOTE: we do not 'realloc' to keep all the zones in contiguous memory. - * - */ - -#define ZONECHUNK 50 /* how many zone structs we make at once.*/ -#define ZONE_USED_MAGIC 0x7fffffff -#define ZONE_FREE_MAGIC 0x0 - - -isc_result_t -isc_zone_newcontext(isc_mem_t *memctx, isc_zonectx_t **zctx) -{ - isc_zonectx_t *zc ; - - INSIST(zctx != NULL); - INSIST(memctx != NULL); - - zc = isc_mem_get(memctx, sizeof *zc); - INSIST(zc != NULL); - - memset(zc, 0x0, sizeof *zc); - zc->memctx = memctx; - - *zctx = zc; - - return ISC_R_SUCCESS; -} - - -isc_result_t -isc_zone_freecontext(isc_zonectx_t *zonectx) -{ - isc_zoneinfo_t *zi; - isc_zoneinfo_t *zp; - - zi = ISC_LIST_HEAD(zonectx->freezones); - while (zi != NULL ) { - zp = zi; - zi = ISC_LIST_NEXT(zi, chainlink); - - isc_zone_release_zone(zp); - } - - return (ISC_R_SUCCESS); -} - -isc_result_t -isc_zone_newinfo(isc_zonectx_t *zctx, isc_zoneinfo_t **zone) -{ - struct isc_zoneinfo *zp; - - INSIST(zctx != NULL); - INSIST(zone != NULL); - - if (ISC_LIST_EMPTY(zctx->freezones)) { - int bytes = sizeof (*zp) * ZONECHUNK; - int idx; - - zp = isc_mem_get(zctx->memctx, bytes); - INSIST(zp != NULL); - - memset(zp, 0x0, bytes); - zp->magic = ZONE_FREE_MAGIC; - - for (idx = 0 ; idx < ZONECHUNK ; idx++) { - zp[idx].magic = ZONE_FREE_MAGIC; - ISC_LIST_APPEND(zctx->freezones, &zp[idx], chainlink); - } - } - - INSIST(!ISC_LIST_EMPTY(zctx->freezones)); - - zp = ISC_LIST_HEAD(zctx->freezones); - ISC_LIST_UNLINK(zctx->freezones, zp, chainlink); - ISC_LIST_APPEND(zctx->usedzones, zp, chainlink); - - zp->magic = ZONE_USED_MAGIC; - zp->zctx = zctx; - - *zone = zp; - - return ISC_R_SUCCESS; -} - - -isc_result_t -isc_zone_freezone(isc_zoneinfo_t *zone) -{ - INSIST(zone != NULL); - INSIST(zone->magic == ZONE_USED_MAGIC); - INSIST(zone->zctx != NULL); - - ISC_LIST_UNLINK(zone->zctx->usedzones, zone, chainlink); - zone->magic = ZONE_FREE_MAGIC; - ISC_LIST_APPEND(zone->zctx->freezones, zone, chainlink); - - return ISC_R_SUCCESS; -} - - -isc_result_t -isc_zone_release_zone(isc_zoneinfo_t *zone) -{ - isc_mem_put(zone->zctx->memctx, zone, sizeof *zone); - - return (ISC_R_SUCCESS); -} - - -isc_result_t -isc_zone_setsource(isc_zoneinfo_t *zone, const char *source) -{ - size_t len; - - INSIST(zone != NULL); - INSIST(source != NULL); - - len = strlen(source) + 1; - - INSIST(len > 1); - - zone->source.base = isc_mem_get(zone->zctx->memctx, len); - if (zone->source.base == NULL) { - return (ISC_R_NOMEMORY); - } - zone->source.length = len; - strcpy(zone->source.base, source); - - return (ISC_R_SUCCESS); -} - - -isc_result_t -isc_zone_setorigin(isc_zoneinfo_t *zone, const char *origin) -{ - size_t len; - - INSIST(zone != NULL); - INSIST(origin != NULL); - - len = strlen(origin) + 1; - - INSIST(len > 1); - - zone->origin.base = isc_mem_get(zone->zctx->memctx, len); - if (zone->origin.base == NULL) { - return (ISC_R_NOMEMORY); - } - zone->origin.length = len; - - strcpy(zone->origin.base, origin); - - return (ISC_R_SUCCESS); -} - - -const char * -isc_zonetype_to_string(isc_zonet_t zone_type) -{ - const char *res = NULL; - switch (zone_type) { - case zone_master: - res = "master"; - break; - case zone_slave: - res = "slave"; - break; - case zone_hint: - res = "hint"; - break; - case zone_stub: - res = "stub"; - break; - case zone_forward: - res = "forward"; - break; - } - - INSIST (res != NULL); - - return (res); -} - - -void -isc_zonectx_dump(FILE *fp, isc_zonectx_t *ctx) -{ - isc_zoneinfo_t *zi; - - INSIST(ctx != NULL); - - zi = ISC_LIST_HEAD(ctx->usedzones); - while (zi != NULL ) { - isc_zone_dump(fp, zi); - zi = ISC_LIST_NEXT(zi, chainlink); - } -} - - -void -isc_zone_dump(FILE *fp, isc_zoneinfo_t *zone) -{ - INSIST(fp != NULL); - INSIST(zone != NULL); - - fprintf(fp, "zone \"%s\" %s {\n", zone->origin.base, - rrclass_to_string(zone->zone_class)); - fprintf(fp, "\ttype %s;\n",isc_zonetype_to_string(zone->type)); - - /* XXX this will get more complicated */ - fprintf(fp, "\tfile \"%s\";\n",zone->source.base); - fprintf(fp, "}\n"); -} - - - -isc_result_t -isc_zone_setclass(isc_zoneinfo_t *zone, isc_rrclass_t rrclass) -{ - INSIST(zone != NULL); - - zone->zone_class = rrclass; - - return (ISC_R_SUCCESS); -} - - -const char * -rrclass_to_string(isc_rrclass_t rrclass) -{ - const char *res; - - switch (rrclass) { - case class_none: - res = "NONE"; - break; - case class_any: - res = "ANY"; - break; - case class_in: - res = "IN"; - break; - case class_chaos: - res = "CHAOS"; - break; - case class_hesiod: - res = "HESIOD"; - break; - case class_hs: - res = "HS"; - break; - default: - res = NULL; - break; - } - - INSIST(res != NULL); - - return (res); -} - - diff --git a/bin/named/zone.h b/bin/named/zone.h deleted file mode 100644 index c214bd6bbf..0000000000 --- a/bin/named/zone.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#if ! defined(ZONE_H) -#define ZONE_H - -#include - -#include - -#include -#include -#include -#include - -#include - -/* Zone context structures contain a set of zones and related information - (like isc_mem_t contexts to allocate memory from). */ -typedef struct isc_zonectx isc_zonectx_t; - -/* The zone. All access is through function API */ -typedef struct isc_zoneinfo isc_zoneinfo_t; - - -typedef enum { - zone_master, zone_slave, zone_hint, zone_stub, zone_forward -} isc_zonet_t ; - - -typedef enum { - class_any, class_none, class_in, class_chaos, class_hesiod, - class_hs -} isc_rrclass_t; - - -/* This structure contains all the run-time information about a zone. */ -struct isc_zoneinfo -{ - isc_int32_t magic; /* private magic stamp for valid'ng */ - - isc_textregion_t origin; - isc_textregion_t source; - - isc_zonet_t type; /* master, slave etc. */ - isc_rrclass_t zone_class; /* IN, CHAOS etc. */ - - dns_db_t *thedb; - - - /* The rest below aren't implmented yet */ - - time_t filemodtime; /* mod time of zone file */ - time_t lastupdate; /* time last soa serial increment */ - isc_uint32_t refresh; /* refresh interval */ - isc_uint32_t retry; /* refresh retry interval */ - isc_uint32_t expire; /* expiration time for cached info */ - isc_uint32_t minimum; /* minimum TTL value */ - isc_uint32_t serial; /* SOA serial number */ - - unsigned int options; /* zone specific options */ - int zoneclass; /* zone class type */ - - struct isc_zonectx *zctx; /* contect zone came from. */ - - ISC_LINK(struct isc_zoneinfo) chainlink; -}; - - -/* This structure contains context information about a set of - zones. Presumamable there'd only be one of these passed around the - various threads, but separating out zones might be useful in some way */ -struct isc_zonectx -{ - ISC_LIST(isc_zoneinfo_t) freezones; - ISC_LIST(isc_zoneinfo_t) usedzones; - - isc_mem_t *memctx; /* where we get all our memory from */ -}; - - - -/* Allocate a zone context from the memctx pool. All zone-private data - * structures will be will be made from that same pool. - */ -isc_result_t isc_zone_newcontext(isc_mem_t *memctx, isc_zonectx_t **ctx); - -/* Allocate a zone from the give zone context. */ -isc_result_t isc_zone_newinfo(isc_zonectx_t *zctx, isc_zoneinfo_t **zone); - -isc_result_t isc_zone_release_zone(isc_zoneinfo_t *zone); - -/* write named.conf-type format */ -void isc_zone_dump(FILE *fp, isc_zoneinfo_t *zone); - -/* Free up a zone and all associated data structures. The zone knows which - *zone context to go back to - */ -isc_result_t isc_zone_freezone(isc_zoneinfo_t *zone); -isc_result_t isc_zone_freecontext(isc_zonectx_t *ctx); - -/* These functions copy the data they're given. */ -isc_result_t isc_zone_setsource(isc_zoneinfo_t *zone, - const char *source); -isc_result_t isc_zone_setorigin(isc_zoneinfo_t *zone, - const char *origin); - -isc_result_t isc_zone_setclass(isc_zoneinfo_t *zone, isc_rrclass_t class); - - - -const char * isc_zonetype_to_string(isc_zonet_t zont_type); -void isc_zonectx_dump(FILE *fp, isc_zonectx_t *ctx); -void isc_zone_dump(FILE *fp, isc_zoneinfo_t *zone); - -const char * rrclass_to_string(isc_rrclass_t rrclass); - - - -#endif