Commit Diff
Diff:
014fb34f426e6d4ffd714d1632ec0b6f5bbd8ec3
dd86938369f3460df8e62a9d89b1897479c4a652
Commit:
dd86938369f3460df8e62a9d89b1897479c4a652
Tree:
9a770958007a6a0e5688d18a5a24b4b9d8cc82f2
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Sat Feb 16 17:27:06 2013 UTC
Message:
* add a debug and verbose flag (-d and -v) * document these along with -r which is recursive mode, which is still broken * add a dolog() function which replaces syslog and printf. In debug mode messages will be printed in the foreground and with verbose option show the parsing logic of the configfile. * replace all syslog() with dolog() tested in debug mode on OpenBSD/amd64
blob - 583dc8b60ff0e8f781c56cfd250dda7f56b0e53b
blob + 2d760d071086f987b19d32cbce8fa20a680fd0c2
--- axfr.c
+++ axfr.c
@@ -47,9 +47,10 @@ extern int compress_label(u_char *, int, int);
extern u_int16_t create_anyreply(struct sreply *sreply, char *reply, int rlen, int offset, int soa);
extern struct question * build_fake_question(char *, int, u_int16_t);
extern int free_question(struct question *);
+extern void dolog(int, char *, ...);
+extern int debug, verbose;
-
SLIST_HEAD(listhead, axfrentry) axfrhead;
struct axfrentry {
@@ -62,7 +63,7 @@ struct axfrentry {
} *an1, *an2, *anp;
-static const char rcsid[] = "$Id: axfr.c,v 1.4 2013/02/16 11:47:30 pjp Exp $";
+static const char rcsid[] = "$Id: axfr.c,v 1.5 2013/02/16 17:27:06 pjp Exp $";
/*
* INIT_AXFR - initialize the axfr singly linked list
@@ -238,7 +239,7 @@ axfrloop(int *afd, int sockcount, char **ident, DB *db
sel = select(maxso + 1, &rset, NULL, NULL, NULL);
if (sel < 0) {
- syslog(LOG_INFO, "select: %m");
+ dolog(LOG_INFO, "select: %s\n", strerror(errno));
continue;
}
@@ -248,7 +249,7 @@ axfrloop(int *afd, int sockcount, char **ident, DB *db
so = accept(afd[i], (struct sockaddr*)&from, &fromlen);
if (so < 0) {
- syslog(LOG_INFO, "afd accept: %m");
+ dolog(LOG_INFO, "afd accept: %s\n", strerror(errno));
continue;
}
@@ -270,18 +271,18 @@ axfrloop(int *afd, int sockcount, char **ident, DB *db
axfr_acl = find_axfr((struct sockaddr_storage *)sin, AF_INET);
} else {
- syslog(LOG_INFO, "afd accept unknown family %d, close", from.ss_family);
+ dolog(LOG_INFO, "afd accept unknown family %d, close\n", from.ss_family);
close(so);
continue;
}
if (! axfr_acl) {
- syslog(LOG_INFO, "connection from %s was not in our axfr acl, drop", address);
+ dolog(LOG_INFO, "connection from %s was not in our axfr acl, drop\n", address);
close(so);
continue;
}
- syslog(LOG_INFO, "AXFR connection from %s on interface \"%s\"", address, ident[i]);
+ dolog(LOG_INFO, "AXFR connection from %s on interface \"%s\"\n", address, ident[i]);
switch (pid = fork()) {
case 0:
@@ -361,12 +362,12 @@ axfr_connection(int so, char *address, int is_ipv6, DB
dh = (struct dns_header *)(p + 2);
if ((ntohs(dh->query) & DNS_REPLY)) {
- syslog(LOG_INFO, "AXFR dns packet is not a question, drop");
+ dolog(LOG_INFO, "AXFR dns packet is not a question, drop\n");
goto drop;
}
if (ntohs(dh->question) != 1) {
- syslog(LOG_INFO, "AXFR dns packet does not have a question count of 1 (RFC 5936, page 9), reply fmterror");
+ dolog(LOG_INFO, "AXFR dns packet does not have a question count of 1 (RFC 5936, page 9), reply fmterror\n");
build_reply(&sreply, so, (p + 2), dnslen, NULL, NULL, 0, NULL, NULL, 0xff, 1, 0, NULL);
@@ -375,12 +376,12 @@ axfr_connection(int so, char *address, int is_ipv6, DB
}
if ((question = build_question((p + 2), dnslen)) == NULL) {
- syslog(LOG_INFO, "AXFR malformed question, drop");
+ dolog(LOG_INFO, "AXFR malformed question, drop\n");
goto drop;
}
if (ntohs(question->hdr->qclass) != DNS_CLASS_IN) {
- syslog(LOG_INFO, "AXFR question wasn't for class DNS_CLASS_IN, drop");
+ dolog(LOG_INFO, "AXFR question wasn't for class DNS_CLASS_IN, drop\n");
goto drop;
}
@@ -390,7 +391,7 @@ axfr_connection(int so, char *address, int is_ipv6, DB
case DNS_TYPE_SOA:
break;
default:
- syslog(LOG_INFO, "AXFR question wasn't for valid types (ixfr, axfr, soa) with requested type %d, drop", ntohs(question->hdr->qtype));
+ dolog(LOG_INFO, "AXFR question wasn't for valid types (ixfr, axfr, soa) with requested type %d, drop\n", ntohs(question->hdr->qtype));
goto drop;
}
@@ -399,7 +400,7 @@ axfr_connection(int so, char *address, int is_ipv6, DB
reply = calloc(1, 65538);
if (reply == NULL) {
- syslog(LOG_INFO, "internal error: %m");
+ dolog(LOG_INFO, "internal error: %s\n", strerror(errno));
goto drop;
}
@@ -424,12 +425,12 @@ axfr_connection(int so, char *address, int is_ipv6, DB
(void)get_soa(db, question, &sdomain, 0);
build_reply(&sreply, so, (p + 2), dnslen, question, NULL, 0, &sdomain, NULL, 0xff, 1, 0, NULL);
reply_nxdomain(&sreply);
- syslog(LOG_INFO, "AXFR request for zone %s, no db entry, nxdomain -> drop", question->converted_name);
+ dolog(LOG_INFO, "AXFR request for zone %s, no db entry, nxdomain -> drop\n", question->converted_name);
goto drop;
}
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "AXFR btree db is damaged, drop");
+ dolog(LOG_INFO, "AXFR btree db is damaged, drop\n");
goto drop;
}
@@ -445,12 +446,12 @@ axfr_connection(int so, char *address, int is_ipv6, DB
build_reply(&sreply, so, (p + 2), dnslen, question, NULL, 0, &sdomain, NULL, 0xff, 1, 0, NULL);
reply_nxdomain(&sreply);
- syslog(LOG_INFO, "AXFR request for zone %s, which has no SOA for the zone, nxdomain -> drop", question->converted_name);
+ dolog(LOG_INFO, "AXFR request for zone %s, which has no SOA for the zone, nxdomain -> drop\n", question->converted_name);
goto drop;
}
if (ntohs(question->hdr->qtype) == DNS_TYPE_SOA) {
- syslog(LOG_INFO, "TCP SOA request for zone \"%s\", replying...", question->converted_name);
+ dolog(LOG_INFO, "TCP SOA request for zone \"%s\", replying...\n", question->converted_name);
outlen = 0;
outlen = build_header(db, (reply + 2), (p + 2), question, 1);
outlen = build_soa(db, (reply + 2), outlen, &soa, question);
@@ -472,7 +473,7 @@ axfr_connection(int so, char *address, int is_ipv6, DB
continue;
}
- syslog(LOG_INFO, "%s request for zone \"%s\", replying...",
+ dolog(LOG_INFO, "%s request for zone \"%s\", replying...\n",
(ntohs(question->hdr->qtype) == DNS_TYPE_AXFR ? "AXFR"
: "IXFR"), question->converted_name);
@@ -481,7 +482,7 @@ axfr_connection(int so, char *address, int is_ipv6, DB
rrcount = 1;
if (db->cursor(db, NULL, &cursor, 0) != 0) {
- syslog(LOG_INFO, "db->cursor: %m");
+ dolog(LOG_INFO, "db->cursor: %s\n", strerror(errno));
goto drop;
}
@@ -490,13 +491,13 @@ axfr_connection(int so, char *address, int is_ipv6, DB
if (cursor->c_get(cursor, &key, &data, DB_FIRST) != 0) {
- syslog(LOG_INFO, "cursor->c_get: %m");
+ dolog(LOG_INFO, "cursor->c_get: %s\n", strerror(errno));
goto drop;
}
do {
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "AXFR btree db is damaged (%d), drop", __LINE__);
+ dolog(LOG_INFO, "AXFR btree db is damaged (%d), drop\n", __LINE__);
goto drop;
}
@@ -530,7 +531,7 @@ axfr_connection(int so, char *address, int is_ipv6, DB
}
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "AXFR btree db is damaged (%d), drop", __LINE__);
+ dolog(LOG_INFO, "AXFR btree db is damaged (%d), drop\n", __LINE__);
goto drop;
}
@@ -807,7 +808,7 @@ checklabel(DB *db, struct domain *sd, struct domain *s
}
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "AXFR btree db is damaged (%d), drop", __LINE__);
+ dolog(LOG_INFO, "AXFR btree db is damaged (%d), drop\n", __LINE__);
return (0);
}
blob - c9914fedb77f417c21a0ddb3b78440e85a05e2c1
blob + d2458cb3d128246f16b5d22c04cc98b1bac58c73
--- log.c
+++ log.c
@@ -34,8 +34,46 @@
#include <openssl/hmac.h>
extern struct logging logging;
+extern int debug;
+extern int verbose;
+
int remotelog(int fd, char *fmt, ...);
void receivelog(char *buf, int len);
+void dolog(int pri, char *fmt, ...);
+
+
+/*
+ * dolog() - is a wrapper to syslog and printf depending on debug flag
+ *
+ */
+
+void
+dolog(int pri, char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ /*
+ * if the message is a debug message and verbose (-v) is set
+ * then print it, otherwise
+ */
+
+ if (pri == LOG_DEBUG) {
+ if (debug && verbose)
+ vprintf(fmt, ap);
+ else
+ vsyslog(pri, fmt, ap);
+ } else {
+ if (debug)
+ vprintf(fmt, ap);
+ else
+ vsyslog(pri, fmt, ap);
+ }
+
+ va_end(ap);
+
+}
/*
* remotelog() - is like syslog() only the first argument is a filedescriptor
blob - 7f7f7a7487911996d0fe9ef12d2ea7ef804c55ec
blob + 22569780a08a13059f56d987bd7ca417e18ed6c8
--- main.c
+++ main.c
@@ -63,6 +63,7 @@ extern void init_recurse(void);
extern int remotelog(int, char *, ...);
extern void receivelog(char *buf, int len);
extern void axfrloop(int *afd, int sockcount, char **ident, DB *db);
+extern void dolog(int, char *, ...);
char * dns_label(char *, int *);
int compress_label(u_char *, u_int16_t, int);
@@ -109,6 +110,7 @@ struct typetable {
extern char *__progname;
extern struct logging logging;
extern int axfrport;
+
static int lflag = 0;
static int rflag = 0;
static u_int16_t port = 53;
@@ -119,6 +121,8 @@ static int msig;
static char *database;
static char mydatabase[512];
+int debug = 0, verbose = 0;
+
/* singly linked list for tcp operations */
SLIST_HEAD(listhead, tcps) tcpshead;
@@ -138,7 +142,7 @@ struct tcps {
} *tn1, *tn2, *tnp;
-static const char rcsid[] = "$Id: main.c,v 1.76 2013/02/16 11:47:30 pjp Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.77 2013/02/16 17:27:06 pjp Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -195,7 +199,7 @@ main(int argc, char *argv[])
av = argv;
- while ((ch = getopt(argc, argv, "b:c:f:i:ln:p:r")) != -1) {
+ while ((ch = getopt(argc, argv, "b:c:df:i:ln:p:rv")) != -1) {
switch (ch) {
case 'b':
bflag = 1;
@@ -212,6 +216,9 @@ main(int argc, char *argv[])
cachesize = strtonum(optarg, 1, 0xffffffff, NULL);
#endif
break;
+ case 'd':
+ debug = 1;
+ break;
case 'f':
conffile = optarg;
break;
@@ -235,8 +242,11 @@ main(int argc, char *argv[])
case 'r':
rflag = 1;
break;
+ case 'v':
+ verbose++;
+ break;
default:
- fprintf(stderr, "usage: wildcarddnsd [-i interface] [-b bindaddress] [-f configfile] [-p portnumber] [-r]\n");
+ fprintf(stderr, "usage: wildcarddnsd [-i interface] [-b bindaddress] [-f configfile] [-p portnumber] [-drv]\n");
exit (1);
}
}
@@ -246,21 +256,21 @@ main(int argc, char *argv[])
exit(1);
}
-#ifndef DEBUG
/*
* calling daemon before a sleuth of configurations ala rwhod.c
*/
- daemon(0,0);
-#endif
+
+ if (! debug)
+ daemon(0,0);
openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
- syslog(LOG_INFO, "starting up");
+ dolog(LOG_INFO, "starting up\n");
/* cfg struct */
cfg = calloc(1, sizeof(struct cfg));
if (cfg == NULL) {
- syslog(LOG_ERR, "calloc: %m");
+ dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
exit(1);
}
@@ -274,7 +284,7 @@ main(int argc, char *argv[])
MAP_ANON, -1, 0);
if (ptr == MAP_FAILED) {
- syslog(LOG_ERR, "failed to setup mmap segment, exit");
+ dolog(LOG_ERR, "failed to setup mmap segment, exit\n");
exit(1);
}
@@ -285,21 +295,21 @@ main(int argc, char *argv[])
#if DB_VERSION_MAJOR == 4
if ((ret = db_env_create(&dbenv, 0)) != 0) {
- syslog(LOG_INFO, "db_env_create: %s", db_strerror(ret));
+ dolog(LOG_INFO, "db_env_create: %s\n", db_strerror(ret));
slave_shutdown();
exit(1);
}
key = ftok("/usr/local/sbin/wildcarddnsd", 1);
if (key == (key_t)-1) {
- syslog(LOG_INFO, "ftok failed, does /usr/local/sbin/wildcarddnsd exist?");
+ dolog(LOG_INFO, "ftok failed, does /usr/local/sbin/wildcarddnsd exist?\n");
slave_shutdown();
exit(1);
}
if ((ret = dbenv->set_shm_key(dbenv, key)) != 0) {
- syslog(LOG_INFO, "dbenv->set_shm_key failed");
+ dolog(LOG_INFO, "dbenv->set_shm_key failed\n");
slave_shutdown();
exit(1);
}
@@ -308,7 +318,7 @@ main(int argc, char *argv[])
if (cachesize) {
if ((ret = dbenv->set_cachesize(dbenv, 0, cachesize, 0)) != 0) {
- syslog(LOG_INFO, "dbenv->set_cachesize: %s",
+ dolog(LOG_INFO, "dbenv->set_cachesize: %s\n",
db_strerror(ret));
slave_shutdown();
exit(1);
@@ -320,13 +330,13 @@ main(int argc, char *argv[])
if ((ret = dbenv->open(dbenv, MYDB_PATH, DB_CREATE | \
DB_INIT_LOCK | DB_INIT_MPOOL | DB_SYSTEM_MEM, \
S_IRUSR | S_IWUSR)) != 0) {
- syslog(LOG_INFO, "dbenv->open failed: %s", db_strerror(ret));
+ dolog(LOG_INFO, "dbenv->open failed: %s\n", db_strerror(ret));
slave_shutdown();
exit(1);
}
if (db_create((DB **)&db, (DB_ENV *)dbenv, 0) != 0) {
- syslog(LOG_INFO, "db_create: %m");
+ dolog(LOG_INFO, "db_create: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -342,20 +352,20 @@ main(int argc, char *argv[])
fd = open(database, O_WRONLY | O_CREAT, 0600);
if (fd < 0) {
- syslog(LOG_INFO, "open: %m");
+ dolog(LOG_INFO, "open: %s\n", strerror(errno));
}
close(fd);
#if DB_VERSION_MINOR > 0
if (db->open(db, NULL, database, NULL, DB_BTREE, DB_CREATE, 0600) != 0) {
- syslog(LOG_INFO, "db->open: %m");
+ dolog(LOG_INFO, "db->open: %s\n", strerror(errno));
db->close(db, DB_NOSYNC);
slave_shutdown();
exit(1);
}
#else
if (db->open(db, database, NULL, DB_BTREE, DB_CREATE, 0600) != 0) {
- syslog(LOG_INFO, "db->open: %m");
+ dolog(LOG_INFO, "db->open: %s\n", strerror(errno));
db->close(db, DB_NOSYNC);
slave_shutdown();
exit(1);
@@ -368,7 +378,7 @@ main(int argc, char *argv[])
db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL);
if (db == NULL) {
- syslog(LOG_INFO, "dbopen: %m");
+ dolog(LOG_INFO, "dbopen: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -379,7 +389,7 @@ main(int argc, char *argv[])
pid = fork();
switch (pid) {
case -1:
- syslog(LOG_ERR, "fork(): %m");
+ dolog(LOG_ERR, "fork(): %s\n", strerror(errno));
exit(1);
case 0:
break;
@@ -395,20 +405,20 @@ main(int argc, char *argv[])
init_recurse();
if (parse_file(db, conffile) < 0) {
- syslog(LOG_INFO, "parsing config file failed");
+ dolog(LOG_INFO, "parsing config file failed\n");
slave_shutdown();
exit(1);
}
pw = getpwnam(DEFAULT_PRIVILEGE);
if (pw == NULL) {
- syslog(LOG_INFO, "getpwnam: %m");
+ dolog(LOG_INFO, "getpwnam: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bcount > DEFAULT_SOCKET) {
- syslog(LOG_INFO, "not enough sockets available\n");
+ dolog(LOG_INFO, "not enough sockets available\n");
slave_shutdown();
exit(1);
}
@@ -430,7 +440,7 @@ main(int argc, char *argv[])
snprintf(buf, sizeof(buf) - 1, "%u", port);
if ((gai_error = getaddrinfo(bind_list[i], buf, &hints, &res0)) != 0) {
- syslog(LOG_INFO, "getaddrinfo: %s\n", gai_strerror(gai_error));
+ dolog(LOG_INFO, "getaddrinfo: %s\n", gai_strerror(gai_error));
slave_shutdown();
exit (1);
}
@@ -438,13 +448,13 @@ main(int argc, char *argv[])
res = res0;
if ((udp[i] = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
- syslog(LOG_INFO, "socket: %m");
+ dolog(LOG_INFO, "socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(udp[i], res->ai_addr, res->ai_addrlen) < 0) {
- syslog(LOG_INFO, "bind: %m");
+ dolog(LOG_INFO, "bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -457,14 +467,14 @@ main(int argc, char *argv[])
if (setsockopt(udp[i], IPPROTO_IP, IP_RECVTTL,
&on, sizeof(on)) < 0) {
#endif
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
}
} else if (res->ai_family == AF_INET6) {
/* RFC 3542 page 30 */
on = 1;
if (setsockopt(udp[i], IPPROTO_IPV6,
IPV6_RECVHOPLIMIT, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
}
}
@@ -478,7 +488,7 @@ main(int argc, char *argv[])
snprintf(buf, sizeof(buf) - 1, "%u", port);
if ((gai_error = getaddrinfo(bind_list[i], buf, &hints, &res0)) != 0) {
- syslog(LOG_INFO, "getaddrinfo: %s\n", gai_strerror(gai_error));
+ dolog(LOG_INFO, "getaddrinfo: %s\n", gai_strerror(gai_error));
slave_shutdown();
exit (1);
}
@@ -486,17 +496,17 @@ main(int argc, char *argv[])
res = res0;
if ((tcp[i] = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
- syslog(LOG_INFO, "tcp socket: %m");
+ dolog(LOG_INFO, "tcp socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setsockopt(tcp[i], SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(tcp[i], res->ai_addr, res->ai_addrlen) < 0) {
- syslog(LOG_INFO, "tcp bind: %m");
+ dolog(LOG_INFO, "tcp bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -510,7 +520,7 @@ main(int argc, char *argv[])
snprintf(buf, sizeof(buf) - 1, "%u", axfrport);
if ((gai_error = getaddrinfo(bind_list[i], buf, &hints, &res0)) != 0) {
- syslog(LOG_INFO, "getaddrinfo: %s\n", gai_strerror(gai_error));
+ dolog(LOG_INFO, "getaddrinfo: %s\n", gai_strerror(gai_error));
slave_shutdown();
exit (1);
}
@@ -518,28 +528,28 @@ main(int argc, char *argv[])
res = res0;
if ((afd[i] = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) {
- syslog(LOG_INFO, "tcp socket: %m");
+ dolog(LOG_INFO, "tcp socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setsockopt(afd[i], SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(afd[i], res->ai_addr, res->ai_addrlen) < 0) {
- syslog(LOG_INFO, "tcp bind: %m");
+ dolog(LOG_INFO, "tcp bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if ((uafd[i] = socket(res->ai_family, SOCK_DGRAM, res->ai_protocol)) < 0) {
- syslog(LOG_INFO, "axfr udp socket: %m");
+ dolog(LOG_INFO, "axfr udp socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(uafd[i], res->ai_addr, res->ai_addrlen) < 0) {
- syslog(LOG_INFO, "axfr udp socket bind: %m");
+ dolog(LOG_INFO, "axfr udp socket bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -549,7 +559,7 @@ main(int argc, char *argv[])
} else {
if (getifaddrs(&ifap) < 0) {
- syslog(LOG_INFO, "getifaddrs");
+ dolog(LOG_INFO, "getifaddrs\n");
slave_shutdown();
exit(1);
}
@@ -573,7 +583,7 @@ main(int argc, char *argv[])
}
if ((pifap->ifa_flags & IFF_UP) != IFF_UP) {
- syslog(LOG_INFO, "skipping interface %s\n", pifap->ifa_name);
+ dolog(LOG_INFO, "skipping interface %s\n", pifap->ifa_name);
i--;
continue;
}
@@ -594,22 +604,20 @@ main(int argc, char *argv[])
salen = sizeof(struct sockaddr_in6);
} else {
-#ifdef DEBUG
- syslog(LOG_INFO, "unknown address family %d\n", pifap->ifa_addr->sa_family);
-#endif
+ dolog(LOG_DEBUG, "unknown address family %d\n", pifap->ifa_addr->sa_family);
i--;
continue;
}
if ((udp[i] = socket(pifap->ifa_addr->sa_family, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- syslog(LOG_INFO, "socket: %m");
+ dolog(LOG_INFO, "socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(udp[i], (struct sockaddr *)pifap->ifa_addr, salen) < 0) {
- syslog(LOG_INFO, "bind: %m");
+ dolog(LOG_INFO, "bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -622,14 +630,14 @@ main(int argc, char *argv[])
if (setsockopt(udp[i], IPPROTO_IP, IP_RECVTTL,
&on, sizeof(on)) < 0) {
#endif
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
}
} else if (pifap->ifa_addr->sa_family == AF_INET6) {
/* RFC 3542 page 30 */
on = 1;
if (setsockopt(udp[i], IPPROTO_IPV6,
IPV6_RECVHOPLIMIT, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
}
}
@@ -637,18 +645,18 @@ main(int argc, char *argv[])
ident[i] = pifap->ifa_name;
if ((tcp[i] = socket(pifap->ifa_addr->sa_family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- syslog(LOG_INFO, "tcp socket: %m");
+ dolog(LOG_INFO, "tcp socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setsockopt(tcp[i], SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(tcp[i], (struct sockaddr *)pifap->ifa_addr, salen) < 0) {
- syslog(LOG_INFO, "tcp bind: %m");
+ dolog(LOG_INFO, "tcp bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -657,12 +665,12 @@ main(int argc, char *argv[])
/* axfr socket */
if (axfrport) {
if ((afd[i] = socket(pifap->ifa_addr->sa_family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- syslog(LOG_INFO, "tcp socket: %m");
+ dolog(LOG_INFO, "tcp socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setsockopt(afd[i], SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "setsockopt: %m");
+ dolog(LOG_INFO, "setsockopt: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -670,17 +678,17 @@ main(int argc, char *argv[])
((struct sockaddr_in *)pifap->ifa_addr)->sin_port = htons(axfrport);
if (bind(afd[i], (struct sockaddr *)pifap->ifa_addr, salen) < 0) {
- syslog(LOG_INFO, "tcp bind: %m");
+ dolog(LOG_INFO, "tcp bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if ((uafd[i] = socket(pifap->ifa_addr->sa_family, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- syslog(LOG_INFO, "axfr udp socket: %m");
+ dolog(LOG_INFO, "axfr udp socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (bind(uafd[i], (struct sockaddr *)pifap->ifa_addr, salen) < 0) {
- syslog(LOG_INFO, "udp axfr bind: %m");
+ dolog(LOG_INFO, "udp axfr bind: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -689,7 +697,7 @@ main(int argc, char *argv[])
} /* AF_INET */
if (i >= DEFAULT_SOCKET) {
- syslog(LOG_INFO, "not enough sockets available\n");
+ dolog(LOG_INFO, "not enough sockets available\n");
slave_shutdown();
exit(1);
}
@@ -697,19 +705,19 @@ main(int argc, char *argv[])
if (rflag == 1) {
if ((raw[0] = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
- syslog(LOG_INFO, "raw socket: %m");
+ dolog(LOG_INFO, "raw socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setsockopt(raw[0], IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)) < 0) {
- syslog(LOG_INFO, "raw setsockopt: %m");
+ dolog(LOG_INFO, "raw setsockopt: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if ((raw[1] = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP)) < 0) {
- syslog(LOG_INFO, "raw socket[1]: %m");
+ dolog(LOG_INFO, "raw socket[1]: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -723,7 +731,7 @@ main(int argc, char *argv[])
case AF_INET:
lfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (lfd < 0) {
- syslog(LOG_INFO, "logging socket: %m");
+ dolog(LOG_INFO, "logging socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -733,7 +741,7 @@ main(int argc, char *argv[])
case AF_INET6:
lfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (lfd < 0) {
- syslog(LOG_INFO, "logging socket: %m");
+ dolog(LOG_INFO, "logging socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -748,14 +756,14 @@ main(int argc, char *argv[])
sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in))
) < 0) {
- syslog(LOG_INFO, "binding log socket: %m");
+ dolog(LOG_INFO, "binding log socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
#ifndef __linux__
if (shutdown(lfd, SHUT_WR) < 0) {
- syslog(LOG_INFO, "shutdown log socket: %m");
+ dolog(LOG_INFO, "shutdown log socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -766,13 +774,13 @@ main(int argc, char *argv[])
((logging.loghost2.ss_family == AF_INET6) ?
sizeof(struct sockaddr_in6) :
sizeof(struct sockaddr_in))) < 0) {
- syslog(LOG_INFO, "connecting log socket: %m");
+ dolog(LOG_INFO, "connecting log socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (shutdown(lfd, SHUT_RD) < 0) {
- syslog(LOG_INFO, "shutdown log socket: %m");
+ dolog(LOG_INFO, "shutdown log socket: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -781,21 +789,18 @@ main(int argc, char *argv[])
} /* if logging.bind */
-#ifndef DEBUG
/* chroot to the drop priv user home directory */
if (chroot(pw->pw_dir) < 0) {
- syslog(LOG_INFO, "chroot: %m");
+ dolog(LOG_INFO, "chroot: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (chdir("/") < 0) {
- syslog(LOG_INFO, "chdir: %m");
+ dolog(LOG_INFO, "chdir: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
-
-#endif
/*
* add signals
@@ -818,32 +823,32 @@ main(int argc, char *argv[])
/* set groups */
if (setgroups(1, &pw->pw_gid) < 0) {
- syslog(LOG_INFO, "setgroups: %m");
+ dolog(LOG_INFO, "setgroups: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
#if defined __OpenBSD__ || defined __FreeBSD__
if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) < 0) {
- syslog(LOG_INFO, "setresgid: %m");
+ dolog(LOG_INFO, "setresgid: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) {
- syslog(LOG_INFO, "setresuid: %m");
+ dolog(LOG_INFO, "setresuid: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
#else
if (setgid(pw->pw_gid) < 0) {
- syslog(LOG_INFO, "setgid: %m");
+ dolog(LOG_INFO, "setgid: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
if (setuid(pw->pw_uid) < 0) {
- syslog(LOG_INFO, "setuid: %m");
+ dolog(LOG_INFO, "setuid: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -910,14 +915,14 @@ main(int argc, char *argv[])
*/
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, (int *)&sp) < 0) {
- syslog(LOG_INFO, "socketpair: %m");
+ dolog(LOG_INFO, "socketpair: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
switch (pid = fork()) {
case -1:
- syslog(LOG_INFO, "fork: %m");
+ dolog(LOG_INFO, "fork: %s\n", strerror(errno));
slave_shutdown();
exit(1);
@@ -970,14 +975,14 @@ main(int argc, char *argv[])
*/
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, (int *)&sp) < 0) {
- syslog(LOG_INFO, "socketpair: %m");
+ dolog(LOG_INFO, "socketpair: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
switch (pid = fork()) {
case -1:
- syslog(LOG_INFO, "fork: %m");
+ dolog(LOG_INFO, "fork: %s\n", strerror(errno));
slave_shutdown();
exit(1);
@@ -1056,7 +1061,7 @@ build_question(char *buf, int len)
*/
if (end_name == NULL) {
- syslog(LOG_INFO, "query name is not null terminated");
+ dolog(LOG_INFO, "query name is not null terminated\n");
return NULL;
}
@@ -1074,15 +1079,15 @@ build_question(char *buf, int len)
* also illegal.
*/
if (labellen == 0) {
- syslog(LOG_INFO, "illegal label len (0)");
+ dolog(LOG_INFO, "illegal label len (0)\n");
return NULL;
}
if (labellen > DNS_MAXLABEL) {
- syslog(LOG_INFO, "illegal label len (> 63)");
+ dolog(LOG_INFO, "illegal label len (> 63)\n");
return NULL;
}
if (labellen > (end_name - &buf[i])) {
- syslog(LOG_INFO, "label len extends beyond name");
+ dolog(LOG_INFO, "label len extends beyond name\n");
return NULL;
}
@@ -1091,45 +1096,45 @@ build_question(char *buf, int len)
}
if (&buf[i] != end_name || i >= len) {
- syslog(LOG_INFO, "query name is maliciously malformed");
+ dolog(LOG_INFO, "query name is maliciously malformed\n");
return NULL;
}
if (i > DNS_MAXNAME) {
- syslog(LOG_INFO, "query name is too long (%u)", i);
+ dolog(LOG_INFO, "query name is too long (%u)\n", i);
return NULL;
}
/* check if there is space for qtype and qclass */
if (len < ((end_name - &buf[0]) + (2 * sizeof(u_int16_t)))) {
- syslog(LOG_INFO, "question rr is truncated");
+ dolog(LOG_INFO, "question rr is truncated\n");
return NULL;
}
q = (void *)calloc(1, sizeof(struct question));
if (q == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
return NULL;
}
q->hdr = (void *)calloc(1, sizeof(struct dns_question_hdr));
if (q->hdr == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
free(q);
return NULL;
}
q->hdr->namelen = (end_name - &buf[sizeof(struct dns_header)]) + 1; /* XXX */
q->hdr->name = (void *) calloc(1, q->hdr->namelen);
if (q->hdr->name == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
free(q->hdr);
free(q);
return NULL;
}
q->converted_name = (void *)calloc(1, namelen + num_label + 2);
if (q->converted_name == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
free(q->hdr->name);
free(q->hdr);
free(q);
@@ -1156,7 +1161,7 @@ build_question(char *buf, int len)
int c0;
if ((buf[i] & 0xc0) == 0xc0) {
- syslog(LOG_INFO, "question has compressed name, drop");
+ dolog(LOG_INFO, "question has compressed name, drop\n");
free_question(q);
return NULL; /* XXX should say error */
}
@@ -1288,9 +1293,7 @@ dns_label(char *name, int *returnlen)
p++;
}
-#ifdef DEBUG
- printf("converting name= %s\n", name);
-#endif
+ dolog(LOG_DEBUG, "converting name= %s\n", name);
return dnslabel;
}
@@ -1608,7 +1611,7 @@ lookup_zone(DB *db, struct question *question, struct
} else {
/* we have a match check if the type has an answer, if not we leave */
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "btree db is damaged, drop");
+ dolog(LOG_INFO, "btree db is damaged, drop\n");
*lzerrno = ERR_DROP;
return -1;
}
@@ -1642,7 +1645,7 @@ lookup_zone(DB *db, struct question *question, struct
*/
if (! (sd->flags & DOMAIN_STATIC_ZONE)) {
- syslog(LOG_INFO, "non-static zone %s passed to recurse process\n", sd->zonename);
+ dolog(LOG_INFO, "non-static zone %s passed to recurse process\n", sd->zonename);
*lzerrno = ERR_NOERROR;
return (-1);
}
@@ -1776,13 +1779,13 @@ lookup_zone(DB *db, struct question *question, struct
#else
if (db->get(db, &key, &data, 0) != 0) {
#endif
- syslog(LOG_INFO, "don't have wildcard answer");
+ dolog(LOG_INFO, "don't have wildcard answer\n");
*lzerrno = ERR_NXDOMAIN;
return -1;
}
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "btree db is damaged, drop");
+ dolog(LOG_INFO, "btree db is damaged, drop\n");
*lzerrno = ERR_DROP;
return -1;
}
@@ -1912,20 +1915,20 @@ build_fake_question(char *name, int namelen, u_int16_t
q = (void *)calloc(1, sizeof(struct question));
if (q == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
return NULL;
}
q->hdr = (void *)calloc(1, sizeof(struct dns_question_hdr));
if (q->hdr == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
free(q);
return NULL;
}
q->hdr->namelen = namelen;
q->hdr->name = (void *) calloc(1, q->hdr->namelen);
if (q->hdr->name == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
free(q->hdr);
free(q);
return NULL;
@@ -1990,7 +1993,7 @@ get_soa(DB *db, struct question *question, struct doma
}
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "btree db is damaged, drop");
+ dolog(LOG_INFO, "btree db is damaged, drop\n");
return -1;
}
@@ -2177,7 +2180,7 @@ mainloop(struct cfg *cfg)
sel = select(maxso + 1, &rset, NULL, NULL, &tv);
if (sel < 0) {
- syslog(LOG_INFO, "select: %m");
+ dolog(LOG_INFO, "select: %s\n", strerror(errno));
continue;
}
@@ -2202,7 +2205,7 @@ mainloop(struct cfg *cfg)
so = accept(cfg->tcp[i], (struct sockaddr*)from, &fromlen);
if (so < 0) {
- syslog(LOG_INFO, "tcp accept: %m");
+ dolog(LOG_INFO, "tcp accept: %s\n", strerror(errno));
continue;
}
@@ -2223,7 +2226,7 @@ mainloop(struct cfg *cfg)
wildcard = find_wildcard((struct sockaddr_storage *)sin, AF_INET);
aregion = find_region((struct sockaddr_storage *)sin, AF_INET);
} else {
- syslog(LOG_INFO, "TCP packet received on descriptor %u interface \"%s\" had weird address family (%u), drop", so, cfg->ident[i], from->sa_family);
+ dolog(LOG_INFO, "TCP packet received on descriptor %u interface \"%s\" had weird address family (%u), drop\n", so, cfg->ident[i], from->sa_family);
close(so);
continue;
}
@@ -2233,11 +2236,11 @@ mainloop(struct cfg *cfg)
*/
if ((flag = fcntl(so, F_GETFL)) < 0) {
- syslog(LOG_INFO, "fcntl: %m");
+ dolog(LOG_INFO, "fcntl: %s\n", strerror(errno));
}
flag |= O_NONBLOCK;
if (fcntl(so, F_SETFL, flag) < 0) {
- syslog(LOG_INFO, "fcntl 2: %m");
+ dolog(LOG_INFO, "fcntl 2: %s\n", strerror(errno));
}
@@ -2245,14 +2248,14 @@ mainloop(struct cfg *cfg)
tn1 = malloc(sizeof(struct tcps));
if (tn1 == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
close(so);
continue;
}
tn1->input = (char *)malloc(0xffff + 2);
if (tn1->input == NULL) {
- syslog(LOG_INFO, "tcp malloc 2: %m");
+ dolog(LOG_INFO, "tcp malloc 2: %s\n", strerror(errno));
close(so);
continue;
}
@@ -2321,7 +2324,7 @@ mainloop(struct cfg *cfg)
/* if UDP packet check length for minimum / maximum */
if (len > DNS_MAXUDP || len < sizeof(struct dns_header)){
- syslog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" illegal dns packet length from %s, drop", tnp->so, tnp->ident, tnp->address);
+ dolog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" illegal dns packet length from %s, drop\n", tnp->so, tnp->ident, tnp->address);
goto drop;
}
@@ -2329,7 +2332,7 @@ mainloop(struct cfg *cfg)
/* check if we're a question or reply, drop replies */
if ((ntohs(dh->query) & DNS_REPLY)) {
- syslog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" dns header from %s is not a question, drop", tnp->so, tnp->ident, tnp->address);
+ dolog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" dns header from %s is not a question, drop\n", tnp->so, tnp->ident, tnp->address);
goto drop;
}
@@ -2338,7 +2341,7 @@ mainloop(struct cfg *cfg)
*/
if (ntohs(dh->question) != 1) {
- syslog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" header from %s has no question, drop", tnp->so, tnp->ident, tnp->address);
+ dolog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" header from %s has no question, drop\n", tnp->so, tnp->ident, tnp->address);
/* format error */
build_reply( &sreply, tnp->so, pbuf, len, NULL,
@@ -2346,13 +2349,13 @@ mainloop(struct cfg *cfg)
istcp, tnp->wildcard, NULL);
reply_fmterror(&sreply);
- syslog(LOG_INFO, "TCP question on descriptor %d interface \"%s\" from %s, did not have question of 1 replying format error", tnp->so, tnp->ident, tnp->address);
+ dolog(LOG_INFO, "TCP question on descriptor %d interface \"%s\" from %s, did not have question of 1 replying format error\n", tnp->so, tnp->ident, tnp->address);
goto drop;
}
if ((question = build_question(pbuf, len)) == NULL) {
- syslog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" malformed question from %s, drop", tnp->so, tnp->ident, tnp->address);
+ dolog(LOG_INFO, "TCP packet on descriptor %u interface \"%s\" malformed question from %s, drop\n", tnp->so, tnp->ident, tnp->address);
goto drop;
}
@@ -2363,7 +2366,7 @@ mainloop(struct cfg *cfg)
switch (lzerrno) {
default:
- syslog(LOG_INFO, "invalid lzerrno! dropping");
+ dolog(LOG_INFO, "invalid lzerrno! dropping\n");
/* FALLTHROUGH */
case ERR_DROP:
snprintf(replystring, DNS_MAXNAME, "DROP");
@@ -2421,7 +2424,7 @@ tcpnxdomain:
case DNS_TYPE_CNAME:
fakequestion = build_fake_question(sd0.cname, sd0.cnamelen, question->hdr->qtype);
if (fakequestion == NULL) {
- syslog(LOG_INFO, "fakequestion failed");
+ dolog(LOG_INFO, "fakequestion failed\n");
break;
}
@@ -2622,7 +2625,7 @@ tcpnxdomain:
tcpout:
if (lflag)
- syslog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=TCP, region=%d) for \"%s\" type=%s class=%u, answering \"%s\"", tnp->so, tnp->ident, tnp->address, tnp->region, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), replystring);
+ dolog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=TCP, region=%d) for \"%s\" type=%s class=%u, answering \"%s\"\n", tnp->so, tnp->ident, tnp->address, tnp->region, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), replystring);
if (fakequestion != NULL) {
@@ -2665,7 +2668,7 @@ axfrentry:
len = recvmsg(so, &msgh, 0);
if (len < 0) {
- syslog(LOG_INFO, "recvmsg: on descriptor %u interface \"%s\" %m", so, cfg->ident[i]);
+ dolog(LOG_INFO, "recvmsg: on descriptor %u interface \"%s\" %s\n", so, cfg->ident[i], strerror(errno));
continue;
}
@@ -2701,7 +2704,7 @@ axfrentry:
if (cmsg->cmsg_len !=
CMSG_LEN(sizeof(int))) {
- syslog(LOG_INFO, "cmsg->cmsg_len == %d", cmsg->cmsg_len);
+ dolog(LOG_INFO, "cmsg->cmsg_len == %d\n", cmsg->cmsg_len);
continue;
}
@@ -2712,7 +2715,7 @@ axfrentry:
if (rflag) {
if (getsockname(so, (struct sockaddr*)&sto, &namelen) < 0) {
- syslog(LOG_INFO, "getsockname failed: %m");
+ dolog(LOG_INFO, "getsockname failed: %s\n", strerror(errno));
}
memset(&rh, 0, sizeof(rh));
@@ -2743,13 +2746,13 @@ axfrentry:
recurseheader(&rh, IPPROTO_UDP, (struct sockaddr_storage*)sin, &sto, AF_INET);
}
} else {
- syslog(LOG_INFO, "packet received on descriptor %u interface \"%s\" had weird address family (%u), drop", so, cfg->ident[i], from->sa_family);
+ dolog(LOG_INFO, "packet received on descriptor %u interface \"%s\" had weird address family (%u), drop\n", so, cfg->ident[i], from->sa_family);
goto drop;
}
/* if UDP packet check length for minimum / maximum */
if (len > DNS_MAXUDP || len < sizeof(struct dns_header)){
- syslog(LOG_INFO, "on descriptor %u interface \"%s\" illegal dns packet length from %s, drop", so, cfg->ident[i], address);
+ dolog(LOG_INFO, "on descriptor %u interface \"%s\" illegal dns packet length from %s, drop\n", so, cfg->ident[i], address);
goto drop;
}
@@ -2757,7 +2760,7 @@ axfrentry:
/* check if we're a question or reply, drop replies */
if ((ntohs(dh->query) & DNS_REPLY)) {
- syslog(LOG_INFO, "on descriptor %u interface \"%s\" dns header from %s is not a question, drop", so, cfg->ident[i], address);
+ dolog(LOG_INFO, "on descriptor %u interface \"%s\" dns header from %s is not a question, drop\n", so, cfg->ident[i], address);
goto drop;
}
@@ -2766,12 +2769,12 @@ axfrentry:
*/
if (ntohs(dh->question) != 1) {
- syslog(LOG_INFO, "on descriptor %u interface \"%s\" header from %s has no question, drop", so, cfg->ident[i], address);
+ dolog(LOG_INFO, "on descriptor %u interface \"%s\" header from %s has no question, drop\n", so, cfg->ident[i], address);
/* format error */
build_reply(&sreply, so, buf, len, NULL, from, fromlen, NULL, NULL, aregion, istcp, wildcard, NULL);
reply_fmterror(&sreply);
- syslog(LOG_INFO, "question on descriptor %d interface \"%s\" from %s, did not have question of 1 replying format error", so, cfg->ident[i], address);
+ dolog(LOG_INFO, "question on descriptor %d interface \"%s\" from %s, did not have question of 1 replying format error\n", so, cfg->ident[i], address);
goto drop;
}
@@ -2781,7 +2784,7 @@ axfrentry:
}
if ((question = build_question(buf, len)) == NULL) {
- syslog(LOG_INFO, "on descriptor %u interface \"%s\" malformed question from %s, drop", so, cfg->ident[i], address);
+ dolog(LOG_INFO, "on descriptor %u interface \"%s\" malformed question from %s, drop\n", so, cfg->ident[i], address);
goto drop;
}
@@ -2791,7 +2794,7 @@ axfrentry:
if ((type0 = lookup_zone(cfg->db, question, &sd0, &lzerrno, (char *)&replystring, wildcard)) < 0) {
switch (lzerrno) {
default:
- syslog(LOG_INFO, "invalid lzerrno! dropping");
+ dolog(LOG_INFO, "invalid lzerrno! dropping\n");
/* FALLTHROUGH */
case ERR_DROP:
snprintf(replystring, DNS_MAXNAME, "DROP");
@@ -2803,7 +2806,7 @@ axfrentry:
if (rflag && recursion) {
snprintf(replystring, DNS_MAXNAME, "RECURSE");
if (send(sp, (char *)&rh, sizeof(rh), 0) < 0) {
- syslog(LOG_INFO, "send sp: %m");
+ dolog(LOG_INFO, "send sp: %s\n", strerror(errno));
}
goto udpout;
@@ -2836,7 +2839,7 @@ udpnxdomain:
if (rflag && recursion) {
snprintf(replystring, DNS_MAXNAME, "RECURSE");
if (send(sp, (char *)&rh, sizeof(rh), 0) < 0) {
- syslog(LOG_INFO, "send sp: %m");
+ dolog(LOG_INFO, "send sp: %s\n", strerror(errno));
}
goto udpout;
@@ -2863,7 +2866,7 @@ udpnxdomain:
case DNS_TYPE_CNAME:
fakequestion = build_fake_question(sd0.cname, sd0.cnamelen, question->hdr->qtype);
if (fakequestion == NULL) {
- syslog(LOG_INFO, "fakequestion failed");
+ dolog(LOG_INFO, "fakequestion failed\n");
break;
}
@@ -3054,7 +3057,7 @@ udpnxdomain:
udpout:
if (lflag) {
- syslog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=%u, region=%d) for \"%s\" type=%s class=%u, answering \"%s\"", so, cfg->ident[i], address, received_ttl, aregion, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), replystring);
+ dolog(LOG_INFO, "request on descriptor %u interface \"%s\" from %s (ttl=%u, region=%d) for \"%s\" type=%s class=%u, answering \"%s\"\n", so, cfg->ident[i], address, received_ttl, aregion, question->converted_name, get_dns_type(ntohs(question->hdr->qtype)), ntohs(question->hdr->qclass), replystring);
}
@@ -3076,7 +3079,7 @@ udpnxdomain:
logfromlen = sizeof(struct sockaddr_storage);
len = recvfrom(lfd, buf, sizeof(buf), 0, (struct sockaddr *)&logfrom, &logfromlen);
if (len < 0) {
- syslog(LOG_INFO, "recvfrom: logging %m");
+ dolog(LOG_INFO, "recvfrom: logging %s\n", strerror(errno));
} else
receivelog(buf, len);
}
@@ -3185,7 +3188,7 @@ setup_master(DB *db, DB_ENV *dbenv, int port, char **a
fd = open(PIDFILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd < 0) {
- syslog(LOG_ERR, "couldn't install pid file, exiting...\n");
+ dolog(LOG_ERR, "couldn't install pid file, exiting...\n");
pid = getpgrp();
killpg(pid, SIGTERM);
exit(1);
@@ -3206,23 +3209,23 @@ setup_master(DB *db, DB_ENV *dbenv, int port, char **a
sleep(1);
if (*ptr) {
- syslog(LOG_INFO, "pid %u died, killing wildcarddnsd", *ptr);
+ dolog(LOG_INFO, "pid %u died, killing wildcarddnsd\n", *ptr);
master_shutdown(SIGTERM);
}
if (mshutdown) {
- syslog(LOG_INFO, "shutting down on signal %d", msig);
+ dolog(LOG_INFO, "shutting down on signal %d\n", msig);
unlink(PIDFILE);
db->close(db, 0);
if (db_create((DB **)&destroy, (DB_ENV *)dbenv, 0) != 0) {
- syslog(LOG_INFO, "db_create: %m");
+ dolog(LOG_INFO, "db_create: %s\n", strerror(errno));
}
ret = destroy->remove(destroy, database, NULL, 0);
if (ret != 0) {
- syslog(LOG_INFO, "db->remove: %s", db_strerror(ret));
+ dolog(LOG_INFO, "db->remove: %s\n", db_strerror(ret));
}
dbenv->close(dbenv, 0);
@@ -3240,28 +3243,28 @@ setup_master(DB *db, DB_ENV *dbenv, int port, char **a
pid = getpgrp();
killpg(pid, SIGTERM);
if (munmap(ptr, sizeof(int)) < 0) {
- syslog(LOG_ERR, "munmap: %m");
+ dolog(LOG_ERR, "munmap: %s\n", strerror(errno));
}
unlink(PIDFILE);
db->close(db, 0);
if (db_create((DB **)&destroy, (DB_ENV *)dbenv, 0) != 0) {
- syslog(LOG_INFO, "db_create: %m");
+ dolog(LOG_INFO, "db_create: %s\n", strerror(errno));
}
ret = destroy->remove(destroy, database, NULL, 0);
if (ret != 0) {
- syslog(LOG_INFO, "db->remove: %s", db_strerror(ret));
+ dolog(LOG_INFO, "db->remove: %s\n", db_strerror(ret));
}
dbenv->close(dbenv, 0);
- syslog(LOG_INFO, "restarting on SIGHUP");
+ dolog(LOG_INFO, "restarting on SIGHUP\n");
closelog();
if (execvp("/usr/local/sbin/wildcarddnsd", av) < 0) {
- syslog(LOG_ERR, "execvp: %m");
+ dolog(LOG_ERR, "execvp: %s\n", strerror(errno));
}
/* NOTREACHED */
exit(1);
@@ -3305,7 +3308,7 @@ void
slave_signal(int sig)
{
slave_shutdown();
- syslog(LOG_INFO, "shutting down on signal");
+ dolog(LOG_INFO, "shutting down on signal\n");
exit(1);
}
blob - 2bda33e1d8dec75ca5ad6908bfff2a56bef5c591
blob + f7beb4766aecd757954f6721f2063c85b43f6b22
--- parse.c
+++ parse.c
@@ -37,6 +37,7 @@ extern int insert_wildcard(char *address, char *prefix
extern int insert_recurse(char *, char *);
extern int insert_axfr(char *, char *);
extern void slave_shutdown(void);
+extern void dolog(int, char *, ...);
static int parse_file0(char *filename, DB *db, FILE *f);
@@ -94,11 +95,12 @@ struct cmd_lookup {
#define WILDCARDVERSION 5
+extern int debug, verbose;
static u_int32_t config = 0;
struct logging logging;
int axfrport = 0;
-static const char rcsid[] = "$Id: parse.c,v 1.35 2013/02/16 11:47:30 pjp Exp $";
+static const char rcsid[] = "$Id: parse.c,v 1.36 2013/02/16 17:27:06 pjp Exp $";
/*
* PARSE_FILE - parse the configfile XXX rewrite me in yacc :(
@@ -124,14 +126,14 @@ parse_file(DB *db, char *file)
fd = open(file, O_RDONLY, 0);
if (fd < 0) {
- syslog(LOG_INFO, "open: %m");
+ dolog(LOG_INFO, "open: %s\n", strerror(errno));
return -1;
}
memset((char *)&sb, 0, sizeof(struct stat));
if (fstat(fd, &sb) < 0) {
- syslog(LOG_INFO, "fstat: %m");
+ dolog(LOG_INFO, "fstat: %s\n", strerror(errno));
return -1;
}
@@ -139,14 +141,14 @@ parse_file(DB *db, char *file)
dir = opendir("/dev/");
if (dir == NULL) {
- syslog(LOG_INFO, "opendir: %m");
+ dolog(LOG_INFO, "opendir: %s\n", strerror(errno));
return -1;
}
while ((dp = readdir(dir)) != NULL) {
snprintf(buf, sizeof(buf) - 1, "/dev/%s", dp->d_name);
if (stat(buf, &sb0) < 0) {
- syslog(LOG_INFO, "stat: %m");
+ dolog(LOG_INFO, "stat: %s\n", strerror(errno));
}
if (sb.st_dev == sb0.st_rdev)
@@ -158,12 +160,12 @@ parse_file(DB *db, char *file)
if (sb.st_dev != sb0.st_rdev)
snprintf(buf, sizeof(buf) - 1, "%ld", (long)sb.st_dev);
- syslog(LOG_INFO,
- "opening configfile \"%s\", device: %s, inode: %ld, ctime: %ld",
+ dolog(LOG_INFO,
+ "opening configfile \"%s\", device: %s, inode: %ld, ctime: %ld\n",
file, buf, (long)sb.st_ino, (long)sb.st_ctime);
if ((f = fdopen(fd, "r")) == NULL) {
- syslog(LOG_INFO, "fdopen: %m");
+ dolog(LOG_INFO, "fdopen: %s\n", strerror(errno));
return -1;
}
@@ -233,15 +235,14 @@ parse_file0(char *filename, DB *db, FILE *f)
}
if (endline == NULL) {
- syslog(LOG_INFO, "%s: line too long line %d", filename, line);
+ dolog(LOG_INFO, "%s: line too long line %d\n", filename, line);
return -1;
}
/* are we a comment? skip rest of line */
if (*start == '#' || *start == ';') {
-#ifdef DEBUG
- printf("hash mark skipping line %d\n", line);
-#endif
+ if (debug)
+ dolog(LOG_DEBUG, "hash mark skipping line %d\n", line);
goto loop;
}
@@ -254,7 +255,7 @@ parse_file0(char *filename, DB *db, FILE *f)
if (*start == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (33) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return (-1);
}
@@ -267,7 +268,7 @@ parse_file0(char *filename, DB *db, FILE *f)
break;
case CMD_TYPE_AXFRPORT:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
@@ -276,11 +277,11 @@ parse_file0(char *filename, DB *db, FILE *f)
break;
case CMD_TYPE_ZONE:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
if (strchr(starttoken, '{') == NULL) {
- syslog(LOG_INFO, "%s: must have opening brace ('{') in zone entry on line %d", filename, line);
+ dolog(LOG_INFO, "%s: must have opening brace ('{') in zone entry on line %d", filename, line);
return (-1);
}
@@ -289,7 +290,7 @@ parse_file0(char *filename, DB *db, FILE *f)
goto loop;
case CMD_TYPE_INCLUDE:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
confstatus |= CONFIG_INCLUDE;
@@ -297,11 +298,11 @@ parse_file0(char *filename, DB *db, FILE *f)
break;
case CMD_TYPE_REGION:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
if (strchr(starttoken, '{') == NULL) {
- syslog(LOG_INFO, "%s: must have opening brace ('{') in region entry on line %d", filename, line);
+ dolog(LOG_INFO, "%s: must have opening brace ('{') in region entry on line %d\n", filename, line);
return (-1);
}
config |= CONFIG_REGION;
@@ -311,11 +312,11 @@ parse_file0(char *filename, DB *db, FILE *f)
goto loop;
case CMD_TYPE_WILDCARDONLYFOR:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
if (strchr(starttoken, '{') == NULL) {
- syslog(LOG_INFO, "%s: must have opening brace ('{') in wildcard-only-for entry on line %d", filename, line);
+ dolog(LOG_INFO, "%s: must have opening brace ('{') in wildcard-only-for entry on line %d\n", filename, line);
return (-1);
}
config |= CONFIG_WILDCARDONLYFOR;
@@ -325,11 +326,11 @@ parse_file0(char *filename, DB *db, FILE *f)
goto loop;
case CMD_TYPE_RECURSEFOR:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
if (strchr(starttoken, '{') == NULL) {
- syslog(LOG_INFO, "%s: must have opening brace ('{') in recurse-for entry on line %d", filename, line);
+ dolog(LOG_INFO, "%s: must have opening brace ('{') in recurse-for entry on line %d\n", filename, line);
return (-1);
}
config |= CONFIG_RECURSEFOR;
@@ -339,11 +340,11 @@ parse_file0(char *filename, DB *db, FILE *f)
goto loop;
case CMD_TYPE_AXFRFOR:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
if (strchr(starttoken, '{') == NULL) {
- syslog(LOG_INFO, "%s: must have opening brace ('{') in axfr-for entry on line %d", filename, line);
+ dolog(LOG_INFO, "%s: must have opening brace ('{') in axfr-for entry on line %d\n", filename, line);
return (-1);
}
config |= CONFIG_AXFRFOR;
@@ -353,11 +354,11 @@ parse_file0(char *filename, DB *db, FILE *f)
goto loop;
case CMD_TYPE_LOGGING:
if ((config & CONFIG_VERSION) != CONFIG_VERSION) {
- syslog(LOG_INFO, "%s: must have version at top of config\n", filename);
+ dolog(LOG_INFO, "%s: must have version at top of config\n", filename);
return (-1);
}
if (strchr(starttoken, '{') == NULL) {
- syslog(LOG_INFO, "%s: must have opening brace ('{') in recurse-for entry on line %d", filename, line);
+ dolog(LOG_INFO, "%s: must have opening brace ('{') in recurse-for entry on line %d\n", filename, line);
return (-1);
}
config |= CONFIG_LOGGING;
@@ -376,7 +377,7 @@ parse_file0(char *filename, DB *db, FILE *f)
} /* for()*/
if (CMD_lookup[i].name == NULL) {
- syslog(LOG_INFO, "%s: unknown command, line %d", filename, line);
+ dolog(LOG_INFO, "%s: unknown command, line %d\n", filename, line);
return (-1);
}
@@ -397,13 +398,13 @@ parse_file0(char *filename, DB *db, FILE *f)
if (p >= endline || *p != ',') {
if (*starttoken == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (1) malformed line %d",filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n",filename, __LINE__, line);
return -1;
}
tokenlen = (p - starttoken);
if (tokenlen > (DNS_MAXNAME - 2)) {
- syslog(LOG_INFO, "%s: domain name is too long, on line %d", filename, line);
+ dolog(LOG_INFO, "%s: domain name is too long, on line %d\n", filename, line);
return -1;
}
@@ -436,7 +437,7 @@ parse_file0(char *filename, DB *db, FILE *f)
if (tokenlen == 1 && domainname[0] == '*') {
converted_name = (char *)malloc(1);
if (converted_name == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -445,7 +446,7 @@ parse_file0(char *filename, DB *db, FILE *f)
} else if (tokenlen == 1 && domainname[0] == '.') {
converted_name = (char *)malloc(1);
if (converted_name == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s", strerror(errno));
slave_shutdown();
exit(1);
}
@@ -454,7 +455,7 @@ parse_file0(char *filename, DB *db, FILE *f)
} else {
converted_name = dns_label(domainname, &converted_namelen);
if (converted_name == NULL) {
- fprintf(stderr, "(XXX) illegal domain name line %d\n", line);
+ dolog(LOG_INFO, "(%d) illegal domain name line %d\n", __LINE__, line);
slave_shutdown();
exit(1);
}
@@ -476,14 +477,14 @@ parse_file0(char *filename, DB *db, FILE *f)
if (db->get(db, &key, &data, 0) == 0) {
#endif
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "damaged btree database");
+ dolog(LOG_INFO, "damaged btree database\n");
return -1;
}
memcpy((char *)&sdomain, (char *)data.data, data.size);
} else {
#if 0
- syslog(LOG_INFO, "db->get: %m");
+ dolog(LOG_INFO, "db->get: %s", strerror(errno));
#endif
}
@@ -497,7 +498,7 @@ parse_file0(char *filename, DB *db, FILE *f)
#endif
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (2) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -505,7 +506,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (3) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -522,14 +523,14 @@ parse_file0(char *filename, DB *db, FILE *f)
}
if (type == 0) {
- syslog(LOG_INFO, "%s: unknown rr line %d", filename, line);
+ dolog(LOG_INFO, "%s: unknown rr line %d\n", filename, line);
return -1;
}
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (4) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -537,7 +538,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (5) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -552,7 +553,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (6) malformed line %d", filename, line );
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line );
return -1;
}
@@ -568,7 +569,7 @@ parse_file0(char *filename, DB *db, FILE *f)
ia = (in_addr_t *) &sdomain.a[sdomain.a_count];
sdomain.a_count++;
} else {
- syslog(LOG_INFO, "%s: too many a records for zone \"%s\", skipping line %d\n", filename, domainname, line);
+ dolog(LOG_INFO, "%s: too many a records for zone \"%s\", skipping line %d\n", filename, domainname, line);
return (-1);
}
@@ -586,7 +587,7 @@ parse_file0(char *filename, DB *db, FILE *f)
case DNS_TYPE_BALANCE:
if ((config & CONFIG_REGION) != CONFIG_REGION) {
- syslog(LOG_INFO, "%s: must have region before zone in config\n", filename);
+ dolog(LOG_INFO, "%s: must have region before zone in config\n", filename);
return -1;
}
@@ -599,7 +600,7 @@ parse_file0(char *filename, DB *db, FILE *f)
ia = (in_addr_t *) &sdomain.a[sdomain.a_count];
sdomain.a_count++;
} else {
- syslog(LOG_INFO, "%s: too many a records for zone \"%s\", skipping line %d\n", filename, domainname, line);
+ dolog(LOG_INFO, "%s: too many a records for zone \"%s\", skipping line %d\n", filename, domainname, line);
return (-1);
}
@@ -628,17 +629,16 @@ parse_file0(char *filename, DB *db, FILE *f)
ia6 = (struct in6_addr *)&sdomain.aaaa[sdomain.aaaa_count];
sdomain.aaaa_count++;
} else {
- syslog(LOG_INFO, "%s: too many aaaa records for zone \"%s\", skipping line %d\n", filename, domainname, line);
+ dolog(LOG_INFO, "%s: too many aaaa records for zone \"%s\", skipping line %d\n", filename, domainname, line);
return (-1);
}
- #ifdef DEBUG
- printf("starttoken = %s\n", starttoken);
- #endif
+ if (debug)
+ dolog(LOG_DEBUG, "starttoken = %s\n", starttoken);
if (inet_pton(AF_INET6, (char *)starttoken, (char *)ia6) != 1) {
sdomain.aaaa_count--;
- fprintf(stderr, "aaaa \"%s\" unparseable line %d\n", starttoken, line);
+ dolog(LOG_INFO, "aaaa \"%s\" unparseable line %d\n", starttoken, line);
}
*p = save;
@@ -651,7 +651,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (7a) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -662,7 +662,7 @@ parse_file0(char *filename, DB *db, FILE *f)
if (sdomain.srv_count < RECORD_COUNT) {
sdomain.srv[sdomain.srv_count].priority = atoi(starttoken);
} else {
- syslog(LOG_INFO, "%s: too many srv records for zone \"%s\", skipping line %d\n", filename, domainname, line);
+ dolog(LOG_INFO, "%s: too many srv records for zone \"%s\", skipping line %d\n", filename, domainname, line);
return (-1);
}
@@ -671,7 +671,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (7b) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -685,7 +685,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (7b) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -695,7 +695,7 @@ parse_file0(char *filename, DB *db, FILE *f)
sdomain.srv[sdomain.srv_count].port = atoi(starttoken);
if (++p >= endline) {
- fprintf(stderr, "(XX) malformed line %d", line);
+ dolog(LOG_INFO, "(%d) malformed line %d\n", __LINE__, line);
break;
}
@@ -710,7 +710,7 @@ parse_file0(char *filename, DB *db, FILE *f)
char *n;
if ((name = dns_label(starttoken, (int *)&sdomain.srv[sdomain.srv_count].targetlen)) == NULL) {
- fprintf(stderr, "illegal srv server, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal srv server, skipping line %d\n", line);
goto skip;
}
n = (char *)sdomain.srv[sdomain.srv_count].target;
@@ -734,7 +734,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (7) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -745,14 +745,14 @@ parse_file0(char *filename, DB *db, FILE *f)
if (sdomain.mx_count < RECORD_COUNT) {
sdomain.mx[sdomain.mx_count].preference = atoi(starttoken);
} else {
- syslog(LOG_INFO, "%s: too many mx records for zone \"%s\", skipping line %d\n", filename, domainname, line);
+ dolog(LOG_INFO, "%s: too many mx records for zone \"%s\", skipping line %d\n", filename, domainname, line);
return (-1);
}
*p = save;
if (++p >= endline) {
- fprintf(stderr, "(XX) malformed line %d", line);
+ dolog(LOG_INFO, "(%d) malformed line %d\n", __LINE__, line);
break;
}
@@ -768,7 +768,7 @@ parse_file0(char *filename, DB *db, FILE *f)
char *n;
if ((name = dns_label(starttoken, (int *)&sdomain.mx[sdomain.mx_count].exchangelen)) == NULL) {
- fprintf(stderr, "illegal mx server, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal mx server, skipping line %d\n", line);
goto skip;
}
n = (char *)sdomain.mx[sdomain.mx_count].exchange;
@@ -785,7 +785,7 @@ parse_file0(char *filename, DB *db, FILE *f)
case DNS_TYPE_SOA:
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (7) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -794,12 +794,12 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = 0;
if ((name = dns_label(starttoken, (int *)&convert)) == NULL) {
- fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", line);
goto skip;
}
if (convert > 0xff || convert < 0) {
- fprintf(stderr, "illegal convert value");
+ dolog(LOG_INFO, "illegal convert value line %d\n", line);
return -1;
}
@@ -810,7 +810,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (8) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -818,7 +818,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (9) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d", filename, __LINE__, line);
return -1;
}
@@ -827,12 +827,12 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = 0;
if ((name = dns_label(starttoken, (int *)&convert)) == NULL) {
- fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", line);
goto skip;
}
if (convert > 0xff || convert < 0) {
- fprintf(stderr, "illegal convert value");
+ dolog(LOG_INFO, "illegal convert value line %d\n", line );
return -1;
}
@@ -843,7 +843,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (10) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -851,7 +851,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (11) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -864,7 +864,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (12) malformed line %d\n", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -872,7 +872,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (13) malformed line %d\n", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -885,7 +885,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (14) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -893,7 +893,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (15) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d", filename, __LINE__, line);
return -1;
}
@@ -906,7 +906,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (16) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -914,7 +914,7 @@ parse_file0(char *filename, DB *db, FILE *f)
for (p = starttoken; p < endline && *p != ','; p++);
if (p >= endline || *p != ',') {
- syslog(LOG_INFO, "%s: (17) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__,line);
return -1;
}
@@ -927,7 +927,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = save;
if (++p >= endline) {
- syslog(LOG_INFO, "%s: (18) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return -1;
}
@@ -953,7 +953,7 @@ parse_file0(char *filename, DB *db, FILE *f)
char *name;
if ((name = dns_label(starttoken, (int *)&sdomain.ptrlen)) == NULL) {
- fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", line);
goto skip;
}
@@ -974,7 +974,7 @@ parse_file0(char *filename, DB *db, FILE *f)
*p = 0;
if (sdomain.ns_count >= RECORD_COUNT) {
- syslog(LOG_INFO, "%s: too many ns records for zone \"%s\", skipping line %d\n", filename, domainname, line);
+ dolog(LOG_INFO, "%s: too many ns records for zone \"%s\", skipping line %d\n", filename, domainname, line);
return (-1);
}
@@ -983,7 +983,7 @@ parse_file0(char *filename, DB *db, FILE *f)
char *n;
if ((name = dns_label(starttoken, &(sdomain.ns[sdomain.ns_count].nslen))) == NULL) {
- fprintf(stderr, "illegal ns server, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal ns server, skipping line %d\n", line);
goto skip;
}
n = (char *)sdomain.ns[sdomain.ns_count].nsserver;
@@ -1018,7 +1018,7 @@ parse_file0(char *filename, DB *db, FILE *f)
char *name;
if ((name = dns_label(starttoken, (int *)&sdomain.cnamelen)) == NULL) {
- fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
+ dolog(LOG_INFO, "illegal nameserver, skipping line %d\n", line);
goto skip;
}
@@ -1038,7 +1038,7 @@ parse_file0(char *filename, DB *db, FILE *f)
tokenlen = (p - starttoken);
if (tokenlen > 255) {
- syslog(LOG_INFO, "%s: TXT record too long, maximum length is 255 (per protocol), line %d\n", filename, line);
+ dolog(LOG_INFO, "%s: TXT record too long, maximum length is 255 (per protocol), line %d\n", filename, line);
return (-1);
}
@@ -1086,22 +1086,22 @@ parse_file0(char *filename, DB *db, FILE *f)
#if DB_VERSION_MAJOR > 3
/* XXX */
if ((ret = db->put(db, NULL, &key, &data, 0)) != 0) {
- fprintf(stderr, "db->put: %s" , db_strerror(ret));
+ dolog(LOG_INFO, "db->put: %s\n" , db_strerror(ret));
#else
if (db->put(db, &key, &data, 0) < 0) {
- syslog(LOG_INFO, "db->put: %m");
+ dolog(LOG_INFO, "db->put: %s\n", strerror(errno));
#endif
return -1;
}
skip:
-#ifdef DEBUG
- save = *endline;
- *endline = 0;
-
- printf("line %d: \"%s\"\n", line, start);
+ if (debug) {
+ save = *endline;
+ *endline = 0;
+
+ dolog(LOG_DEBUG, "line %d: \"%s\"\n", line, start);
- *endline = save;
-#endif
+ *endline = save;
+ }
if (converted_name)
free (converted_name);
@@ -1120,7 +1120,7 @@ skip:
starttoken++;
for (p = starttoken; *p && *p != '"';p++);
if (*p == '\0') {
- syslog(LOG_INFO, "%s: (30) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d", filename, __LINE__, line);
return (-1);
}
*p++ = '\0';
@@ -1128,13 +1128,13 @@ skip:
version = atoi(starttoken);
if (version != WILDCARDVERSION) {
- syslog(LOG_INFO, "%s: version of configfile is wrong, must be"
- " \"%d\"", filename, WILDCARDVERSION);
+ dolog(LOG_INFO, "%s: version of configfile is wrong, must be"
+ " \"%d\"\n", filename, WILDCARDVERSION);
return (-1);
}
if (*p != ';') {
- syslog(LOG_INFO, "%s: missing trailing semi-colon on line %d", filename, line);
+ dolog(LOG_INFO, "%s: missing trailing semi-colon on line %d\n", filename, line);
return (-1);
}
@@ -1147,7 +1147,7 @@ skip:
starttoken++;
for (p = starttoken; *p && *p != '"';p++);
if (*p == '\0') {
- syslog(LOG_INFO, "%s: (%d) malformed line %d", filename, __LINE__, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return (-1);
}
*p++ = '\0';
@@ -1155,7 +1155,7 @@ skip:
axfrport = atoi(starttoken);
if (*p != ';') {
- syslog(LOG_INFO, "%s: missing trailing semi-colon on line %d", filename, line);
+ dolog(LOG_INFO, "%s: missing trailing semi-colon on line %d\n", filename, line);
return (-1);
}
@@ -1173,13 +1173,13 @@ skip:
starttoken++;
for (p = starttoken; *p && *p != '"';p++);
if (*p == '\0') {
- syslog(LOG_INFO, "%s: (include) malformed line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line %d\n", filename, __LINE__, line);
return (-1);
}
*p++ = '\0';
if ((includef = fopen(starttoken, "r")) == NULL) {
- syslog(LOG_INFO, "%s: include file: %s: %s", filename, starttoken, strerror(errno));
+ dolog(LOG_INFO, "%s: include file: %s: %s\n", filename, starttoken, strerror(errno));
return (-1);
}
@@ -1203,7 +1203,7 @@ skip:
if (*starttoken == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (31) malformed line, line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d\n", filename, __LINE__, line);
return (-1);
}
@@ -1214,13 +1214,13 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (32) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
*p = '\0';
if (insert_region(address, starttoken, region) < 0) {
- syslog(LOG_INFO, "%s: address on line %d, is malformed", filename, line);
+ dolog(LOG_INFO, "%s: address on line %d, is malformed\n", filename, line);
return (-1);
}
} /* CONFIG_REGION */
@@ -1237,7 +1237,7 @@ skip:
if (*starttoken == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (31) malformed line, line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d\n", filename, __LINE__, line);
return (-1);
}
@@ -1248,13 +1248,13 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (32) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
*p = '\0';
if (insert_wildcard(address, starttoken) < 0) {
- syslog(LOG_INFO, "%s: address on line %d, is malformed", filename, line);
+ dolog(LOG_INFO, "%s: address on line %d, is malformed\n", filename, line);
return (-1);
}
} /* CONFIG_WILDCARDONLYFOR */
@@ -1270,7 +1270,7 @@ skip:
if (*starttoken == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (%d) malformed line, line %d", filename, __LINE__, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d\n", filename, __LINE__, line);
return (-1);
}
@@ -1281,13 +1281,13 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon", filename, __LINE__, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
*p = '\0';
if (insert_axfr(address, starttoken) < 0) {
- syslog(LOG_INFO, "%s: address on line %d, is malformed", filename, line);
+ dolog(LOG_INFO, "%s: address on line %d, is malformed\n", filename, line);
return (-1);
}
} /* CONFIG_AXFRFOR */
@@ -1304,7 +1304,7 @@ skip:
if (*starttoken == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (31) malformed line, line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d\n", filename, __LINE__, line);
return (-1);
}
@@ -1315,13 +1315,13 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (32) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
*p = '\0';
if (insert_recurse(address, starttoken) < 0) {
- syslog(LOG_INFO, "%s: address on line %d, is malformed", filename, line);
+ dolog(LOG_INFO, "%s: address on line %d, is malformed\n", filename, line);
return (-1);
}
} /* CONFIG_RECURSEFOR */
@@ -1338,7 +1338,7 @@ skip:
if (*starttoken == '\n')
goto loop;
- syslog(LOG_INFO, "%s: (34) malformed line, line %d", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d\n", filename, __LINE__, line);
return (-1);
}
@@ -1349,7 +1349,7 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (36) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
@@ -1365,7 +1365,7 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (35) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
@@ -1381,13 +1381,13 @@ skip:
error = getaddrinfo(starttoken, "www", &hints, &res0);
if (error) {
- syslog(LOG_INFO, "%s line %d: %s", filename, line,
+ dolog(LOG_INFO, "%s line %d: %s\n", filename, line,
gai_strerror(error));
return (-1);
}
if (res0 == NULL) {
- syslog(LOG_INFO, "%s line %d: could not determine IPv6 address", filename, line);
+ dolog(LOG_INFO, "%s line %d: could not determine IPv6 address\n", filename, line);
return (-1);
}
@@ -1404,13 +1404,13 @@ skip:
error = getaddrinfo(starttoken, "www", &hints, &res0);
if (error) {
- syslog(LOG_INFO, "%s line %d: %s", filename, line,
+ dolog(LOG_INFO, "%s line %d: %s\n", filename, line,
gai_strerror(error));
return (-1);
}
if (res0 == NULL) {
- syslog(LOG_INFO, "%s line %d: could not determine IPv6 address", filename, line);
+ dolog(LOG_INFO, "%s line %d: could not determine IPv6 address\n", filename, line);
return (-1);
}
@@ -1427,7 +1427,7 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (35) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
@@ -1442,7 +1442,7 @@ skip:
p = strchr(starttoken, ';');
if (p == NULL) {
- syslog(LOG_INFO, "%s: (36) malformed line, line %d, must have closing semi-colon", filename, line);
+ dolog(LOG_INFO, "%s: (%d) malformed line, line %d, must have closing semi-colon\n", filename, __LINE__, line);
return (-1);
}
@@ -1472,20 +1472,20 @@ opendatabase(DB *ret)
#if DB_VERSION_MAJOR == 4
if (db_create((DB **)&ret, (DB_ENV *)NULL, 0) != 0) {
- syslog(LOG_INFO, "db_create: %m");
+ dolog(LOG_INFO, "db_create: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
#if DB_VERSION_MINOR > 0
if (ret->open(ret, NULL, NULL, NULL, DB_BTREE, DB_CREATE, 0600) != 0) {
- syslog(LOG_INFO, "db->open: %m");
+ dolog(LOG_INFO, "db->open: %s\n", strerror(errno));
ret->close(ret, DB_NOSYNC);
slave_shutdown();
exit(1);
}
#else
if (ret->open(ret, NULL, NULL, DB_BTREE, DB_CREATE, 0600) != 0) {
- syslog(LOG_INFO, "db->open: %m");
+ dolog(LOG_INFO, "db->open: %s\n", strerror(errno));
ret->close(ret, DB_NOSYNC);
slave_shutdown();
exit(1);
@@ -1497,7 +1497,7 @@ opendatabase(DB *ret)
ret = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL);
if (ret == NULL) {
- syslog(LOG_INFO, "dbopen: %m");
+ dolog(LOG_INFO, "dbopen: %s\n", strerror(errno));
slave_shutdown();
exit(1);
}
blob - 6ac300e29d68635de44031261b146fac734a28ba
blob + 1b61627f5a68fe92df396dc57e53b851e5d164ff
--- recurse.c
+++ recurse.c
@@ -37,6 +37,7 @@ extern struct question * build_fake_question(char *, i
extern int free_question(struct question *);
extern int lookup_zone(DB *db, struct question *question, struct domain *sd, int *lzerrno, char *replystring, int wildcard);
extern void slave_shutdown(void);
+extern void dolog(int, char *, ...);
void init_recurse(void);
int find_recurse(struct sockaddr_storage *sst, int family);
@@ -74,6 +75,8 @@ int level(u_char *p);
int lookup_aaaa(DB *db, struct recurses *sr, struct ns *ns);
int netlookup6(DB *db, struct recurses *sr);
+extern int debug, verbose;
+
#ifndef MIN
#define MIN(a,b) ((a < b) ? a : b)
#endif
@@ -90,7 +93,7 @@ struct recurseentry {
} *rn1, *rn2, *rnp;
-static const char rcsid[] = "$Id: recurse.c,v 1.39 2013/02/16 11:47:30 pjp Exp $";
+static const char rcsid[] = "$Id: recurse.c,v 1.40 2013/02/16 17:27:06 pjp Exp $";
/*
* INIT_RECURSE - initialize the recurse singly linked list
@@ -254,7 +257,7 @@ recurseloop(int sp, int *raw, DB *db)
*/
SLIST_FOREACH(sr1, &recurseshead, entries) {
if (sr1->isfake && !sr1->launched) {
- syslog(LOG_DEBUG, "launching question (fakesr) for %s", sr1->question->hdr->name);
+ dolog(LOG_DEBUG, "launching question (fakesr) for %s", sr1->question->hdr->name);
sr1->launched = 1;
type = lookup_zone(db, sr1->question, &sd, &lzerrno, (char *)fakereplystring, wildcard);
if (type < 0) {
@@ -277,11 +280,11 @@ recurseloop(int sp, int *raw, DB *db)
* outstanding...
*/
if (! sr1->hascallback) {
- syslog(LOG_DEBUG, "removing recurses struct");
+ dolog(LOG_DEBUG, "removing recurses struct");
SLIST_REMOVE(&recurseshead, sr1, recurses, entries);
if (sr1->so != -1) {
if (close(sr1->so) < 0)
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
sr1->so = -1;
}
@@ -312,7 +315,7 @@ recurseloop(int sp, int *raw, DB *db)
tv.tv_usec = 0;
sel = select(maxso + 1, &rset, NULL, NULL, &tv);
if (sel < 0) {
- syslog(LOG_INFO, "select: %m");
+ dolog(LOG_INFO, "select: %m");
continue;
} else if (sel == 0) {
/* timeout */
@@ -322,7 +325,7 @@ recurseloop(int sp, int *raw, DB *db)
if (FD_ISSET(sp, &rset)) {
ret = recv(sp, (char *)&rh, sizeof(rh), 0);
if (ret < 0) {
- syslog(LOG_INFO, "recv: %m");
+ dolog(LOG_INFO, "recv: %m");
continue;
}
@@ -330,7 +333,7 @@ recurseloop(int sp, int *raw, DB *db)
sr = calloc(sizeof(struct recurses), 1);
if (sr == NULL) {
- syslog(LOG_ERR, "calloc: %m");
+ dolog(LOG_ERR, "calloc: %m");
continue;
}
@@ -350,7 +353,7 @@ recurseloop(int sp, int *raw, DB *db)
sr->question = build_question(sr->query, sr->len);
if (sr->question == NULL) {
- syslog(LOG_ERR, "malformed question in recurse.c");
+ dolog(LOG_ERR, "malformed question in recurse.c");
free(sr);
continue;
}
@@ -372,7 +375,7 @@ recurseloop(int sp, int *raw, DB *db)
SLIST_INSERT_HEAD(&recurseshead, sr, entries);
} else {
- syslog(LOG_DEBUG, "we had the record in our cache, reply action");
+ dolog(LOG_DEBUG, "we had the record in our cache, reply action");
/* check if zone is expired */
if ((! (sd.flags & DOMAIN_STATIC_ZONE)) &&
@@ -410,7 +413,7 @@ recurseloop(int sp, int *raw, DB *db)
slen = sizeof(struct sockaddr_storage);
if ((len = recvfrom(sr1->so, buf, sizeof(buf), 0, (struct sockaddr *)&ssin, &slen)) < 0) {
if (errno != EWOULDBLOCK)
- syslog(LOG_ERR, "recvfrom: %m");
+ dolog(LOG_ERR, "recvfrom: %m");
continue;
}
@@ -421,7 +424,7 @@ recurseloop(int sp, int *raw, DB *db)
case AF_INET:
sin = (struct sockaddr_in *)&ssin;
if (sin->sin_addr.s_addr != sr1->a[0]) {
- syslog(LOG_ERR, "return address is not from right nameserver");
+ dolog(LOG_ERR, "return address is not from right nameserver");
continue;
}
break;
@@ -430,7 +433,7 @@ recurseloop(int sp, int *raw, DB *db)
if (memcmp((char *)&sin6->sin6_addr, (char *)&sr1->aaaa[0], sizeof(struct in6_addr)) != 0) {
inet_ntop(AF_INET6, &sin6->sin6_addr, address, sizeof(address));
- syslog(LOG_ERR, "return IPv6 address (%s) is not from right nameserver", address);
+ dolog(LOG_ERR, "return IPv6 address (%s) is not from right nameserver", address);
continue;
}
break;
@@ -438,7 +441,7 @@ recurseloop(int sp, int *raw, DB *db)
#endif
if (len < sizeof(struct dns_header)) {
- syslog(LOG_ERR, "size malformed on reply len=%d", len);
+ dolog(LOG_ERR, "size malformed on reply len=%d", len);
/* on error, we just go out and wait for the real ID, this sucks! XXX */
continue;
}
@@ -446,26 +449,26 @@ recurseloop(int sp, int *raw, DB *db)
dh = (struct dns_header*)&buf[0];
if (ntohs(dh->id) != sr1->id) {
- syslog(LOG_ERR, "unexpected dns ID (%u != %u)", ntohs(dh->id), sr1->id);
+ dolog(LOG_ERR, "unexpected dns ID (%u != %u)", ntohs(dh->id), sr1->id);
/* on error, we just go out and wait for the real ID, this sucks! XXX */
continue;
}
if (! (ntohs(dh->query) & DNS_REPLY)) {
- syslog(LOG_ERR, "reply is not a DNS reply");
+ dolog(LOG_ERR, "reply is not a DNS reply");
continue;
}
/* XXX */
if (close(sr1->so) < 0)
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
sr1->so = -1;
if (ntohs(dh->query) & DNS_NAMEERR) {
negative_cache(db, sr1);
- syslog(LOG_DEBUG, "added negative cache for domain \"%s\"", sr1->question->converted_name);
+ dolog(LOG_DEBUG, "added negative cache for domain \"%s\"", sr1->question->converted_name);
/* reply negatively */
reply_raw_nxdomain(db, sr1, &sd, raw);
goto remove;
@@ -476,23 +479,23 @@ recurseloop(int sp, int *raw, DB *db)
/* check if we're flooding anything */
if (sr1->packetcount > 50) {
- syslog(LOG_ERR, "packetcount is over 50, I think I'm flooding something, abort()");
+ dolog(LOG_ERR, "packetcount is over 50, I think I'm flooding something, abort()");
slave_shutdown();
abort();
}
type = lookup_zone(db, sr1->question, &sd, &lzerrno, (char *)fakereplystring, wildcard);
if (type < 0) {
- syslog(LOG_DEBUG, "lookup_zone failed, doing netlookup");
+ dolog(LOG_DEBUG, "lookup_zone failed, doing netlookup");
if (sr1->authoritative == DNS_TYPE_NS &&
netlookup(db, sr1) < 0) {
- syslog(LOG_DEBUG, "subsequent netlookup failed");
+ dolog(LOG_DEBUG, "subsequent netlookup failed");
}
if (sr1->authoritative == DNS_TYPE_SOA) {
- syslog(LOG_DEBUG, "got an authoritative SOA answer, we'd reply an SOA here");
+ dolog(LOG_DEBUG, "got an authoritative SOA answer, we'd reply an SOA here");
memset(&sd, 0, sizeof(struct domain));
get_soa(db, sr1->question, &sd, wildcard);
@@ -510,10 +513,10 @@ recurseloop(int sp, int *raw, DB *db)
if (sr1->isfake) {
/* do another netlookup with the callback */
- syslog(LOG_DEBUG, "sr is fake, doing netlookup on the callback");
+ dolog(LOG_DEBUG, "sr is fake, doing netlookup on the callback");
if (netlookup(db, sr1->callback) < 0) {
- syslog(LOG_DEBUG, "callback netlookup failed");
+ dolog(LOG_DEBUG, "callback netlookup failed");
}
sr1->callback->hascallback--;
@@ -642,12 +645,12 @@ again:
/* we have a lookup */
if (data.size != sizeof(struct domain)) {
- syslog(LOG_ERR, "btree db is damaged");
+ dolog(LOG_ERR, "btree db is damaged");
return (-1);
}
#if 0
- syslog(LOG_DEBUG, "we gots a lookup, yay!\n");
+ dolog(LOG_DEBUG, "we gots a lookup, yay!\n");
#endif
/*
@@ -716,7 +719,7 @@ again:
} while (*p != 0 && ret != 0);
#if 1
- syslog(LOG_DEBUG, "got %d addresses for %s, indicator %d\n", sr->a_count, sr->question->hdr->name, sr->indicator);
+ dolog(LOG_DEBUG, "got %d addresses for %s, indicator %d\n", sr->a_count, sr->question->hdr->name, sr->indicator);
#endif
@@ -762,7 +765,7 @@ lookup_a(DB *db, struct recurses *sr, struct ns *ns)
if (ret == 0) {
if (data.size != sizeof(struct domain)) {
- syslog(LOG_ERR, "btree db is damaged");
+ dolog(LOG_ERR, "btree db is damaged");
return (-1);
}
@@ -778,7 +781,7 @@ lookup_a(DB *db, struct recurses *sr, struct ns *ns)
}
if (! found) {
- syslog(LOG_DEBUG, "calling fakerecurse");
+ dolog(LOG_DEBUG, "calling fakerecurse");
fakerecurse(db, sr, ns, DNS_TYPE_A);
return (-1);
}
@@ -1075,7 +1078,7 @@ again:
* recursive label... corrupt.
*/
- syslog(LOG_ERR, "corrupt compression");
+ dolog(LOG_ERR, "corrupt compression");
return (-1);
}
@@ -1086,7 +1089,7 @@ again:
#if 0
for (j = 0; j <= i; j++) {
- syslog(LOG_DEBUG, "%s with length %u", converted_name[j], cn_len[j]);
+ dolog(LOG_DEBUG, "%s with length %u", converted_name[j], cn_len[j]);
}
#endif
@@ -1147,7 +1150,7 @@ again:
if (db->get(db, &key, &data, 0) == 0) {
#endif
if (data.size != sizeof(struct domain)) {
- syslog(LOG_INFO, "damaged btree database");
+ dolog(LOG_INFO, "damaged btree database");
return -1;
}
@@ -1173,14 +1176,14 @@ again:
for (j = 0; j < sdomain.a_count; j++) {
if (memcmp(&sdomain.a[j], p, sizeof(in_addr_t)) == 0) {
#if 0
- syslog(LOG_INFO, "record exists already");
+ dolog(LOG_INFO, "record exists already");
#endif
update = 0;
}
}
if (j >= RECORD_COUNT) {
- syslog(LOG_INFO, "db can't hold any more records\n");
+ dolog(LOG_INFO, "db can't hold any more records\n");
update = 0;
}
@@ -1215,13 +1218,13 @@ again:
if (! (sdomain.flags & DOMAIN_STATIC_ZONE)) {
update_db(db, &sdomain);
inet_ntop(AF_INET, p, abuf, sizeof(abuf));
- syslog(LOG_DEBUG, "updateing zone %s with address %s ttl= %u, lookrecord = %s", converted_name[i], abuf, sdomain.ttl, sr->lookrecord);
+ dolog(LOG_DEBUG, "updateing zone %s with address %s ttl= %u, lookrecord = %s", converted_name[i], abuf, sdomain.ttl, sr->lookrecord);
}
}
p += sizeof(in_addr_t);
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
rrcount[pointer]--;
@@ -1239,14 +1242,14 @@ again:
for (j = 0; j < sdomain.aaaa_count; j++) {
if (memcmp(&sdomain.aaaa[j], p, sizeof(struct in6_addr)) == 0) {
#if 0
- syslog(LOG_INFO, "record exists already");
+ dolog(LOG_INFO, "record exists already");
#endif
update = 0;
}
}
if (j >= RECORD_COUNT) {
- syslog(LOG_INFO, "db can't hold any more records\n");
+ dolog(LOG_INFO, "db can't hold any more records\n");
update = 0;
}
@@ -1279,12 +1282,12 @@ again:
if (! (sdomain.flags & DOMAIN_STATIC_ZONE)) {
update_db(db, &sdomain);
inet_ntop(AF_INET6, p, abuf, sizeof(abuf));
- syslog(LOG_DEBUG, "updateing zone %s with address %s ttl= %u\n", converted_name[i], abuf, sdomain.ttl);
+ dolog(LOG_DEBUG, "updateing zone %s with address %s ttl= %u\n", converted_name[i], abuf, sdomain.ttl);
}
}
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
rrcount[pointer]--;
@@ -1309,7 +1312,7 @@ again:
}
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
@@ -1374,12 +1377,12 @@ again:
if (! (sdomain.flags & DOMAIN_STATIC_ZONE)) {
update_db(db, &sdomain);
#if 1
- syslog(LOG_DEBUG, "updateing zone %s with PTR name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
+ dolog(LOG_DEBUG, "updateing zone %s with PTR name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
#endif
}
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
@@ -1398,12 +1401,12 @@ again:
if (! (sdomain.flags & DOMAIN_STATIC_ZONE)) {
update_db(db, &sdomain);
#if 1
- syslog(LOG_DEBUG, "updateing zone %s with PTR name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
+ dolog(LOG_DEBUG, "updateing zone %s with PTR name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
#endif
}
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
@@ -1415,14 +1418,14 @@ again:
for (j = 0; j < sdomain.ns_count; j++) {
if (memcasecmp((u_char *)sdomain.ns[j].nsserver, (u_char *)converted_name[i], MIN(cn_len[i], sdomain.ns[j].nslen)) == 0) {
#if 0
- syslog(LOG_INFO, "record exists already");
+ dolog(LOG_INFO, "record exists already");
#endif
update = 0;
}
}
if (j >= RECORD_COUNT) {
- syslog(LOG_INFO, "db can't hold any more records\n");
+ dolog(LOG_INFO, "db can't hold any more records\n");
update = 0;
}
@@ -1440,12 +1443,12 @@ again:
if (! (sdomain.flags & DOMAIN_STATIC_ZONE)) {
update_db(db, &sdomain);
#if 0
- syslog(LOG_DEBUG, "updateing zone %s with NS name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
+ dolog(LOG_DEBUG, "updateing zone %s with NS name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
#endif
}
} /* if update */
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
@@ -1464,7 +1467,7 @@ again:
}
if (j >= RECORD_COUNT) {
- syslog(LOG_INFO, "db can't hold any more records\n");
+ dolog(LOG_INFO, "db can't hold any more records\n");
update = 0;
}
@@ -1483,12 +1486,12 @@ again:
if (! (sdomain.flags & DOMAIN_STATIC_ZONE)) {
update_db(db, &sdomain);
#if 0
- syslog(LOG_DEBUG, "updateing zone %s with MX name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
+ dolog(LOG_DEBUG, "updateing zone %s with MX name %s ttl= %u\n", converted_name[i - 1], converted_name[i], sdomain.ttl);
#endif
}
} /* if update */
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
@@ -1546,7 +1549,7 @@ again:
soa = malloc(sizeof(struct soa));
if (soa == NULL) {
- syslog(LOG_ERR, "malloc: %m");
+ dolog(LOG_ERR, "malloc: %m");
return (-1);
}
@@ -1572,7 +1575,7 @@ again:
}
if (pointer > 2) {
- syslog(LOG_ERR, "there is more records than indicated in the header!!!");
+ dolog(LOG_ERR, "there is more records than indicated in the header!!!");
return (-1);
}
@@ -1597,7 +1600,7 @@ again:
return (0);
end:
- syslog(LOG_DEBUG, "mangled input packet");
+ dolog(LOG_DEBUG, "mangled input packet");
return (-1);
}
@@ -1626,12 +1629,12 @@ netlookup(DB *db, struct recurses *sr)
if (sr->so != -1) {
if (close(sr->so) < 0)
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sr->so < 0) {
- syslog(LOG_ERR, "socket: %m");
+ dolog(LOG_ERR, "socket: %m");
sr->so = -1;
return (-1);
}
@@ -1652,9 +1655,9 @@ netlookup(DB *db, struct recurses *sr)
sin.sin_addr.s_addr = INADDR_ANY;
if (bind(sr->so, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- syslog(LOG_ERR, "bind: %m");
+ dolog(LOG_ERR, "bind: %m");
if (close(sr->so) < 0) {
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = -1;
return (-1);
@@ -1665,17 +1668,17 @@ netlookup(DB *db, struct recurses *sr)
*/
if ((flag = fcntl(sr->so, F_GETFL)) < 0) {
- syslog(LOG_INFO, "fcntl 3: %m");
+ dolog(LOG_INFO, "fcntl 3: %m");
}
flag |= O_NONBLOCK;
if (fcntl(sr->so, F_SETFL, flag) < 0) {
- syslog(LOG_INFO, "fcntl 4: %m");
+ dolog(LOG_INFO, "fcntl 4: %m");
}
if (lookup_ns(db, sr) <= 0) {
- syslog(LOG_ERR, "can't establish any servers to reach for zone \"%s\"", sr->question->converted_name);
+ dolog(LOG_ERR, "can't establish any servers to reach for zone \"%s\"", sr->question->converted_name);
if (close(sr->so) < 0) {
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = -1;
return (-1);
@@ -1698,14 +1701,14 @@ netlookup(DB *db, struct recurses *sr)
dh->id = htons(sr->id);
#if 1
- syslog(LOG_INFO, "sending request with id %u\n", sr->id);
+ dolog(LOG_INFO, "sending request with id %u\n", sr->id);
#endif
if (sendto(sr->so, buf, sr->len, 0, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- syslog(LOG_ERR, "sendto: %m");
+ dolog(LOG_ERR, "sendto: %m");
if (close(sr->so) < 0) {
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = -1;
return (-1);
@@ -1739,7 +1742,7 @@ fakerecurse(DB *db, struct recurses *sr, struct ns *ns
SLIST_FOREACH(sr2, &recurseshead, entries) {
if (memcasecmp((u_char *)ns->nsserver, (u_char *)sr2->question->hdr->name, MIN(ns->nslen, sr2->question->hdr->namelen)) == 0) {
- syslog(LOG_INFO, "already have a fakerecurse structure with name %s, drop\n", ns->nsserver);
+ dolog(LOG_INFO, "already have a fakerecurse structure with name %s, drop\n", ns->nsserver);
return (-1);
}
}
@@ -1749,7 +1752,7 @@ fakerecurse(DB *db, struct recurses *sr, struct ns *ns
fakesr = calloc(sizeof(struct recurses), 1);
if (fakesr == NULL) {
- syslog(LOG_ERR, "calloc: %m");
+ dolog(LOG_ERR, "calloc: %m");
return (-1);
}
@@ -1768,7 +1771,7 @@ fakerecurse(DB *db, struct recurses *sr, struct ns *ns
fakesr->question = build_fake_question(ns->nsserver, ns->nslen, htons(type));
if (fakesr->question == NULL) {
- syslog(LOG_ERR, "malformed question in recurse.c");
+ dolog(LOG_ERR, "malformed question in recurse.c");
free(fakesr);
return (-1);
}
@@ -1814,7 +1817,7 @@ reply_raw(DB *db, struct recurses *sr, struct domain *
int so;
struct sreply sreply;
- syslog(LOG_DEBUG, "reply_raw called");
+ dolog(LOG_DEBUG, "reply_raw called");
switch (sr->af) {
case AF_INET:
@@ -1824,7 +1827,7 @@ reply_raw(DB *db, struct recurses *sr, struct domain *
so = raw[1];
break;
default:
- syslog(LOG_ERR, "reply_raw(): unknown address family in struct recurses");
+ dolog(LOG_ERR, "reply_raw(): unknown address family in struct recurses");
return;
}
@@ -1832,7 +1835,7 @@ reply_raw(DB *db, struct recurses *sr, struct domain *
case IPPROTO_UDP:
break;
default:
- syslog(LOG_ERR, "reply_raw(): can't do any protocol other than udp right now");
+ dolog(LOG_ERR, "reply_raw(): can't do any protocol other than udp right now");
return;
}
@@ -1864,7 +1867,7 @@ reply_raw(DB *db, struct recurses *sr, struct domain *
reply_txt(&sreply);
break;
default:
- syslog(LOG_ERR, "other types have not been implemented yet");
+ dolog(LOG_ERR, "other types have not been implemented yet");
break;
}
@@ -1877,7 +1880,7 @@ reply_raw_cname(DB *db, struct recurses *sr, struct do
int so;
struct sreply sreply;
- syslog(LOG_DEBUG, "reply_raw called");
+ dolog(LOG_DEBUG, "reply_raw called");
switch (sr->af) {
case AF_INET:
@@ -1887,7 +1890,7 @@ reply_raw_cname(DB *db, struct recurses *sr, struct do
so = raw[1];
break;
default:
- syslog(LOG_ERR, "reply_raw_cname(): unknown address family in struct recurses");
+ dolog(LOG_ERR, "reply_raw_cname(): unknown address family in struct recurses");
return;
}
@@ -1895,7 +1898,7 @@ reply_raw_cname(DB *db, struct recurses *sr, struct do
case IPPROTO_UDP:
break;
default:
- syslog(LOG_ERR, "reply_raw_cname(): can't do any protocol other than udp right now");
+ dolog(LOG_ERR, "reply_raw_cname(): can't do any protocol other than udp right now");
return;
}
@@ -1930,10 +1933,10 @@ remove_zone(DB *db, struct domain *sd)
#else
if (db->del(db, &key, 0) != 0) {
#endif
- syslog(LOG_ERR, "could not delete zone %s: %m", zone);
+ dolog(LOG_ERR, "could not delete zone %s: %m", zone);
}
- syslog(LOG_DEBUG, "deleting zone %s\n", zone);
+ dolog(LOG_DEBUG, "deleting zone %s\n", zone);
free(zone);
@@ -1946,7 +1949,7 @@ reply_raw_noerror(DB *db, struct recurses *sr, struct
int so;
struct sreply sreply;
- syslog(LOG_DEBUG, "reply_raw_noerror called");
+ dolog(LOG_DEBUG, "reply_raw_noerror called");
switch (sr->af) {
case AF_INET:
@@ -1956,7 +1959,7 @@ reply_raw_noerror(DB *db, struct recurses *sr, struct
so = raw[1];
break;
default:
- syslog(LOG_ERR, "reply_raw_noerror(): unknown address family in struct recurses");
+ dolog(LOG_ERR, "reply_raw_noerror(): unknown address family in struct recurses");
return;
}
@@ -1964,7 +1967,7 @@ reply_raw_noerror(DB *db, struct recurses *sr, struct
case IPPROTO_UDP:
break;
default:
- syslog(LOG_ERR, "reply_raw_noerror(): can't do any protocol other than udp right now");
+ dolog(LOG_ERR, "reply_raw_noerror(): can't do any protocol other than udp right now");
return;
}
@@ -1981,7 +1984,7 @@ reply_raw_nxdomain(DB *db, struct recurses *sr, struct
int so;
struct sreply sreply;
- syslog(LOG_DEBUG, "reply_raw_nxdomain called");
+ dolog(LOG_DEBUG, "reply_raw_nxdomain called");
switch (sr->af) {
case AF_INET:
@@ -1991,7 +1994,7 @@ reply_raw_nxdomain(DB *db, struct recurses *sr, struct
so = raw[1];
break;
default:
- syslog(LOG_ERR, "reply_raw_nxdomain(): unknown address family in struct recurses");
+ dolog(LOG_ERR, "reply_raw_nxdomain(): unknown address family in struct recurses");
return;
}
@@ -1999,7 +2002,7 @@ reply_raw_nxdomain(DB *db, struct recurses *sr, struct
case IPPROTO_UDP:
break;
default:
- syslog(LOG_ERR, "reply_raw_nxdomain(): can't do any protocol other than udp right now");
+ dolog(LOG_ERR, "reply_raw_nxdomain(): can't do any protocol other than udp right now");
return;
}
@@ -2081,12 +2084,12 @@ netlookup6(DB *db, struct recurses *sr)
if (sr->so != -1) {
if (close(sr->so) < 0)
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (sr->so < 0) {
- syslog(LOG_ERR, "socket6: %m");
+ dolog(LOG_ERR, "socket6: %m");
sr->so = -1;
return (-1);
}
@@ -2109,9 +2112,9 @@ netlookup6(DB *db, struct recurses *sr)
#endif
if (bind(sr->so, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
- syslog(LOG_ERR, "bind: %m");
+ dolog(LOG_ERR, "bind: %m");
if (close(sr->so) < 0) {
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = -1;
return (-1);
@@ -2122,17 +2125,17 @@ netlookup6(DB *db, struct recurses *sr)
*/
if ((flag = fcntl(sr->so, F_GETFL)) < 0) {
- syslog(LOG_INFO, "fcntl 3: %m");
+ dolog(LOG_INFO, "fcntl 3: %m");
}
flag |= O_NONBLOCK;
if (fcntl(sr->so, F_SETFL, flag) < 0) {
- syslog(LOG_INFO, "fcntl 4: %m");
+ dolog(LOG_INFO, "fcntl 4: %m");
}
if (lookup_ns(db, sr) <= 0) {
- syslog(LOG_ERR, "can't establish any servers to reach for zone \"%s\"", sr->question->converted_name);
+ dolog(LOG_ERR, "can't establish any servers to reach for zone \"%s\"", sr->question->converted_name);
if (close(sr->so) < 0) {
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = -1;
return (-1);
@@ -2156,14 +2159,14 @@ netlookup6(DB *db, struct recurses *sr)
dh->id = htons(sr->id);
#if 1
- syslog(LOG_INFO, "sending request with id %u\n", sr->id);
+ dolog(LOG_INFO, "sending request with id %u\n", sr->id);
#endif
if (sendto(sr->so, buf, sr->len, 0, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
- syslog(LOG_ERR, "sendto6: %m");
+ dolog(LOG_ERR, "sendto6: %m");
if (close(sr->so) < 0) {
- syslog(LOG_ERR, "close: %m");
+ dolog(LOG_ERR, "close: %m");
}
sr->so = -1;
return (-1);
@@ -2214,7 +2217,7 @@ lookup_aaaa(DB *db, struct recurses *sr, struct ns *ns
if (ret == 0) {
if (data.size != sizeof(struct domain)) {
- syslog(LOG_ERR, "btree db is damaged");
+ dolog(LOG_ERR, "btree db is damaged");
return (-1);
}
@@ -2230,7 +2233,7 @@ lookup_aaaa(DB *db, struct recurses *sr, struct ns *ns
}
if (! found) {
- syslog(LOG_DEBUG, "calling fakerecurse");
+ dolog(LOG_DEBUG, "calling fakerecurse");
fakerecurse(db, sr, ns, DNS_TYPE_AAAA);
return (-1);
}
blob - 1a547746724b5d7cd5eece33532f4950b5842fe8
blob + e033dfcb7ba885237379315788365a43fefa56fc
--- reply.c
+++ reply.c
@@ -55,6 +55,7 @@ extern struct question * build_fake_question(char *, i
extern int free_question(struct question *);
extern int lookup_zone(DB *, struct question *, struct domain *, int *, char *, int);
extern void slave_shutdown(void);
+extern void dolog(int, char *, ...);
void update_db(DB *, struct domain *);
struct domain * Lookup_zone(DB *db, char *name, u_int16_t namelen, u_int16_t type, int);
@@ -79,9 +80,11 @@ struct collects {
SLIST_ENTRY(collects) entries;
} *cn1, *cn2, *cnp;
+extern int debug, verbose;
-static const char rcsid[] = "$Id: reply.c,v 1.48 2013/02/16 11:47:30 pjp Exp $";
+static const char rcsid[] = "$Id: reply.c,v 1.49 2013/02/16 17:27:06 pjp Exp $";
+
/*
* REPLY_A() - replies a DNS question (*q) on socket (so)
*
@@ -215,7 +218,7 @@ out:
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -223,12 +226,12 @@ out:
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
@@ -353,7 +356,7 @@ out:
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -361,12 +364,12 @@ out:
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -555,19 +558,19 @@ out:
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -788,19 +791,19 @@ out:
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -972,7 +975,7 @@ reply_cname(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -980,12 +983,12 @@ reply_cname(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -1108,7 +1111,7 @@ reply_ptr(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -1116,12 +1119,12 @@ reply_ptr(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -1321,7 +1324,7 @@ reply_soa(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -1329,12 +1332,12 @@ reply_soa(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -1436,7 +1439,7 @@ reply_txt(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -1444,12 +1447,12 @@ reply_txt(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -1641,19 +1644,19 @@ out:
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -1711,7 +1714,7 @@ reply_notimpl(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -1719,12 +1722,12 @@ reply_notimpl(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, len, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
@@ -1816,7 +1819,7 @@ reply_nxdomain(struct sreply *sreply)
tmpbuf = malloc(len + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(len);
@@ -1824,12 +1827,12 @@ reply_nxdomain(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, len);
if (send(so, tmpbuf, len + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, len, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -1978,7 +1981,7 @@ reply_nxdomain(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -1986,12 +1989,12 @@ reply_nxdomain(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
} /* sreply->sr.. */
@@ -2042,7 +2045,7 @@ reply_fmterror(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -2050,12 +2053,12 @@ reply_fmterror(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, sizeof(struct dns_header), 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
@@ -2141,7 +2144,7 @@ reply_noerror(struct sreply *sreply)
tmpbuf = malloc(len + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(len);
@@ -2149,12 +2152,12 @@ reply_noerror(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, len);
if (send(so, tmpbuf, len + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, len, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
@@ -2294,7 +2297,7 @@ reply_noerror(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -2302,12 +2305,12 @@ reply_noerror(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
@@ -2325,7 +2328,7 @@ update_db(DB *db, struct domain *sd)
do {
if (++i == 32) {
- syslog(LOG_ERR, "could not update zone for 32 tries, giving up entire database, quit");
+ dolog(LOG_ERR, "could not update zone for 32 tries, giving up entire database, quit");
slave_shutdown();
exit(1);
}
@@ -2366,13 +2369,13 @@ Lookup_zone(DB *db, char *name, u_int16_t namelen, u_i
fakequestion = build_fake_question(name, namelen, type);
if (fakequestion == NULL) {
- syslog(LOG_INFO, "fakequestion(2) failed");
+ dolog(LOG_INFO, "fakequestion(2) failed\n");
return (NULL);
}
sd = calloc(sizeof(struct domain), 1);
if (sd == NULL) {
- syslog(LOG_INFO, "calloc: %m");
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
free_question(fakequestion);
return (NULL);
}
@@ -2495,7 +2498,7 @@ reply_raw2(int so, char *reply, int outlen, struct rec
#else
if (sendto(so, buf, sizeof(struct ip) + udplen, 0, (struct sockaddr *)(&sr->dest), sizeof(struct sockaddr)) < 0) {
#endif
- syslog(LOG_ERR, "sendto: %m");
+ dolog(LOG_ERR, "sendto: %s\n", strerror(errno));
}
}
@@ -2540,7 +2543,7 @@ reply_raw6(int so, char *reply, int outlen, struct rec
memcpy((char *)&sin6.sin6_addr, (char *)&sin_dst->sin6_addr, sizeof(struct in6_addr));
if (bind(so, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
- syslog(LOG_ERR, "bind6: %m");
+ dolog(LOG_ERR, "bind6: %s\n", strerror(errno));
return;
}
@@ -2568,7 +2571,7 @@ reply_raw6(int so, char *reply, int outlen, struct rec
if (sendto(so, buf, udplen, 0, (struct sockaddr *)(&sr->dest), sizeof(struct sockaddr_in6)) < 0) {
- syslog(LOG_ERR, "sendto: %m");
+ dolog(LOG_ERR, "sendto: %s\n", strerror(errno));
}
}
@@ -2724,7 +2727,7 @@ reply_any(struct sreply *sreply)
tmpbuf = malloc(outlen + 2);
if (tmpbuf == NULL) {
- syslog(LOG_INFO, "malloc: %m");
+ dolog(LOG_INFO, "malloc: %s\n", strerror(errno));
}
plen = (u_int16_t *)tmpbuf;
*plen = htons(outlen);
@@ -2732,12 +2735,12 @@ reply_any(struct sreply *sreply)
memcpy(&tmpbuf[2], reply, outlen);
if (send(so, tmpbuf, outlen + 2, 0) < 0) {
- syslog(LOG_INFO, "send: %m");
+ dolog(LOG_INFO, "send: %s\n", strerror(errno));
}
free(tmpbuf);
} else {
if (sendto(so, reply, outlen, 0, sa, salen) < 0) {
- syslog(LOG_INFO, "sendto: %m");
+ dolog(LOG_INFO, "sendto: %s\n", strerror(errno));
}
}
}
blob - b7bd7b870086d2a0a5aedbcc8a290d5e8f17a216
blob + 32311e889ed994cba7a4b211c21da45230640beb
--- wildcarddnsd.8
+++ wildcarddnsd.8
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 19, 2011
+.Dd February 16, 2013
.Dt WILDCARDDNSD 8
.Os
.Sh NAME
@@ -31,19 +31,16 @@
.Nd the Wildcard DNS daemon
.Sh SYNOPSIS
.Nm wildcarddnsd
-.Oo
.Op Fl b Ar address
-.Op ...
-.Oc
.Op Fl c Ar size
+.Op Fl d
.Op Fl f Ar file
-.Oo
.Op Fl i Ar interface
-.Op ...
-.Oc
.Op Fl l
.Op Fl n Ar instances
.Op Fl p Ar port
+.Op Fl r
+.Op Fl v
.Sh DESCRIPTION
.Nm
is the daemon that runs Wildcard DNS.
@@ -70,6 +67,12 @@ not be used in conjunction with
Specifies a size in bytes for the SYSV shared memory cache that DB4 is
using.
.It Xo
+.Fl d
+Turn on debug mode.
+.Nm
+does not fork into the background with this. Messages are printed in the
+foreground.
+.It Xo
.Fl f
.Ar file
.Xc
@@ -87,7 +90,7 @@ should listen on. This option can be specified multip
used in conjunction with
.Fl b .
.It Fl l
-Turn syslog logging of queries on.
+Turn logging of queries on.
.It Xo
.Fl n
.Ar instances
@@ -105,7 +108,15 @@ that
should listen on. This can be useful when using
.Nm
with
-.Xr pf 4 .
+.Xr pf 4
+.It Xo
+.Fl r
+.Xc
+Go into recursive mode. This is broken, please don't use.
+.It Xo
+.Fl v
+.Xc
+Be more verbose in debug mode. This shows configfile parsing logic.
.El
.Sh FILES
.Pa /etc/wildcarddns.conf
repomaster@centroid.eu