static void
shutdown_listener(controllistener_t *listener) {
- controlconnection_t *conn;
- controlconnection_t *next;
+ controlconnection_t *conn = NULL;
+ controlconnection_t *next = NULL;
if (!listener->exiting) {
char socktext[ISC_SOCKADDR_FORMATSIZE];
isc_stdtime_t now;
isc_buffer_t b;
isc_region_t r;
- isc_buffer_t *text;
+ isc_buffer_t *text = NULL;
isc_result_t result;
isc_result_t eresult;
isccc_sexpr_t *_ctrl = NULL;
static isc_result_t
newconnection(controllistener_t *listener, isc_socket_t *sock) {
- controlconnection_t *conn;
+ controlconnection_t *conn = NULL;
isc_interval_t interval;
isc_result_t result;
control_newconn(isc_task_t *task, isc_event_t *event) {
isc_socket_newconnev_t *nevent = (isc_socket_newconnev_t *)event;
controllistener_t *listener = event->ev_arg;
- isc_socket_t *sock;
+ isc_socket_t *sock = NULL;
isc_sockaddr_t peeraddr;
isc_result_t result;
static void
controls_shutdown(named_controls_t *controls) {
- controllistener_t *listener;
- controllistener_t *next;
+ controllistener_t *listener = NULL;
+ controllistener_t *next = NULL;
for (listener = ISC_LIST_HEAD(controls->listeners); listener != NULL;
listener = next)
static isc_result_t
cfgkeylist_find(const cfg_obj_t *keylist, const char *keyname,
const cfg_obj_t **objp) {
- const cfg_listelt_t *element;
- const char *str;
- const cfg_obj_t *obj;
+ const cfg_listelt_t *element = NULL;
+ const char *str = NULL;
+ const cfg_obj_t *obj = NULL;
for (element = cfg_list_first(keylist); element != NULL;
element = cfg_list_next(element))
static void
controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
controlkeylist_t *keyids) {
- const cfg_listelt_t *element;
+ const cfg_listelt_t *element = NULL;
char *newstr = NULL;
- const char *str;
- const cfg_obj_t *obj;
- controlkey_t *key;
+ const char *str = NULL;
+ const cfg_obj_t *obj = NULL;
+ controlkey_t *key = NULL;
for (element = cfg_list_first(keylist); element != NULL;
element = cfg_list_next(element))
static void
register_keys(const cfg_obj_t *control, const cfg_obj_t *keylist,
controlkeylist_t *keyids, isc_mem_t *mctx, const char *socktext) {
- controlkey_t *keyid, *next;
- const cfg_obj_t *keydef;
+ controlkey_t *keyid = NULL, *next = NULL;
+ const cfg_obj_t *keydef = NULL;
char secret[1024];
isc_buffer_t b;
isc_result_t result;
algstr = cfg_obj_asstring(algobj);
secretstr = cfg_obj_asstring(secretobj);
- if (named_config_getkeyalgorithm2(algstr, NULL,
- &algtype, NULL) !=
- ISC_R_SUCCESS)
- {
+ result = named_config_getkeyalgorithm2(algstr, NULL,
+ &algtype, NULL);
+ if (result != ISC_R_SUCCESS) {
cfg_obj_log(control, named_g_lctx,
ISC_LOG_WARNING,
"unsupported algorithm '%s' in "
}
}
-#define CHECK(x) \
- do { \
- result = (x); \
- if (result != ISC_R_SUCCESS) \
- goto cleanup; \
+#define CHECK(x) \
+ do { \
+ result = (x); \
+ if (result != ISC_R_SUCCESS) { \
+ goto cleanup; \
+ } \
} while (0)
static isc_result_t
algstr = cfg_obj_asstring(algobj);
secretstr = cfg_obj_asstring(secretobj);
- if (named_config_getkeyalgorithm2(algstr, NULL, &algtype, NULL) !=
- ISC_R_SUCCESS)
- {
+ result = named_config_getkeyalgorithm2(algstr, NULL, &algtype, NULL);
+ if (result != ISC_R_SUCCESS) {
cfg_obj_log(key, named_g_lctx, ISC_LOG_WARNING,
"unsupported algorithm '%s' in "
"key '%s' for use with command "
const cfg_obj_t *control, const cfg_obj_t *config,
isc_sockaddr_t *addr, cfg_aclconfctx_t *aclconfctx,
const char *socktext, isc_sockettype_t type) {
- controllistener_t *listener;
- const cfg_obj_t *allow;
+ controllistener_t *listener = NULL;
+ const cfg_obj_t *allow = NULL;
const cfg_obj_t *global_keylist = NULL;
const cfg_obj_t *control_keylist = NULL;
dns_acl_t *new_acl = NULL;
}
if (control != NULL) {
- const cfg_obj_t *readonly;
+ const cfg_obj_t *readonly = NULL;
readonly = cfg_tuple_get(control, "read-only");
if (!cfg_obj_isvoid(readonly)) {
isc_sockaddr_t *addr, cfg_aclconfctx_t *aclconfctx,
const char *socktext, isc_sockettype_t type) {
isc_mem_t *mctx = cp->server->mctx;
- controllistener_t *listener;
- const cfg_obj_t *allow;
+ controllistener_t *listener = NULL;
+ const cfg_obj_t *allow = NULL;
const cfg_obj_t *global_keylist = NULL;
const cfg_obj_t *control_keylist = NULL;
dns_acl_t *new_acl = NULL;
isc_result_t result = ISC_R_SUCCESS;
listener = isc_mem_get(mctx, sizeof(*listener));
-
- listener->mctx = NULL;
+ *listener = (controllistener_t){ .controls = cp,
+ .task = cp->server->task,
+ .address = *addr,
+ .type = type };
isc_mem_attach(mctx, &listener->mctx);
- listener->controls = cp;
- listener->task = cp->server->task;
- listener->address = *addr;
- listener->sock = NULL;
- listener->listening = false;
- listener->exiting = false;
- listener->acl = NULL;
- listener->type = type;
- listener->perm = 0;
- listener->owner = 0;
- listener->group = 0;
- listener->readonly = false;
ISC_LINK_INIT(listener, link);
ISC_LIST_INIT(listener->keys);
ISC_LIST_INIT(listener->connections);
/*
- * Make the acl.
+ * Make the ACL.
*/
if (control != NULL && type == isc_sockettype_tcp) {
allow = cfg_tuple_get(control, "allow");
result = dns_acl_any(mctx, &new_acl);
}
- if ((result == ISC_R_SUCCESS) && (control != NULL)) {
- const cfg_obj_t *readonly;
+ if (result == ISC_R_SUCCESS && control != NULL) {
+ const cfg_obj_t *readonly = NULL;
readonly = cfg_tuple_get(control, "read-only");
if (!cfg_obj_isvoid(readonly)) {
result = isc_socket_permunix(&listener->address, listener->perm,
listener->owner, listener->group);
}
+
if (result == ISC_R_SUCCESS) {
result = control_listen(listener);
}
isc_result_t
named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
cfg_aclconfctx_t *aclconfctx) {
- controllistener_t *listener;
+ controllistener_t *listener = NULL;
controllistenerlist_t new_listeners;
const cfg_obj_t *controlslist = NULL;
const cfg_listelt_t *element, *element2;
for (element = cfg_list_first(controlslist); element != NULL;
element = cfg_list_next(element))
{
- const cfg_obj_t *controls;
+ const cfg_obj_t *controls = NULL;
const cfg_obj_t *inetcontrols = NULL;
controls = cfg_listelt_value(element);
element2 != NULL;
element2 = cfg_list_next(element2))
{
- const cfg_obj_t *control;
- const cfg_obj_t *obj;
+ const cfg_obj_t *control = NULL;
+ const cfg_obj_t *obj = NULL;
isc_sockaddr_t addr;
/*
for (element = cfg_list_first(controlslist); element != NULL;
element = cfg_list_next(element))
{
- const cfg_obj_t *controls;
+ const cfg_obj_t *controls = NULL;
const cfg_obj_t *unixcontrols = NULL;
controls = cfg_listelt_value(element);
element2 != NULL;
element2 = cfg_list_next(element2))
{
- const cfg_obj_t *control;
- const cfg_obj_t *path;
+ const cfg_obj_t *control = NULL;
+ const cfg_obj_t *path = NULL;
isc_sockaddr_t addr;
isc_result_t result;
#define SERVERADDRS 10
-const char *progname;
+const char *progname = NULL;
bool verbose;
-static const char *admin_conffile;
-static const char *admin_keyfile;
+static const char *admin_conffile = NULL;
+static const char *admin_keyfile = NULL;
static const char *version = PACKAGE_VERSION;
static const char *servername = NULL;
static isc_sockaddr_t serveraddrs[SERVERADDRS];
static int currentaddr = 0;
static unsigned int remoteport = 0;
static isc_socketmgr_t *socketmgr = NULL;
-static isc_buffer_t *databuf;
+static isc_buffer_t *databuf = NULL;
static isccc_ccmsg_t ccmsg;
static uint32_t algorithm;
static isccc_region_t secret;
static bool failed = false;
static bool c_flag = false;
-static isc_mem_t *rndc_mctx;
+static isc_mem_t *rndc_mctx = NULL;
static atomic_uint_fast32_t sends = ATOMIC_VAR_INIT(0);
static atomic_uint_fast32_t recvs = ATOMIC_VAR_INIT(0);
static atomic_uint_fast32_t connects = ATOMIC_VAR_INIT(0);
-static char *command;
-static char *args;
+static char *command = NULL;
+static char *args = NULL;
static char program[256];
static isc_socket_t *sock = NULL;
static uint32_t serial;
Close, rename and re-open the DNSTAP output file(s).\n\
dumpdb [-all|-cache|-zones|-adb|-bad|-fail] [view ...]\n\
Dump cache(s) to the dump file (named_dump.db).\n\
- flush Flushes all of the server's caches.\n\
+ flush Flushes all of the server's caches.\n\
flush [view] Flushes the server's cache for a view.\n\
flushname name [view]\n\
Flush the given name from the server's cache(s)\n\
if (servers != NULL) {
for (elt = cfg_list_first(servers); elt != NULL;
elt = cfg_list_next(elt)) {
- const char *name;
+ const char *name = NULL;
server = cfg_listelt_value(elt);
name = cfg_obj_asstring(
cfg_map_getname(server));
DO("get config key list", cfg_map_get(config, "key", &keys));
for (elt = cfg_list_first(keys); elt != NULL;
elt = cfg_list_next(elt)) {
+ const char *name = NULL;
+
key = cfg_listelt_value(elt);
- if (strcasecmp(cfg_obj_asstring(cfg_map_getname(key)),
- keyname) == 0) {
+ name = cfg_obj_asstring(cfg_map_getname(key));
+ if (strcasecmp(name, keyname) == 0) {
break;
}
}
DO("create task manager",
isc_taskmgr_create(rndc_mctx, 1, 0, NULL, &taskmgr));
DO("create task", isc_task_create(taskmgr, 0, &task));
-
isc_log_create(rndc_mctx, &log, &logconfig);
isc_log_setcontext(log);
isc_log_settag(logconfig, progname);
static void
recv_length(isc_task_t *task, isc_event_t *ev_in) {
isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
- isc_event_t *dev;
+ isc_event_t *dev = NULL;
isccc_ccmsg_t *ccmsg = ev_in->ev_arg;
isc_region_t region;
isc_result_t result;
static void
recv_message(isc_task_t *task, isc_event_t *ev_in) {
isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
- isc_event_t *dev;
+ isc_event_t *dev = NULL;
isccc_ccmsg_t *ccmsg = ev_in->ev_arg;
- (void)task;
+ UNUSED(task);
INSIST(VALID_CCMSG(ccmsg));
REQUIRE(sock != NULL);
REQUIRE(ccmsg != NULL);
- ccmsg->magic = CCMSG_MAGIC;
- ccmsg->size = 0;
- ccmsg->buffer.base = NULL;
- ccmsg->buffer.length = 0;
- ccmsg->maxsize = 4294967295U; /* Largest message possible. */
- ccmsg->mctx = mctx;
- ccmsg->sock = sock;
- ccmsg->task = NULL; /* None yet. */
- ccmsg->result = ISC_R_UNEXPECTED; /* None yet. */
- /*
- * Should probably initialize the
- *event here, but it can wait.
- */
+ *ccmsg = (isccc_ccmsg_t){
+ .magic = CCMSG_MAGIC,
+ .maxsize = 0xffffffffU, /* Largest message possible. */
+ .mctx = mctx,
+ .sock = sock,
+ .result = ISC_R_UNEXPECTED /* None yet. */
+ };
+
+ /*
+ * Should probably initialize the event here, but it can wait.
+ */
}
void
isc_socket_cancel(ccmsg->sock, NULL, ISC_SOCKCANCEL_RECV);
}
-#if 0
-void
-isccc_ccmsg_freebuffer(isccc_ccmsg_t*ccmsg) {
- REQUIRE(VALID_CCMSG(ccmsg));
-
- if (ccmsg->buffer.base == NULL) {
- return;
- }
-
- isc_mem_put(ccmsg->mctx,ccmsg->buffer.base,ccmsg->buffer.length);
- ccmsg->buffer.base = NULL;
- ccmsg->buffer.length = 0;
-}
-#endif /* if 0 */
-
void
isccc_ccmsg_invalidate(isccc_ccmsg_t *ccmsg) {
REQUIRE(VALID_CCMSG(ccmsg));