1*53a984a3SEd Maste--- /dev/null	2015-01-23 17:30:40.000000000 -0500
2*53a984a3SEd Maste+++ pfilter.c	2015-01-23 17:12:02.000000000 -0500
3*53a984a3SEd Maste@@ -0,0 +1,24 @@
4*53a984a3SEd Maste+#include <stdio.h>
5*53a984a3SEd Maste+#include <blacklist.h>
6*53a984a3SEd Maste+
7*53a984a3SEd Maste+#include "pfilter.h"
8*53a984a3SEd Maste+
9*53a984a3SEd Maste+static struct blacklist *blstate;
10*53a984a3SEd Maste+
11*53a984a3SEd Maste+void
12*53a984a3SEd Maste+pfilter_open(void)
13*53a984a3SEd Maste+{
14*53a984a3SEd Maste+	if (blstate == NULL)
15*53a984a3SEd Maste+		blstate = blacklist_open();
16*53a984a3SEd Maste+}
17*53a984a3SEd Maste+
18*53a984a3SEd Maste+void
19*53a984a3SEd Maste+pfilter_notify(int what, const char *msg)
20*53a984a3SEd Maste+{
21*53a984a3SEd Maste+	pfilter_open();
22*53a984a3SEd Maste+
23*53a984a3SEd Maste+	if (blstate == NULL)
24*53a984a3SEd Maste+		return;
25*53a984a3SEd Maste+
26*53a984a3SEd Maste+	blacklist_r(blstate, what, 0, msg);
27*53a984a3SEd Maste+}
28*53a984a3SEd Maste--- /dev/null	2015-01-23 17:30:40.000000000 -0500
29*53a984a3SEd Maste+++ pfilter.h	2015-01-23 17:07:25.000000000 -0500
30*53a984a3SEd Maste@@ -0,0 +1,2 @@
31*53a984a3SEd Maste+void pfilter_open(void);
32*53a984a3SEd Maste+void pfilter_notify(int, const char *);
33*53a984a3SEd MasteIndex: Makefile
34*53a984a3SEd Maste===================================================================
35*53a984a3SEd MasteRCS file: /cvsroot/src/libexec/ftpd/Makefile,v
36*53a984a3SEd Masteretrieving revision 1.63
37*53a984a3SEd Mastediff -u -p -u -r1.63 Makefile
38*53a984a3SEd Maste--- Makefile	14 Aug 2011 11:46:28 -0000	1.63
39*53a984a3SEd Maste+++ Makefile	23 Jan 2015 22:32:20 -0000
40*53a984a3SEd Maste@@ -11,6 +11,10 @@ LDADD+=	-lcrypt -lutil
41*53a984a3SEd Maste MAN=	ftpd.conf.5 ftpusers.5 ftpd.8
42*53a984a3SEd Maste MLINKS=	ftpusers.5 ftpchroot.5
43*53a984a3SEd Maste
44*53a984a3SEd Maste+SRCS+=	pfilter.c
45*53a984a3SEd Maste+LDADD+=	-lblacklist
46*53a984a3SEd Maste+DPADD+=	${LIBBLACKLIST}
47*53a984a3SEd Maste+
48*53a984a3SEd Maste .if defined(NO_INTERNAL_LS)
49*53a984a3SEd Maste CPPFLAGS+=-DNO_INTERNAL_LS
50*53a984a3SEd Maste .else
51*53a984a3SEd MasteIndex: ftpd.c
52*53a984a3SEd Maste===================================================================
53*53a984a3SEd MasteRCS file: /cvsroot/src/libexec/ftpd/ftpd.c,v
54*53a984a3SEd Masteretrieving revision 1.200
55*53a984a3SEd Mastediff -u -p -u -r1.200 ftpd.c
56*53a984a3SEd Maste--- ftpd.c	31 Jul 2013 19:50:47 -0000	1.200
57*53a984a3SEd Maste+++ ftpd.c	23 Jan 2015 22:32:20 -0000
58*53a984a3SEd Maste@@ -165,6 +165,8 @@ __RCSID("$NetBSD: ftpd.c,v 1.200 2013/07
59*53a984a3SEd Maste #include <security/pam_appl.h>
60*53a984a3SEd Maste #endif
61*53a984a3SEd Maste
62*53a984a3SEd Maste+#include "pfilter.h"
63*53a984a3SEd Maste+
64*53a984a3SEd Maste #define	GLOBAL
65*53a984a3SEd Maste #include "extern.h"
66*53a984a3SEd Maste #include "pathnames.h"
67*53a984a3SEd Maste@@ -471,6 +473,8 @@ main(int argc, char *argv[])
68*53a984a3SEd Maste 	if (EMPTYSTR(confdir))
69*53a984a3SEd Maste 		confdir = _DEFAULT_CONFDIR;
70*53a984a3SEd Maste
71*53a984a3SEd Maste+	pfilter_open();
72*53a984a3SEd Maste+
73*53a984a3SEd Maste 	if (dowtmp) {
74*53a984a3SEd Maste #ifdef SUPPORT_UTMPX
75*53a984a3SEd Maste 		ftpd_initwtmpx();
76*53a984a3SEd Maste@@ -1401,6 +1405,7 @@ do_pass(int pass_checked, int pass_rval,
77*53a984a3SEd Maste 		if (rval) {
78*53a984a3SEd Maste 			reply(530, "%s", rval == 2 ? "Password expired." :
79*53a984a3SEd Maste 			    "Login incorrect.");
80*53a984a3SEd Maste+			pfilter_notify(1, rval == 2 ? "exppass" : "badpass");
81*53a984a3SEd Maste 			if (logging) {
82*53a984a3SEd Maste 				syslog(LOG_NOTICE,
83*53a984a3SEd Maste 				    "FTP LOGIN FAILED FROM %s", remoteloghost);
84*53a984a3SEd Maste@@ -1444,6 +1449,7 @@ do_pass(int pass_checked, int pass_rval,
85*53a984a3SEd Maste 				*remote_ip = 0;
86*53a984a3SEd Maste 		remote_ip[sizeof(remote_ip) - 1] = 0;
87*53a984a3SEd Maste 		if (!auth_hostok(lc, remotehost, remote_ip)) {
88*53a984a3SEd Maste+			pfilter_notify(1, "bannedhost");
89*53a984a3SEd Maste 			syslog(LOG_INFO|LOG_AUTH,
90*53a984a3SEd Maste 			    "FTP LOGIN FAILED (HOST) as %s: permission denied.",
91*53a984a3SEd Maste 			    pw->pw_name);
92