523230336909d30111cb060b7eb6fc39d23ad174Tinderbox User * Copyright (C) 2000-2018 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * Principal Author: DCL
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellingtonstatic isc_sockaddr_t serveraddrs[SERVERADDRS];
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrewsstatic isc_boolean_t local4set = ISC_FALSE, local6set = ISC_FALSE;
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellingtonstatic void rndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task);
5b79d154014f87b6c54b1ec2d3912c35b02042a1Mark AndrewsUsage: %s [-b address] [-c config] [-s server] [-p port]\n\
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt [-k key-file ] [-y key] [-r] [-V] command\n\
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafssoncommand is one of the following:\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews addzone zone [class [view]] { zone-options }\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman Add zone to given view. Requires allow-new-zones option.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews delzone [-clean] zone [class [view]]\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman Removes zone from given view.\n\
d6a0e00dc3e047f8470b938878926957070def77Mark Andrews dnstap -reopen\n\
19977879caf8579a5fafb0cf3bf1cb983063796cEvan Hunt Close, truncate and re-open the DNSTAP output file.\n\
d6a0e00dc3e047f8470b938878926957070def77Mark Andrews dnstap -roll count\n\
d6a0e00dc3e047f8470b938878926957070def77Mark Andrews Close, rename and re-open the DNSTAP output file(s).\n\
1479200aa05414b2acf33607dbd1682c16f58c51Evan Hunt dumpdb [-all|-cache|-zones|-adb|-bad|-fail] [view ...]\n\
b326d7e3a3a50eb65dd06db007d2fddc62606bbfMark Andrews Dump cache(s) to the dump file (named_dump.db).\n\
5455f30a7532738d750252c00e649890c694ee30Brian Wellington flush Flushes all of the server's caches.\n\
5455f30a7532738d750252c00e649890c694ee30Brian Wellington flush [view] Flushes the server's cache for a view.\n\
60213f2815a7e6584a2285546d05633fa7b6f5b4Mark Andrews flushname name [view]\n\
c30d291128e099a284fa6272b91b2bd64519a209Mark Andrews Flush the given name from the server's cache(s)\n\
6150d3cb666a58d5e3a15275562c9fc5c5b6b2d8Evan Hunt flushtree name [view]\n\
6150d3cb666a58d5e3a15275562c9fc5c5b6b2d8Evan Hunt Flush all names under the given name from the server's cache(s)\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews freeze Suspend updates to all dynamic zones.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews freeze zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Suspend updates to a dynamic zone.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews halt Stop the server without saving pending updates.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews halt -p Stop the server without saving pending updates reporting\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews process id.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews loadkeys zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Update keys without signing immediately.\n\
ecaed3593cd14f2491d1bd81fc98cb940e12f8bbMark Andrews managed-keys refresh [class [view]]\n\
ecaed3593cd14f2491d1bd81fc98cb940e12f8bbMark Andrews Check trust anchor for RFC 5011 key changes\n\
ecaed3593cd14f2491d1bd81fc98cb940e12f8bbMark Andrews managed-keys status [class [view]]\n\
ecaed3593cd14f2491d1bd81fc98cb940e12f8bbMark Andrews Display RFC 5011 managed keys information\n\
ecaed3593cd14f2491d1bd81fc98cb940e12f8bbMark Andrews managed-keys sync [class [view]]\n\
ecaed3593cd14f2491d1bd81fc98cb940e12f8bbMark Andrews Write RFC 5011 managed keys to disk\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman modzone zone [class [view]] { zone-options }\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman Modify a zone's configuration.\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman Requires allow-new-zones option.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews notify zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Resend NOTIFY messages for the zone.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews notrace Set debugging level to 0.\n\
323bb31d7c54078aa62146b3aa946b755cbfd52bMark Andrews nta -dump\n\
323bb31d7c54078aa62146b3aa946b755cbfd52bMark Andrews List all negative trust anchors.\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt nta [-lifetime duration] [-force] domain [view]\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt Set a negative trust anchor, disabling DNSSEC validation\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt for the given domain.\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt Using -lifetime specifies the duration of the NTA, up\n\
629a0159401a6c0d991a78a6d0b90ee84e83668cEvan Hunt to one week.\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt Using -force prevents the NTA from expiring before its\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt full lifetime, even if the domain can validate sooner.\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt nta -remove domain [view]\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt Remove a negative trust anchor, re-enabling validation\n\
547411428e467f2a2848886eaac0a8b3e136a9abEvan Hunt for the given domain.\n\
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt querylog [ on | off ]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Enable / disable query logging.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews reconfig Reload configuration file and new zones only.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews recursing Dump the queries that are currently recursing (named.recursing)\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews refresh zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Schedule immediate maintenance for a zone.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews reload Reload configuration file and zones.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews reload zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Reload a single zone.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews retransfer zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Retransfer a single zone without checking serial number.\n\
62ec9fd1681ffae7d6b0d54618599ecf650e3100Mark Andrews scan Scan available network interfaces for changes.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews secroots [view ...]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Write security roots to the secroots file.\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman showzone zone [class [view]]\n\
fc39b6a96109b78154ec148d20eaf29e8abc14b6Mukund Sivaraman Print a zone's configuration.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews sign zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Update zone keys, and sign as needed.\n\
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt signing -clear all zone [class [view]]\n\
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt Remove the private records for all keys that have\n\
9c03f13e18c1b0c32f62391a17300378605bbc7bEvan Hunt finished signing the given zone.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews signing -clear <keyid>/<algorithm> zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Remove the private record that indicating the given key\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews has finished signing the given zone.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews signing -list zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews List the private records showing the state of DNSSEC\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews signing in the given zone.\n\
9bd876a683709be588f6fac6781a76fdd57b2f08Mark Andrews signing -nsec3param hash flags iterations salt zone [class [view]]\n\
9bd876a683709be588f6fac6781a76fdd57b2f08Mark Andrews Add NSEC3 chain to zone if already signed.\n\
9bd876a683709be588f6fac6781a76fdd57b2f08Mark Andrews Prime zone with NSEC3 chain if not yet signed.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews signing -nsec3param none zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Remove NSEC3 chains from zone.\n\
fdcfc6bae754ee8f0b43dfd872284a294a8f2fd2Mark Andrews signing -serial <value> zone [class [view]]\n\
fdcfc6bae754ee8f0b43dfd872284a294a8f2fd2Mark Andrews Set the zones's serial to <value>.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews stats Write server statistics to the statistics file.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews status Display status of the server.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews stop Save pending updates to master files and stop the server.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews stop -p Save pending updates to master files and stop the server\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews reporting process id.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews sync [-clean] Dump changes to all dynamic zones to disk, and optionally\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews remove their journal files.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews sync [-clean] zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Dump a single zone's changes to disk, and optionally\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews remove its journal file.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews thaw Enable updates to all dynamic zones and reload them.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews thaw zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Enable updates to a frozen dynamic zone and reload it.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews trace Increment debugging level by one.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews trace level Change the debugging level.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews tsig-delete keyname [view]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Delete a TKEY-negotiated TSIG key.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews tsig-list List all currently active TSIG keys, including both statically\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews configured and TKEY-negotiated keys.\n\
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt validation [ yes | no | status ] [view]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Enable / disable DNSSEC validation.\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews zonestatus zone [class [view]]\n\
d96f74a3cb6212ac9e4a7a0fa8924f850348eae9Mark Andrews Display the current status of a zone.\n\
87983da955bf63128de85d180359bdc418516c3cDavid LawrenceVersion: %s\n",
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellingtonget_addresses(const char *host, in_port_t port) {
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews result = isc_sockaddr_frompath(&serveraddrs[nserveraddrs],
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonrndc_senddone(isc_task_t *task, isc_event_t *event) {
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington isc_socketevent_t *sevent = (isc_socketevent_t *)event;
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington fatal("send failed: %s", isc_result_totext(sevent->result));
f07fe5a1ac9d1345eb7a36a0bc38716a03e25f61Mark Andrews RUNTIME_CHECK(isc_app_shutdown() == ISC_R_SUCCESS);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonrndc_recvdone(isc_task_t *task, isc_event_t *event) {
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "This may indicate that\n"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "* the remote server is using an older version of"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews " the command protocol,\n"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "* this host is not authorized to connect,\n"
287910778c57d4836a52b03b697c2ef342d0eaa9Francis Dupont "* the clocks are not synchronized, or\n"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "* the key is invalid.");
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington fatal("recv failed: %s", isc_result_totext(ccmsg.result));
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington source.rstart = isc_buffer_base(&ccmsg.buffer);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington source.rend = isc_buffer_used(&ccmsg.buffer);
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt isccc_cc_fromwire(&source, &response, algorithm, &secret));
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington data = isccc_alist_lookup(response, "_data");
a2b15b3305acd52179e6f3dc7d073b07fbc40b8eMark Andrews fatal("bad or missing data section in response");
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington result = isccc_cc_lookupstring(data, "err", &errormsg);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington fprintf(stderr, "%s: parsing response failed: %s\n",
e4cd5a1e5d0358abeee7618b02b4592c055d957fBrian Wellington result = isccc_cc_lookupstring(data, "text", &textmsg);
e7c0d42b11358f08e04316d31c67c23261dcdf36Evan Hunt fprintf(failed ? stderr : stdout, "%s\n", textmsg);
e4cd5a1e5d0358abeee7618b02b4592c055d957fBrian Wellington fprintf(stderr, "%s: parsing response failed: %s\n",
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt result = isccc_cc_lookupuint32(data, "result", &eresult);
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt printf("%s %u\n", isc_result_toid(eresult), eresult);
f07fe5a1ac9d1345eb7a36a0bc38716a03e25f61Mark Andrews RUNTIME_CHECK(isc_app_shutdown() == ISC_R_SUCCESS);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrewsrndc_recvnonce(isc_task_t *task, isc_event_t *event) {
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "This may indicate that\n"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "* the remote server is using an older version of"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews " the command protocol,\n"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "* this host is not authorized to connect,\n"
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt "* the clocks are not synchronized,\n"
bcae9a15c1e9c50a6e6433168d5225b1de89d6b9Evan Hunt "* the key signing algorithm is incorrect, or\n"
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews "* the key is invalid.");
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews fatal("recv failed: %s", isc_result_totext(ccmsg.result));
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews source.rstart = isc_buffer_base(&ccmsg.buffer);
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt isccc_cc_fromwire(&source, &response, algorithm, &secret));
a2b15b3305acd52179e6f3dc7d073b07fbc40b8eMark Andrews fatal("bad or missing ctrl section in response");
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews if (isccc_cc_lookupuint32(_ctrl, "_nonce", &nonce) != ISC_R_SUCCESS)
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial,
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews if (isccc_cc_definestring(data, "type", args) == NULL)
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews if (isccc_cc_defineuint32(_ctrl, "_nonce", nonce) == NULL)
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt /* Skip the length field (4 bytes) */
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt isccc_cc_towire(request, &databuf, algorithm, &secret));
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews DO("schedule recv", isccc_ccmsg_readmessage(&ccmsg, task,
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews DO("send message", isc_socket_send(sock, &r, task, rndc_senddone,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonrndc_connected(isc_task_t *task, isc_event_t *event) {
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington isc_socketevent_t *sevent = (isc_socketevent_t *)event;
bcdf37e0ff7d73310b7bf247d755194a5718ba38Mark Andrews isc_sockaddr_format(&serveraddrs[currentaddr], socktext,
bcdf37e0ff7d73310b7bf247d755194a5718ba38Mark Andrews rndc_startconnect(&serveraddrs[currentaddr], task);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington data = isccc_alist_lookup(request, "_data");
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews if (isccc_cc_definestring(data, "type", "null") == NULL)
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt /* Skip the length field (4 bytes) */
e32d354f754a5d7847a0862bcd6302827ea225bfEvan Hunt isccc_cc_towire(request, &databuf, algorithm, &secret));
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington DO("schedule recv", isccc_ccmsg_readmessage(&ccmsg, task,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington DO("send message", isc_socket_send(sock, &r, task, rndc_senddone,
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellingtonrndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task) {
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington isc_sockaddr_format(addr, socktext, sizeof(socktext));
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence notify("using server %s (%s)", servername, socktext);
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews DO("create socket", isc_socket_create(socketmgr, pf, type, &sock));
240e53b13217af266abb3dae8ba103614daf2bf7Mark Andrews DO("bind socket", isc_socket_bind(sock, &local4, 0));
240e53b13217af266abb3dae8ba103614daf2bf7Mark Andrews DO("bind socket", isc_socket_bind(sock, &local6, 0));
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington DO("connect", isc_socket_connect(sock, addr, task, rndc_connected,
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellingtonrndc_start(isc_task_t *task, isc_event_t *event) {
bcdf37e0ff7d73310b7bf247d755194a5718ba38Mark Andrews rndc_startconnect(&serveraddrs[currentaddr], task);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrewsparse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews const cfg_type_t *conftype = &cfg_type_rndcconf;
4144efb39046963989ad002cf88a0c195401100aJeremy Reed } else if (! c_flag && isc_file_exists(admin_keyfile)) {
4144efb39046963989ad002cf88a0c195401100aJeremy Reed fprintf(stderr, "WARNING: key file (%s) exists, but using "
4144efb39046963989ad002cf88a0c195401100aJeremy Reed "default configuration file (%s)\n",
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence DO("create parser", cfg_parser_create(mctx, log, pctxp));
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence * The parser will output its own errors, so DO() is not used.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews result = cfg_parse_file(*pctxp, conffile, conftype, &config);
0a77211c806fa84fd66638b5cccf550c7cd7760dAndreas Gustafsson fatal("could not load rndc configuration");
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews (void)cfg_map_get(config, "options", &options);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews else if (servername == NULL && options != NULL) {
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews (void)cfg_map_get(options, "default-server", &defserverobj);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson (void)cfg_map_get(config, "server", &servers);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews name = cfg_obj_asstring(cfg_map_getname(server));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * Look for the name of the key to use.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews ; /* Was set on command line, do nothing. */
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews DO("get key for server", cfg_map_get(server, "key", &defkey));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews DO("get default key", cfg_map_get(options, "default-key",
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * Get the key's definition.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews DO("get key", cfg_map_get(config, "key", &key));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews DO("get config key list", cfg_map_get(config, "key", &keys));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews if (strcasecmp(cfg_obj_asstring(cfg_map_getname(key)),
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews fatal("no key definition for name %s", keyname);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews (void)cfg_map_get(key, "algorithm", &algorithmobj);
c40906dfad6dd6e3a3e3c94b8c8847bc9bc064e5Mark Andrews if (strcasecmp(algorithmstr, "hmac-sha1") == 0)
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt else if (strcasecmp(algorithmstr, "hmac-sha224") == 0)
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt else if (strcasecmp(algorithmstr, "hmac-sha256") == 0)
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt else if (strcasecmp(algorithmstr, "hmac-sha384") == 0)
4eb998928b9aef0ceda42d7529980d658138698aEvan Hunt else if (strcasecmp(algorithmstr, "hmac-sha512") == 0)
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews secret.rend = (unsigned char *)secretarray + sizeof(secretarray);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews DO("decode base64 secret", isccc_base64_decode(secretstr, &secret));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * Find the port to connect to.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews ; /* Was set on command line, do nothing. */
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson (void)cfg_map_get(options, "default-port", &defport);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews } else if (remoteport == 0)
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews result = cfg_map_get(server, "addresses", &addresses);
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews "too many address: %s: dropped\n",
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews cfg_map_get(server, "source-address", &address);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews cfg_map_get(options, "default-source-address", &address);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews cfg_map_get(server, "source-address-v6", &address);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews cfg_map_get(options, "default-source-address-v6", &address);
bfafdac0616107ff32389532e7040567cd84b8aaBrian Wellington result = isc_file_progname(*argv, program, sizeof(program));
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson fatal("isc_app_start() failed: %s", isc_result_totext(result));
9e804040a29b9c3066c8471b43835f30707039b7Evan Hunt while ((ch = isc_commandline_parse(argc, argv, "b:c:hk:Mmp:qrs:Vy:"))
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews if (inet_pton(AF_INET, isc_commandline_argument,
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews } else if (inet_pton(AF_INET6, isc_commandline_argument,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington remoteport = atoi(isc_commandline_argument);
47c5b8af920a93763c97d9a93ea1fd766961a5b3Evan Hunt /* FALLTHROUGH */
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt DO("create memory context", isc_mem_create(0, 0, &rndc_mctx));
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt DO("create socket manager", isc_socketmgr_create(rndc_mctx, &socketmgr));
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt DO("create task manager", isc_taskmgr_create(rndc_mctx, 1, 0, &taskmgr));
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington DO("create task", isc_task_create(taskmgr, 0, &task));
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt DO("create logging context", isc_log_create(rndc_mctx, &log, &logconfig));
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington DO("setting log tag", isc_log_settag(logconfig, progname));
1d16cf8bb8596c3e4dc1123a5bdf360bf24a272bAutomatic Updater ISC_LOG_TOFILEDESC, ISC_LOG_INFO, &logdest,
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington DO("enabling log channel", isc_log_usechannel(logconfig, "stderr",
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt parse_config(rndc_mctx, log, keyname, &pctx, &config);
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson * Convert argc/argv into a space-delimited command string
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson * similar to what the user might enter in interactive mode
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson * (if that were implemented).
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson for (i = 0; i < argc; i++)
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson for (i = 0; i < argc; i++) {
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews get_addresses(servername, (in_port_t) remoteport);
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt DO("post event", isc_app_onrun(rndc_mctx, task, rndc_start, NULL));
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson fatal("isc_app_run() failed: %s", isc_result_totext(result));
71ca6e64b4d208a090d255eb64c24f945e615ea0Brian Wellington if (connects > 0 || sends > 0 || recvs > 0)