xref: /freebsd/contrib/blocklist/diff/named.diff (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1*5f4c09ddSEd Maste--- /dev/null	2015-01-22 01:48:00.000000000 -0500
2*5f4c09ddSEd Maste+++ dist/bin/named/pfilter.c	2015-01-22 01:35:16.000000000 -0500
3*5f4c09ddSEd Maste@@ -0,0 +1,42 @@
4*5f4c09ddSEd Maste+#include <config.h>
5*5f4c09ddSEd Maste+
6*5f4c09ddSEd Maste+#include <isc/platform.h>
7*5f4c09ddSEd Maste+#include <isc/util.h>
8*5f4c09ddSEd Maste+#include <named/types.h>
9*5f4c09ddSEd Maste+#include <named/client.h>
10*5f4c09ddSEd Maste+
11*5f4c09ddSEd Maste+#include <blacklist.h>
12*5f4c09ddSEd Maste+
13*5f4c09ddSEd Maste+#include "pfilter.h"
14*5f4c09ddSEd Maste+
15*5f4c09ddSEd Maste+static struct blacklist *blstate;
16*5f4c09ddSEd Maste+
17*5f4c09ddSEd Maste+void
18*5f4c09ddSEd Maste+pfilter_open(void)
19*5f4c09ddSEd Maste+{
20*5f4c09ddSEd Maste+	if (blstate == NULL)
21*5f4c09ddSEd Maste+		blstate = blacklist_open();
22*5f4c09ddSEd Maste+}
23*5f4c09ddSEd Maste+
24*5f4c09ddSEd Maste+#define TCP_CLIENT(c)  (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
25*5f4c09ddSEd Maste+
26*5f4c09ddSEd Maste+void
27*5f4c09ddSEd Maste+pfilter_notify(isc_result_t res, ns_client_t *client, const char *msg)
28*5f4c09ddSEd Maste+{
29*5f4c09ddSEd Maste+	isc_socket_t *socket;
30*5f4c09ddSEd Maste+
31*5f4c09ddSEd Maste+	pfilter_open();
32*5f4c09ddSEd Maste+
33*5f4c09ddSEd Maste+	if (TCP_CLIENT(client))
34*5f4c09ddSEd Maste+		socket = client->tcpsocket;
35*5f4c09ddSEd Maste+	else {
36*5f4c09ddSEd Maste+		socket = client->udpsocket;
37*5f4c09ddSEd Maste+		if (!client->peeraddr_valid)
38*5f4c09ddSEd Maste+			return;
39*5f4c09ddSEd Maste+	}
40*5f4c09ddSEd Maste+	if (socket == NULL)
41*5f4c09ddSEd Maste+		return;
42*5f4c09ddSEd Maste+	blacklist_sa_r(blstate,
43*5f4c09ddSEd Maste+	    res != ISC_R_SUCCESS, isc_socket_getfd(socket),
44*5f4c09ddSEd Maste+	    &client->peeraddr.type.sa, client->peeraddr.length, msg);
45*5f4c09ddSEd Maste+}
46*5f4c09ddSEd Maste--- /dev/null	2015-01-22 01:48:00.000000000 -0500
47*5f4c09ddSEd Maste+++ dist/bin/named/pfilter.h	2015-01-22 01:16:56.000000000 -0500
48*5f4c09ddSEd Maste@@ -0,0 +1,2 @@
49*5f4c09ddSEd Maste+void pfilter_open(void);
50*5f4c09ddSEd Maste+void pfilter_notify(isc_result_t, ns_client_t *, const char *);
51*5f4c09ddSEd MasteIndex: bin/named/Makefile
52*5f4c09ddSEd Maste===================================================================
53*5f4c09ddSEd MasteRCS file: /cvsroot/src/external/bsd/bind/bin/named/Makefile,v
54*5f4c09ddSEd Masteretrieving revision 1.8
55*5f4c09ddSEd Mastediff -u -u -r1.8 Makefile
56*5f4c09ddSEd Maste--- bin/named/Makefile	31 Dec 2013 20:23:12 -0000	1.8
57*5f4c09ddSEd Maste+++ bin/named/Makefile	23 Jan 2015 21:37:09 -0000
58*5f4c09ddSEd Maste@@ -33,7 +33,9 @@
59*5f4c09ddSEd Maste 	lwaddr.c lwdclient.c lwderror.c \
60*5f4c09ddSEd Maste 	lwdgabn.c lwdgnba.c lwdgrbn.c lwdnoop.c lwresd.c lwsearch.c \
61*5f4c09ddSEd Maste 	main.c notify.c query.c server.c sortlist.c statschannel.c \
62*5f4c09ddSEd Maste-	tkeyconf.c tsigconf.c \
63*5f4c09ddSEd Maste+	pfilter.c tkeyconf.c tsigconf.c \
64*5f4c09ddSEd Maste 	update.c xfrout.c zoneconf.c ${SRCS_UNIX}
65*5f4c09ddSEd Maste
66*5f4c09ddSEd Maste+LDADD+=-lblacklist
67*5f4c09ddSEd Maste+DPADD+=${LIBBLACKLIST}
68*5f4c09ddSEd Maste .include <bsd.prog.mk>
69*5f4c09ddSEd MasteIndex: dist/bin/named/client.c
70*5f4c09ddSEd Maste===================================================================
71*5f4c09ddSEd MasteRCS file: /cvsroot/src/external/bsd/bind/dist/bin/named/client.c,v
72*5f4c09ddSEd Masteretrieving revision 1.11
73*5f4c09ddSEd Mastediff -u -u -r1.11 client.c
74*5f4c09ddSEd Maste--- dist/bin/named/client.c	10 Dec 2014 04:37:51 -0000	1.11
75*5f4c09ddSEd Maste+++ dist/bin/named/client.c	23 Jan 2015 21:37:09 -0000
76*5f4c09ddSEd Maste@@ -65,6 +65,8 @@
77*5f4c09ddSEd Maste #include <named/server.h>
78*5f4c09ddSEd Maste #include <named/update.h>
79*5f4c09ddSEd Maste
80*5f4c09ddSEd Maste+#include "pfilter.h"
81*5f4c09ddSEd Maste+
82*5f4c09ddSEd Maste /***
83*5f4c09ddSEd Maste  *** Client
84*5f4c09ddSEd Maste  ***/
85*5f4c09ddSEd Maste@@ -3101,6 +3103,7 @@
86*5f4c09ddSEd Maste 	result = ns_client_checkaclsilent(client, sockaddr ? &netaddr : NULL,
87*5f4c09ddSEd Maste 					  acl, default_allow);
88*5f4c09ddSEd Maste
89*5f4c09ddSEd Maste+	pfilter_notify(result, client, opname);
90*5f4c09ddSEd Maste 	if (result == ISC_R_SUCCESS)
91*5f4c09ddSEd Maste 		ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
92*5f4c09ddSEd Maste 			      NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
93*5f4c09ddSEd MasteIndex: dist/bin/named/main.c
94*5f4c09ddSEd Maste===================================================================
95*5f4c09ddSEd MasteRCS file: /cvsroot/src/external/bsd/bind/dist/bin/named/main.c,v
96*5f4c09ddSEd Masteretrieving revision 1.15
97*5f4c09ddSEd Mastediff -u -u -r1.15 main.c
98*5f4c09ddSEd Maste--- dist/bin/named/main.c	10 Dec 2014 04:37:51 -0000	1.15
99*5f4c09ddSEd Maste+++ dist/bin/named/main.c	23 Jan 2015 21:37:09 -0000
100*5f4c09ddSEd Maste@@ -83,6 +83,9 @@
101*5f4c09ddSEd Maste #ifdef HAVE_LIBXML2
102*5f4c09ddSEd Maste #include <libxml/xmlversion.h>
103*5f4c09ddSEd Maste #endif
104*5f4c09ddSEd Maste+
105*5f4c09ddSEd Maste+#include "pfilter.h"
106*5f4c09ddSEd Maste+
107*5f4c09ddSEd Maste /*
108*5f4c09ddSEd Maste  * Include header files for database drivers here.
109*5f4c09ddSEd Maste  */
110*5f4c09ddSEd Maste@@ -1206,6 +1209,8 @@
111*5f4c09ddSEd Maste
112*5f4c09ddSEd Maste 	parse_command_line(argc, argv);
113*5f4c09ddSEd Maste
114*5f4c09ddSEd Maste+	pfilter_open();
115*5f4c09ddSEd Maste+
116*5f4c09ddSEd Maste 	/*
117*5f4c09ddSEd Maste 	 * Warn about common configuration error.
118*5f4c09ddSEd Maste 	 */
119*5f4c09ddSEd MasteIndex: dist/bin/named/query.c
120*5f4c09ddSEd Maste===================================================================
121*5f4c09ddSEd MasteRCS file: /cvsroot/src/external/bsd/bind/dist/bin/named/query.c,v
122*5f4c09ddSEd Masteretrieving revision 1.17
123*5f4c09ddSEd Mastediff -u -u -r1.17 query.c
124*5f4c09ddSEd Maste--- dist/bin/named/query.c	10 Dec 2014 04:37:52 -0000	1.17
125*5f4c09ddSEd Maste+++ dist/bin/named/query.c	23 Jan 2015 21:37:09 -0000
126*5f4c09ddSEd Maste@@ -65,6 +65,8 @@
127*5f4c09ddSEd Maste #include <named/sortlist.h>
128*5f4c09ddSEd Maste #include <named/xfrout.h>
129*5f4c09ddSEd Maste
130*5f4c09ddSEd Maste+#include "pfilter.h"
131*5f4c09ddSEd Maste+
132*5f4c09ddSEd Maste #if 0
133*5f4c09ddSEd Maste /*
134*5f4c09ddSEd Maste  * It has been recommended that DNS64 be changed to return excluded
135*5f4c09ddSEd Maste@@ -762,6 +764,8 @@
136*5f4c09ddSEd Maste 	}
137*5f4c09ddSEd Maste
138*5f4c09ddSEd Maste 	result = ns_client_checkaclsilent(client, NULL, queryacl, ISC_TRUE);
139*5f4c09ddSEd Maste+	if (result != ISC_R_SUCCESS)
140*5f4c09ddSEd Maste+		pfilter_notify(result, client, "validatezonedb");
141*5f4c09ddSEd Maste 	if ((options & DNS_GETDB_NOLOG) == 0) {
142*5f4c09ddSEd Maste 		char msg[NS_CLIENT_ACLMSGSIZE("query")];
143*5f4c09ddSEd Maste 		if (result == ISC_R_SUCCESS) {
144*5f4c09ddSEd Maste@@ -1026,6 +1030,8 @@
145*5f4c09ddSEd Maste 		result = ns_client_checkaclsilent(client, NULL,
146*5f4c09ddSEd Maste 						  client->view->cacheacl,
147*5f4c09ddSEd Maste 						  ISC_TRUE);
148*5f4c09ddSEd Maste+		if (result == ISC_R_SUCCESS)
149*5f4c09ddSEd Maste+			pfilter_notify(result, client, "cachedb");
150*5f4c09ddSEd Maste 		if (result == ISC_R_SUCCESS) {
151*5f4c09ddSEd Maste 			/*
152*5f4c09ddSEd Maste 			 * We were allowed by the "allow-query-cache" ACL.
153*5f4c09ddSEd MasteIndex: dist/bin/named/update.c
154*5f4c09ddSEd Maste===================================================================
155*5f4c09ddSEd MasteRCS file: /cvsroot/src/external/bsd/bind/dist/bin/named/update.c,v
156*5f4c09ddSEd Masteretrieving revision 1.9
157*5f4c09ddSEd Mastediff -u -u -r1.9 update.c
158*5f4c09ddSEd Maste--- dist/bin/named/update.c	10 Dec 2014 04:37:52 -0000	1.9
159*5f4c09ddSEd Maste+++ dist/bin/named/update.c	23 Jan 2015 21:37:09 -0000
160*5f4c09ddSEd Maste@@ -59,6 +59,8 @@
161*5f4c09ddSEd Maste #include <named/server.h>
162*5f4c09ddSEd Maste #include <named/update.h>
163*5f4c09ddSEd Maste
164*5f4c09ddSEd Maste+#include "pfilter.h"
165*5f4c09ddSEd Maste+
166*5f4c09ddSEd Maste /*! \file
167*5f4c09ddSEd Maste  * \brief
168*5f4c09ddSEd Maste  * This module implements dynamic update as in RFC2136.
169*5f4c09ddSEd Maste@@ -307,6 +309,7 @@
170*5f4c09ddSEd Maste
171*5f4c09ddSEd Maste 	result = ns_client_checkaclsilent(client, NULL, queryacl, ISC_TRUE);
172*5f4c09ddSEd Maste 	if (result != ISC_R_SUCCESS) {
173*5f4c09ddSEd Maste+		pfilter_notify(result, client, "queryacl");
174*5f4c09ddSEd Maste 		dns_name_format(zonename, namebuf, sizeof(namebuf));
175*5f4c09ddSEd Maste 		dns_rdataclass_format(client->view->rdclass, classbuf,
176*5f4c09ddSEd Maste 				      sizeof(classbuf));
177*5f4c09ddSEd Maste@@ -324,6 +327,7 @@
178*5f4c09ddSEd Maste 				      sizeof(classbuf));
179*5f4c09ddSEd Maste
180*5f4c09ddSEd Maste 		result = DNS_R_REFUSED;
181*5f4c09ddSEd Maste+		pfilter_notify(result, client, "updateacl");
182*5f4c09ddSEd Maste 		ns_client_log(client, NS_LOGCATEGORY_UPDATE_SECURITY,
183*5f4c09ddSEd Maste 			      NS_LOGMODULE_UPDATE, ISC_LOG_INFO,
184*5f4c09ddSEd Maste 			      "update '%s/%s' denied", namebuf, classbuf);
185*5f4c09ddSEd Maste@@ -362,6 +366,7 @@
186*5f4c09ddSEd Maste 		msg = "disabled";
187*5f4c09ddSEd Maste 	} else {
188*5f4c09ddSEd Maste 		result = ns_client_checkaclsilent(client, NULL, acl, ISC_FALSE);
189*5f4c09ddSEd Maste+		pfilter_notify(result, client, "updateacl");
190*5f4c09ddSEd Maste 		if (result == ISC_R_SUCCESS) {
191*5f4c09ddSEd Maste 			level = ISC_LOG_DEBUG(3);
192*5f4c09ddSEd Maste 			msg = "approved";
193*5f4c09ddSEd MasteIndex: dist/bin/named/xfrout.c
194*5f4c09ddSEd Maste===================================================================
195*5f4c09ddSEd MasteRCS file: /cvsroot/src/external/bsd/bind/dist/bin/named/xfrout.c,v
196*5f4c09ddSEd Masteretrieving revision 1.7
197*5f4c09ddSEd Mastediff -u -u -r1.7 xfrout.c
198*5f4c09ddSEd Maste--- dist/bin/named/xfrout.c	10 Dec 2014 04:37:52 -0000	1.7
199*5f4c09ddSEd Maste+++ dist/bin/named/xfrout.c	23 Jan 2015 21:37:09 -0000
200*5f4c09ddSEd Maste@@ -54,6 +54,8 @@
201*5f4c09ddSEd Maste #include <named/server.h>
202*5f4c09ddSEd Maste #include <named/xfrout.h>
203*5f4c09ddSEd Maste
204*5f4c09ddSEd Maste+#include "pfilter.h"
205*5f4c09ddSEd Maste+
206*5f4c09ddSEd Maste /*! \file
207*5f4c09ddSEd Maste  * \brief
208*5f4c09ddSEd Maste  * Outgoing AXFR and IXFR.
209*5f4c09ddSEd Maste@@ -822,6 +824,7 @@
210*5f4c09ddSEd Maste 						     &client->peeraddr,
211*5f4c09ddSEd Maste 						     &db);
212*5f4c09ddSEd Maste
213*5f4c09ddSEd Maste+			pfilter_notify(result, client, "zonexfr");
214*5f4c09ddSEd Maste 			if (result == ISC_R_NOPERM) {
215*5f4c09ddSEd Maste 				char _buf1[DNS_NAME_FORMATSIZE];
216*5f4c09ddSEd Maste 				char _buf2[DNS_RDATACLASS_FORMATSIZE];
217