From 0d5d8e2bbf2c0c129f0416f24758a0925ce12be8 Mon Sep 17 00:00:00 2001 From: James Brister Date: Thu, 15 Jun 2000 23:38:16 +0000 Subject: [PATCH] 259. [func] New random-device and random-seed-file statements for global options block of named.conf. Both accept a single string argument. --- CHANGES | 4 ++++ bin/tests/named.conf | 2 ++ lib/dns/config/confctx.c | 18 ++++++++++++++++- lib/dns/config/confparser.y | 38 ++++++++++++++++++++++++++++++++++- lib/dns/include/dns/confctx.h | 12 +++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 763e0b6997..d3e2f85434 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + 259. [func] New random-device and random-seed-file statements + for global options block of named.conf. Both accept + a single string argument. + 258. [bug] Fixed printing of lwres_addr_t.address field. 257. [bug] The server detached the last zone manager reference diff --git a/bin/tests/named.conf b/bin/tests/named.conf index 5c8946b8a0..dd6f2a3b0d 100644 --- a/bin/tests/named.conf +++ b/bin/tests/named.conf @@ -16,6 +16,8 @@ options { version "my version string"; + random-device "/dev/random"; + random-seed-file "/random/seed/file"; directory "/tmp"; port 666; diff --git a/lib/dns/config/confctx.c b/lib/dns/config/confctx.c index b854dc11d0..c21c03f4bb 100644 --- a/lib/dns/config/confctx.c +++ b/lib/dns/config/confctx.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: confctx.c,v 1.68 2000/06/09 22:13:20 brister Exp $ */ +/* $Id: confctx.c,v 1.69 2000/06/15 23:38:12 brister Exp $ */ #include @@ -921,6 +921,8 @@ dns_c_ctx_optionsprint(FILE *fp, int indent, dns_c_options_t *options) PRINT_CHAR_P(stats_filename, "statistics-file"); PRINT_CHAR_P(memstats_filename, "memstatistics-file"); PRINT_CHAR_P(named_xfer, "named-xfer"); + PRINT_CHAR_P(random_device, "random-device"); + PRINT_CHAR_P(random_seed_file, "random-seed-file"); PRINT_INTEGER(port, "port"); @@ -1413,6 +1415,8 @@ dns_c_ctx_optionsnew(isc_mem_t *mem, dns_c_options_t **options) opts->stats_filename = NULL; opts->memstats_filename = NULL; opts->named_xfer = NULL; + opts->random_device = NULL; + opts->random_seed_file = NULL; opts->port = NULL; @@ -1546,6 +1550,8 @@ dns_c_ctx_optionsdelete(dns_c_options_t **opts) FREESTRING(stats_filename); FREESTRING(memstats_filename); FREESTRING(named_xfer); + FREESTRING(random_device); + FREESTRING(random_seed_file); FREEFIELD(expert_mode); @@ -1703,6 +1709,16 @@ GETSTRING(namedxfer, named_xfer) UNSETSTRING(namedxfer, named_xfer) +SETSTRING(randomdevice, random_device) +GETSTRING(randomdevice, random_device) +UNSETSTRING(randomdevice, random_device) + + +SETSTRING(randomseedfile, random_seed_file) +GETSTRING(randomseedfile, random_seed_file) +UNSETSTRING(randomseedfile, random_seed_file) + + GETBYTYPE(in_port_t, port, port) SETBYTYPE(in_port_t, port, port) UNSETBYTYPE(in_port_t, port, port) diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y index 852d1d0622..b44be2e1cb 100644 --- a/lib/dns/config/confparser.y +++ b/lib/dns/config/confparser.y @@ -16,7 +16,7 @@ * SOFTWARE. */ -/* $Id: confparser.y,v 1.96 2000/06/09 22:13:21 brister Exp $ */ +/* $Id: confparser.y,v 1.97 2000/06/15 23:38:14 brister Exp $ */ #include @@ -321,6 +321,8 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult); %token L_OPTIONS %token L_ORDER %token L_OWNER +%token L_RANDOM_DEVICE +%token L_RANDOM_SEED_FILE %token L_PERM %token L_PIDFILE %token L_PORT @@ -583,6 +585,38 @@ option: /* Empty */ isc_mem_free(memctx, $2); } + | L_RANDOM_DEVICE L_QSTRING + { + tmpres = dns_c_ctx_setrandomdevice(currcfg, $2); + if (tmpres == ISC_R_EXISTS) { + parser_error(ISC_FALSE, + "cannot redefine random-device"); + YYABORT; + } else if (tmpres != ISC_R_SUCCESS) { + parser_error(ISC_FALSE, + "error setting random-device: %s: %s", + isc_result_totext(tmpres), $2); + YYABORT; + } + + isc_mem_free(memctx, $2); + } + | L_RANDOM_SEED_FILE L_QSTRING + { + tmpres = dns_c_ctx_setrandomseedfile(currcfg, $2); + if (tmpres == ISC_R_EXISTS) { + parser_error(ISC_FALSE, + "cannot redefine random-seed-file"); + YYABORT; + } else if (tmpres != ISC_R_SUCCESS) { + parser_error(ISC_FALSE, + "error setting random-seed-file: %s: %s", + isc_result_totext(tmpres), $2); + YYABORT; + } + + isc_mem_free(memctx, $2); + } | L_TKEY_DOMAIN L_QSTRING { tmpres = dns_c_ctx_settkeydomain(currcfg, $2); @@ -5128,6 +5162,8 @@ static struct token keyword_tokens [] = { { "pubkey", L_PUBKEY }, { "query-source", L_QUERY_SOURCE }, { "query-source-v6", L_QUERY_SOURCE_V6 }, + { "random-device", L_RANDOM_DEVICE }, + { "random-seed-file", L_RANDOM_SEED_FILE }, { "request-ixfr", L_REQUEST_IXFR }, { "rfc2308-type1", L_RFC2308_TYPE1 }, { "rrset-order", L_RRSET_ORDER }, diff --git a/lib/dns/include/dns/confctx.h b/lib/dns/include/dns/confctx.h index 6cde6b3ab2..255ec9cc5d 100644 --- a/lib/dns/include/dns/confctx.h +++ b/lib/dns/include/dns/confctx.h @@ -115,6 +115,8 @@ struct dns_c_options { char *stats_filename; char *memstats_filename; char *named_xfer; + char *random_device; + char *random_seed_file; in_port_t *port; @@ -312,6 +314,16 @@ isc_result_t dns_c_ctx_getnamedxfer(dns_c_ctx_t *ctx, char **retval); isc_result_t dns_c_ctx_unsetnamedxfer(dns_c_ctx_t *ctx); +isc_result_t dns_c_ctx_setrandomdevice(dns_c_ctx_t *ctx, const char *newval); +isc_result_t dns_c_ctx_getrandomdevice(dns_c_ctx_t *ctx, char **retval); +isc_result_t dns_c_ctx_unsetrandomdevice(dns_c_ctx_t *ctx); + + +isc_result_t dns_c_ctx_setrandomseedfile(dns_c_ctx_t *ctx, const char *newval); +isc_result_t dns_c_ctx_getrandomseedfile(dns_c_ctx_t *ctx, char **retval); +isc_result_t dns_c_ctx_unsetrandomseedfile(dns_c_ctx_t *ctx); + + isc_result_t dns_c_ctx_setport(dns_c_ctx_t *cfg, in_port_t newval); isc_result_t dns_c_ctx_getport(dns_c_ctx_t *cfg, in_port_t *retval); isc_result_t dns_c_ctx_unsetport(dns_c_ctx_t *cfg);