From d7ba3622ffa20c653ef6c8cfae42d8cd26465b7f Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Wed, 28 Mar 2001 00:16:09 +0000 Subject: [PATCH] 794. [func] Implement the "port" and "default-port" statements in rndc.conf. --- CHANGES | 3 +++ bin/rndc/rndc.c | 25 ++++++++++++++++++++++++- bin/rndc/rndc.conf.5 | 37 +++++++++++++++++++------------------ lib/isccfg/parser.c | 4 +++- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 6fd19a98aa..323bf2706e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ + 794. [func] Implement the "port" and "default-port" statements + in rndc.conf. + 793. [cleanup] The DNSSEC tools could create filenames that were illegal or contained shell metacharacters. They now use a different text encoding of names that diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 391a9c5cb3..882ee564f6 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rndc.c,v 1.45 2001/03/27 02:34:36 bwelling Exp $ */ +/* $Id: rndc.c,v 1.46 2001/03/28 00:16:06 bwelling Exp $ */ /* * Principal Author: DCL @@ -331,12 +331,14 @@ main(int argc, char **argv) { cfg_obj_t *defkey = NULL; cfg_obj_t *keys = NULL; cfg_obj_t *key = NULL; + cfg_obj_t *defport = NULL; cfg_obj_t *secretobj = NULL; cfg_obj_t *algorithmobj = NULL; cfg_listelt_t *elt; const char *keyname = NULL; const char *secretstr; const char *algorithm; + isc_boolean_t portset = ISC_FALSE; char secretarray[1024]; char *p; size_t argslen; @@ -373,6 +375,7 @@ main(int argc, char **argv) { progname); exit(1); } + portset = ISC_TRUE; break; case 's': @@ -512,6 +515,26 @@ main(int argc, char **argv) { secret.rend = secret.rstart; secret.rstart = secretarray; + /* + * Find the port to connect to. + */ + if (portset) + ; /* Was set on command line, do nothing. */ + else if (server != NULL) { + DO("get port for server", cfg_map_get(server, "port", + &defport)); + } else if (options != NULL) { + DO("get default port", cfg_map_get(options, "default-port", + &defport)); + } + if (defport != NULL) { + remoteport = cfg_obj_asuint32(defport); + if (remoteport > 65535) { + fprintf(stderr, "%s: port out of range\n", progname); + exit(1); + } + } + isccc_result_register(); have_ipv4 = (isc_net_probeipv4() == ISC_R_SUCCESS); diff --git a/bin/rndc/rndc.conf.5 b/bin/rndc/rndc.conf.5 index 52bbe7a2ec..f2f95e49ab 100644 --- a/bin/rndc/rndc.conf.5 +++ b/bin/rndc/rndc.conf.5 @@ -13,7 +13,7 @@ .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION .\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" $Id: rndc.conf.5,v 1.12 2001/02/07 20:27:40 bwelling Exp $ +.\" $Id: rndc.conf.5,v 1.13 2001/03/28 00:16:09 bwelling Exp $ .Dd Jun 30, 2000 .Dt RDNC.CONF 5 @@ -54,7 +54,7 @@ statement. .Pp The .Dv options -statement contains two clauses. +statement contains three clauses. The .Dv default-server clause @@ -74,10 +74,21 @@ option is provided on the .Xr rndc command line, and no .Dv key -clause is found in a a matching +clause is found in a matching .Dv server statement, this default key will be used to authenticate the server's commands and responses. +The +.Dv default-port clause is followed by the port to connect +to on the remote name server. If no +.Fl p +option is provided on the +.Xr rndc +command line, and no +.Dv port +clause is found in a matching +.Dv server +statement, this default port will be used to connect. .Pp After the keyword .Dv server , @@ -85,11 +96,13 @@ the .Dv server statement is followed by a string which is the hostname or address for a name server. -The statement has a single clause, -.Dv key . +The statement has two possible clauses: +.Dv key +and +.Dv port . The key name must match the name of a .Dv key -statement in the file. +statement in the file. The port number specifies the port to connect to. .Pp The .Dv key @@ -197,18 +210,6 @@ See the sections on the .Dv controls statement in the BIND 9 Administrator Reference Manual for details. -.Sh LIMITATIONS -There is currently no way to specify the port for -.Xr rndc -to use. This will be remedied in future releases by allowing a -.Dv port -clause to the -.Dv server -statement and a -.Dv default-port -clause to the -.Dv options -statement. .Sh SEE ALSO .Xr rndc 8 , .Xr dnssec-keygen 8 , diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 1e171cd10b..13f7ae0a50 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: parser.c,v 1.50 2001/03/26 21:33:07 bwelling Exp $ */ +/* $Id: parser.c,v 1.51 2001/03/28 00:16:05 bwelling Exp $ */ #include @@ -3364,6 +3364,7 @@ static cfg_clausedef_t rndcconf_options_clauses[] = { { "default-server", &cfg_type_astring, 0 }, { "default-key", &cfg_type_astring, 0 }, + { "default-port", &cfg_type_uint32, 0 }, { NULL, NULL, 0 } }; @@ -3381,6 +3382,7 @@ static cfg_type_t cfg_type_rndcconf_options = { static cfg_clausedef_t rndcconf_server_clauses[] = { { "key", &cfg_type_astring, 0 }, + { "port", &cfg_type_uint32, 0 }, { NULL, NULL, 0 } };