summaryrefslogtreecommitdiffstats
path: root/contrib/bind/bin/named/ns_ctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind/bin/named/ns_ctl.c')
-rw-r--r--contrib/bind/bin/named/ns_ctl.c191
1 files changed, 148 insertions, 43 deletions
diff --git a/contrib/bind/bin/named/ns_ctl.c b/contrib/bind/bin/named/ns_ctl.c
index 1950b07..ee77634 100644
--- a/contrib/bind/bin/named/ns_ctl.c
+++ b/contrib/bind/bin/named/ns_ctl.c
@@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: ns_ctl.c,v 8.39 2000/12/19 23:31:38 marka Exp $";
+static const char rcsid[] = "$Id: ns_ctl.c,v 8.46 2001/12/19 11:53:48 marka Exp $";
#endif /* not lint */
/*
@@ -91,55 +91,56 @@ static void propagate_changes(const control, control);
static void install(control);
static void install_inet(control);
static void install_unix(control);
-static void logger(enum ctl_severity, const char *fmt, ...);
+static void logger(enum ctl_severity, const char *fmt, ...)
+ ISC_FORMAT_PRINTF(2,3);
static void verb_connect(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_getpid(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void getpid_closure(struct ctl_sctx *, struct ctl_sess *,
void *);
static void verb_status(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void status_closure(struct ctl_sctx *, struct ctl_sess *,
void *);
static void verb_stop(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_exec(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_reload(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_reconfig(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_dumpdb(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_stats(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_trace(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void trace_closure(struct ctl_sctx *, struct ctl_sess *,
void *);
static void verb_notrace(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_querylog(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_help(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
static void verb_quit(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *,
- const char *, u_int, void *, void *);
+ const char *, u_int, const void *, void *);
/* Private data. */
@@ -226,7 +227,7 @@ ns_ctl_new_inet(struct in_addr saddr, u_int sport, ip_match_list allow) {
#ifndef NO_SOCKADDR_UN
control
-ns_ctl_new_unix(char *path, mode_t mode, uid_t owner, gid_t group) {
+ns_ctl_new_unix(const char *path, mode_t mode, uid_t owner, gid_t group) {
control new = new_control();
INIT_LINK(new, link);
@@ -525,11 +526,11 @@ install_unix(control ctl) {
if (slash != path)
*slash = '\0';
else {
- freestr(path);
+ (void)freestr(path);
path = savestr("/", 1);
}
} else {
- freestr(path);
+ (void)freestr(path);
path = savestr(".", 1);
}
if (mkdir(path, ctl->var.v_unix.mode) < 0) {
@@ -567,7 +568,7 @@ install_unix(control ctl) {
}
}
#ifdef NEED_SECURE_DIRECTORY
- freestr(path);
+ (void)freestr(path);
#endif
}
#endif
@@ -581,7 +582,8 @@ logger(enum ctl_severity ctlsev, const char *format, ...) {
case ctl_debug: logsev = log_debug(5); break;
case ctl_warning: logsev = log_warning; break;
case ctl_error: logsev = log_error; break;
- default: panic("invalid ctlsev in logger", NULL);
+ default: logsev = 0;
+ panic("invalid ctlsev in logger", NULL);
}
if (!log_ctx_valid)
return;
@@ -593,13 +595,18 @@ logger(enum ctl_severity ctlsev, const char *format, ...) {
static void
verb_connect(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
- const struct sockaddr *sa = (struct sockaddr *)respctx;
+ const struct sockaddr *sa = (const struct sockaddr *)respctx;
control nsctl = (control)uctx;
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+
if (sa->sa_family == AF_INET) {
- const struct sockaddr_in *in = (struct sockaddr_in *)sa;
+ const struct sockaddr_in *in = (const struct sockaddr_in *)sa;
const ip_match_list acl = nsctl->var.v_inet.allow;
if (!ip_address_allowed(acl, in->sin_addr)) {
@@ -615,10 +622,17 @@ verb_connect(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_getpid(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
char *msg = memget(MAX_STR_LEN);
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
if (msg == NULL) {
ctl_response(sess, 503, "(out of memory)", 0,
NULL, NULL, NULL, NULL, 0);
@@ -632,6 +646,9 @@ static void
getpid_closure(struct ctl_sctx *sctx, struct ctl_sess *sess, void *uap) {
char *msg = uap;
+ UNUSED(sctx);
+ UNUSED(sess);
+
memput(msg, MAX_STR_LEN);
}
@@ -656,10 +673,17 @@ struct pvt_status {
static void
verb_status(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
struct pvt_status *pvt = ctl_getcsctx(sess);
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
if (pvt == NULL) {
pvt = memget(sizeof *pvt);
if (pvt == NULL) {
@@ -717,6 +741,9 @@ static void
status_closure(struct ctl_sctx *sctx, struct ctl_sess *sess, void *uap) {
struct pvt_status *pvt = ctl_getcsctx(sess);
+ UNUSED(sctx);
+ UNUSED(uap);
+
memput(pvt, sizeof *pvt);
ctl_setcsctx(sess, NULL);
}
@@ -724,8 +751,15 @@ status_closure(struct ctl_sctx *sctx, struct ctl_sess *sess, void *uap) {
static void
verb_stop(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
ns_need(main_need_exit);
ctl_response(sess, 250, "Shutdown initiated.", 0, NULL, NULL, NULL,
NULL, 0);
@@ -734,10 +768,16 @@ verb_stop(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_exec(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
struct stat sb;
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
if (rest != NULL && *rest != '\0') {
if (stat(rest, &sb) < 0) {
ctl_response(sess, 503, strerror(errno),
@@ -764,14 +804,21 @@ verb_exec(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_reload(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
static const char spaces[] = " \t";
struct zoneinfo *zp;
char *tmp = NULL, *x;
+ const char *cl;
const char *msg;
int class, code, success;
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
/* If there are no args, this is a classic reload of the config. */
if (rest == NULL || *rest == '\0') {
ns_need(main_need_reload);
@@ -787,9 +834,8 @@ verb_reload(struct ctl_sctx *ctl, struct ctl_sess *sess,
*x++ = '\0';
x += strspn(x, spaces);
}
- if (x == NULL || *x == '\0')
- x = "in";
- class = sym_ston(__p_class_syms, x, &success);
+ cl = (x == NULL || *x == '\0') ? "in" : x;
+ class = res_nametoclass(cl, &success);
if (!success) {
code = 507;
msg = "unrecognized class";
@@ -833,14 +879,20 @@ verb_reload(struct ctl_sctx *ctl, struct ctl_sess *sess,
respond:
ctl_response(sess, code, msg, 0, NULL, NULL, NULL, NULL, 0);
if (tmp != NULL)
- freestr(tmp);
+ (void)freestr(tmp);
}
static void
verb_reconfig(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
if (strcmp(rest, "-noexpired") != 0)
ns_need(main_need_reconfig);
else
@@ -852,8 +904,15 @@ verb_reconfig(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_dumpdb(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
ns_need(main_need_dump);
ctl_response(sess, 250, "Database dump initiated.", 0, NULL,
NULL, NULL, NULL, 0);
@@ -862,8 +921,14 @@ verb_dumpdb(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_stats(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
if (rest != NULL && strcmp(rest, "clear") == 0) {
ns_need(main_need_statsdumpandclear);
ctl_response(sess, 250, "Statistics dump and clear initiated.",
@@ -878,22 +943,31 @@ verb_stats(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_trace(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
int i = atoi(rest);
char *msg = memget(MAX_STR_LEN);
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
if (msg == NULL) {
ctl_response(sess, 503, "(out of memory)", 0,
NULL, NULL, NULL, NULL, 0);
return;
}
- if (i > 0)
+ if (isdigit(*(const unsigned char *)rest) && i >= 0)
desired_debug = i;
else
desired_debug++;
ns_need(main_need_debug);
- sprintf(msg, "Debug level: %d", desired_debug);
+ if (desired_debug == 0)
+ sprintf(msg, "Debugging turned off.");
+ else
+ sprintf(msg, "Debug level: %d", desired_debug);
ctl_response(sess, 250, msg, 0, NULL, trace_closure, msg, NULL, 0);
}
@@ -901,14 +975,24 @@ static void
trace_closure(struct ctl_sctx *sctx, struct ctl_sess *sess, void *uap) {
char *msg = uap;
+ UNUSED(sctx);
+ UNUSED(sess);
+
memput(msg, MAX_STR_LEN);
}
static void
verb_notrace(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
desired_debug = 0;
ns_need(main_need_debug);
ctl_response(sess, 250, "Debugging turned off.",
@@ -918,11 +1002,18 @@ verb_notrace(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_querylog(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
static const char on[] = "Query logging is now on.",
off[] = "Query logging is now off.";
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
toggle_qrylog();
ctl_response(sess, 250, qrylog ? on : off,
0, NULL, NULL, NULL, NULL, 0);
@@ -931,16 +1022,30 @@ verb_querylog(struct ctl_sctx *ctl, struct ctl_sess *sess,
static void
verb_help(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
ctl_sendhelp(sess, 214);
}
static void
verb_quit(struct ctl_sctx *ctl, struct ctl_sess *sess,
const struct ctl_verb *verb, const char *rest,
- u_int respflags, void *respctx, void *uctx)
+ u_int respflags, const void *respctx, void *uctx)
{
+ UNUSED(ctl);
+ UNUSED(verb);
+ UNUSED(rest);
+ UNUSED(respflags);
+ UNUSED(respctx);
+ UNUSED(uctx);
+
ctl_response(sess, 221, "End of control session.", CTL_EXIT, NULL,
NULL, NULL, NULL, 0);
}
OpenPOWER on IntegriCloud