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