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