Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148131158
D6703.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D6703.diff
View Options
Index: head/libexec/ftpd/Makefile
===================================================================
--- head/libexec/ftpd/Makefile
+++ head/libexec/ftpd/Makefile
@@ -24,6 +24,13 @@
CFLAGS+=-Dmain=ls_main -I${.CURDIR}/${LSDIR}
LIBADD+= m
+.if ${MK_BLACKLIST_SUPPORT} != "no"
+CFLAGS+= -DUSE_BLACKLIST -I${SRCTOP}/contrib/blacklist/include
+SRCS+= blacklist.c
+LIBADD+= blacklist
+LDFLAGS+=-L${LIBBLACKLISTDIR}
+.endif
+
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+=-DINET6
.endif
Index: head/libexec/ftpd/blacklist.c
===================================================================
--- head/libexec/ftpd/blacklist.c
+++ head/libexec/ftpd/blacklist.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2016 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Kurt Lidl under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE. */
+
+/* $FreeBSD$ */
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "blacklist_client.h"
+#include <blacklist.h>
+
+static struct blacklist *blstate;
+
+void
+blacklist_init(void)
+{
+ blstate = blacklist_open();
+}
+
+void
+blacklist_notify(int action, int fd, char *msg)
+{
+ if (blstate == NULL)
+ blacklist_init();
+ if (blstate == NULL)
+ return;
+ (void)blacklist_r(blstate, action, fd, msg);
+}
Index: head/libexec/ftpd/blacklist_client.h
===================================================================
--- head/libexec/ftpd/blacklist_client.h
+++ head/libexec/ftpd/blacklist_client.h
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2016 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Kurt Lidl under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE. */
+
+/* $FreeBSD$ */
+
+void blacklist_notify(int, int, char *);
+void blacklist_init(void);
Index: head/libexec/ftpd/ftpd.c
===================================================================
--- head/libexec/ftpd/ftpd.c
+++ head/libexec/ftpd/ftpd.c
@@ -93,6 +93,10 @@
#include <security/pam_appl.h>
#endif
+#ifdef USE_BLACKLIST
+#include "blacklist_client.h"
+#endif
+
#include "pathnames.h"
#include "extern.h"
@@ -640,6 +644,9 @@
reply(220, "%s FTP server (%s) ready.", hostname, version);
else
reply(220, "FTP server ready.");
+#ifdef USE_BLACKLIST
+ blacklist_init();
+#endif
for (;;)
(void) yyparse();
/* NOTREACHED */
@@ -1415,6 +1422,9 @@
*/
if (rval) {
reply(530, "Login incorrect.");
+#ifdef USE_BLACKLIST
+ blacklist_notify(1, 0, "Login incorrect");
+#endif
if (logging) {
syslog(LOG_NOTICE,
"FTP LOGIN FAILED FROM %s",
@@ -1432,6 +1442,11 @@
}
return;
}
+#ifdef USE_BLACKLIST
+ else {
+ blacklist_notify(0, 0, "Login successful");
+ }
+#endif
}
login_attempts = 0; /* this time successful */
if (setegid(pw->pw_gid) < 0) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 17, 12:20 AM (15 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29796761
Default Alt Text
D6703.diff (5 KB)
Attached To
Mode
D6703: Add blacklist support to ftpd
Attached
Detach File
Event Timeline
Log In to Comment