xref: /freebsd-src/contrib/blocklist/diff/proftpd.diff (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1*5f4c09ddSEd Maste--- Make.rules.in.orig	2015-05-27 20:25:54.000000000 -0400
2*5f4c09ddSEd Maste+++ Make.rules.in	2016-01-25 21:48:47.000000000 -0500
3*5f4c09ddSEd Maste@@ -110,3 +110,8 @@
4*5f4c09ddSEd Maste
5*5f4c09ddSEd Maste FTPWHO_OBJS=ftpwho.o scoreboard.o misc.o
6*5f4c09ddSEd Maste BUILD_FTPWHO_OBJS=utils/ftpwho.o utils/scoreboard.o utils/misc.o
7*5f4c09ddSEd Maste+
8*5f4c09ddSEd Maste+CPPFLAGS+=-DHAVE_BLACKLIST
9*5f4c09ddSEd Maste+LIBS+=-lblacklist
10*5f4c09ddSEd Maste+OBJS+= pfilter.o
11*5f4c09ddSEd Maste+BUILD_OBJS+= src/pfilter.o
12*5f4c09ddSEd Maste--- /dev/null	2016-01-22 17:30:55.000000000 -0500
13*5f4c09ddSEd Maste+++ include/pfilter.h	2016-01-22 16:18:33.000000000 -0500
14*5f4c09ddSEd Maste@@ -0,0 +1,3 @@
15*5f4c09ddSEd Maste+
16*5f4c09ddSEd Maste+void pfilter_notify(int);
17*5f4c09ddSEd Maste+void pfilter_init(void);
18*5f4c09ddSEd Maste--- modules/mod_auth.c.orig	2015-05-27 20:25:54.000000000 -0400
19*5f4c09ddSEd Maste+++ modules/mod_auth.c	2016-01-22 16:21:06.000000000 -0500
20*5f4c09ddSEd Maste@@ -30,6 +30,7 @@
21*5f4c09ddSEd Maste
22*5f4c09ddSEd Maste #include "conf.h"
23*5f4c09ddSEd Maste #include "privs.h"
24*5f4c09ddSEd Maste+#include "pfilter.h"
25*5f4c09ddSEd Maste
26*5f4c09ddSEd Maste extern pid_t mpid;
27*5f4c09ddSEd Maste
28*5f4c09ddSEd Maste@@ -84,6 +85,8 @@
29*5f4c09ddSEd Maste     _("Login timeout (%d %s): closing control connection"), TimeoutLogin,
30*5f4c09ddSEd Maste     TimeoutLogin != 1 ? "seconds" : "second");
31*5f4c09ddSEd Maste
32*5f4c09ddSEd Maste+  pfilter_notify(1);
33*5f4c09ddSEd Maste+
34*5f4c09ddSEd Maste   /* It's possible that any listeners of this event might terminate the
35*5f4c09ddSEd Maste    * session process themselves (e.g. mod_ban).  So write out that the
36*5f4c09ddSEd Maste    * TimeoutLogin has been exceeded to the log here, in addition to the
37*5f4c09ddSEd Maste@@ -913,6 +916,7 @@
38*5f4c09ddSEd Maste         pr_memscrub(pass, strlen(pass));
39*5f4c09ddSEd Maste       }
40*5f4c09ddSEd Maste
41*5f4c09ddSEd Maste+      pfilter_notify(1);
42*5f4c09ddSEd Maste       pr_log_auth(PR_LOG_NOTICE, "SECURITY VIOLATION: Root login attempted");
43*5f4c09ddSEd Maste       return 0;
44*5f4c09ddSEd Maste     }
45*5f4c09ddSEd Maste@@ -1726,6 +1730,7 @@
46*5f4c09ddSEd Maste   return 1;
47*5f4c09ddSEd Maste
48*5f4c09ddSEd Maste auth_failure:
49*5f4c09ddSEd Maste+  pfilter_notify(1);
50*5f4c09ddSEd Maste   if (pass)
51*5f4c09ddSEd Maste     pr_memscrub(pass, strlen(pass));
52*5f4c09ddSEd Maste   session.user = session.group = NULL;
53*5f4c09ddSEd Maste--- src/main.c.orig	2016-01-22 17:36:43.000000000 -0500
54*5f4c09ddSEd Maste+++ src/main.c	2016-01-22 17:37:58.000000000 -0500
55*5f4c09ddSEd Maste@@ -49,6 +49,7 @@
56*5f4c09ddSEd Maste #endif
57*5f4c09ddSEd Maste
58*5f4c09ddSEd Maste #include "privs.h"
59*5f4c09ddSEd Maste+#include "pfilter.h"
60*5f4c09ddSEd Maste
61*5f4c09ddSEd Maste int (*cmd_auth_chk)(cmd_rec *);
62*5f4c09ddSEd Maste void (*cmd_handler)(server_rec *, conn_t *);
63*5f4c09ddSEd Maste@@ -1050,6 +1051,7 @@
64*5f4c09ddSEd Maste   pid_t pid;
65*5f4c09ddSEd Maste   sigset_t sig_set;
66*5f4c09ddSEd Maste
67*5f4c09ddSEd Maste+  pfilter_init();
68*5f4c09ddSEd Maste   if (!nofork) {
69*5f4c09ddSEd Maste
70*5f4c09ddSEd Maste     /* A race condition exists on heavily loaded servers where the parent
71*5f4c09ddSEd Maste@@ -1169,7 +1171,8 @@
72*5f4c09ddSEd Maste
73*5f4c09ddSEd Maste   /* Reseed pseudo-randoms */
74*5f4c09ddSEd Maste   srand((unsigned int) (time(NULL) * getpid()));
75*5f4c09ddSEd Maste-
76*5f4c09ddSEd Maste+#else
77*5f4c09ddSEd Maste+  pfilter_init();
78*5f4c09ddSEd Maste #endif /* PR_DEVEL_NO_FORK */
79*5f4c09ddSEd Maste
80*5f4c09ddSEd Maste   /* Child is running here */
81*5f4c09ddSEd Maste--- /dev/null	2016-01-22 17:30:55.000000000 -0500
82*5f4c09ddSEd Maste+++ src/pfilter.c	2016-01-22 16:37:55.000000000 -0500
83*5f4c09ddSEd Maste@@ -0,0 +1,41 @@
84*5f4c09ddSEd Maste+#include "pfilter.h"
85*5f4c09ddSEd Maste+#include "conf.h"
86*5f4c09ddSEd Maste+#include "privs.h"
87*5f4c09ddSEd Maste+#ifdef HAVE_BLACKLIST
88*5f4c09ddSEd Maste+#include <blacklist.h>
89*5f4c09ddSEd Maste+#endif
90*5f4c09ddSEd Maste+
91*5f4c09ddSEd Maste+static struct blacklist *blstate;
92*5f4c09ddSEd Maste+
93*5f4c09ddSEd Maste+void
94*5f4c09ddSEd Maste+pfilter_init(void)
95*5f4c09ddSEd Maste+{
96*5f4c09ddSEd Maste+#ifdef HAVE_BLACKLIST
97*5f4c09ddSEd Maste+	if (blstate == NULL)
98*5f4c09ddSEd Maste+		blstate = blacklist_open();
99*5f4c09ddSEd Maste+#endif
100*5f4c09ddSEd Maste+}
101*5f4c09ddSEd Maste+
102*5f4c09ddSEd Maste+void
103*5f4c09ddSEd Maste+pfilter_notify(int a)
104*5f4c09ddSEd Maste+{
105*5f4c09ddSEd Maste+#ifdef HAVE_BLACKLIST
106*5f4c09ddSEd Maste+	conn_t *c = session.c;
107*5f4c09ddSEd Maste+	int fd;
108*5f4c09ddSEd Maste+
109*5f4c09ddSEd Maste+	if (c == NULL)
110*5f4c09ddSEd Maste+		return;
111*5f4c09ddSEd Maste+	if (c->rfd != -1)
112*5f4c09ddSEd Maste+		fd = c->rfd;
113*5f4c09ddSEd Maste+	else if (c->wfd != -1)
114*5f4c09ddSEd Maste+		fd = c->wfd;
115*5f4c09ddSEd Maste+	else
116*5f4c09ddSEd Maste+		return;
117*5f4c09ddSEd Maste+
118*5f4c09ddSEd Maste+	if (blstate == NULL)
119*5f4c09ddSEd Maste+		pfilter_init();
120*5f4c09ddSEd Maste+	if (blstate == NULL)
121*5f4c09ddSEd Maste+		return;
122*5f4c09ddSEd Maste+	(void)blacklist_r(blstate, a, fd, "proftpd");
123*5f4c09ddSEd Maste+#endif
124*5f4c09ddSEd Maste+}
125