Commit Graph

26 Commits

Author SHA1 Message Date
Ed Maste
8089749d38 blacklistd: diff reduction against upstream
Add `conf_` prefix, maching https://github.com/zoulasc/blocklist

Sponsored by:	The FreeBSD Foundation
2023-01-23 11:22:10 -05:00
Jose Luis Duran
63f6075fcf blacklistd: Whitespace police
These were missed in the previous whitespace reduction.

Fixes:		631bdcf304 ("blacklistd: whitespace cleanup")
Obtained from:	https://github.com/zoulasc/blocklist
2022-10-13 08:47:56 -04:00
Jose Luis Duran
16d39eadf7 blacklistd: Don't remove a ruleset if we have already added it
The noted argument is wrong - if it's already been deleted then the id we
have for it is invalid.
Because we don't track deletions to the ruleset, working it out is
problematic at best.

Instead, if we have already added the rule treat it as a non-op.

This is a valid use case because we might receive a burst of messages
in the downstream application for the same address and process them
one by one. It's not the job of the downstream application to track
blacklistd state.

Obtained from:	959b18a604
2022-10-12 15:47:44 -04:00
Ed Maste
631bdcf304 blacklistd: whitespace cleanup
Diff reduction against NetBSD external/bsd/blacklist (at commit
03c74c04f277).

Sponsored by:	The FreeBSD Foundation
2022-10-12 13:41:44 -04:00
Jose Luis Duran
45c11d5401 blacklistd: Fix usage for blacklistd/blacklistctl
If getopt(3) encounters a character not found in optstring or if it
detects a missing option argument, it returns ? (question mark).

Obtained from:	 https://github.com/zoulasc/blocklist
Differential Revision:	https://reviews.freebsd.org/D36087
2022-10-12 10:30:12 -04:00
Jose Luis Duran
aa05c93cb7 blacklistd: Update documentation changes
Cherry-pick upstream documentation changes.

Obtained from:	 https://github.com/zoulasc/blocklist
Differential Revision:	https://reviews.freebsd.org/D36086
2022-10-12 09:27:08 -04:00
Ed Maste
36b1f67ca1 blacklistd.conf.5: typo/grammar fixes
PR:		246467
Submitted by:	Mike Lempriere
2020-05-19 00:15:19 +00:00
Ed Maste
c027e8cf48 blacklistd.8: fix db file path
PR:		245781
Submitted by:	Jose Luis Duran
MFC after:	3 days
2020-04-21 13:30:00 +00:00
Ed Maste
9999fa1cd0 blacklistd.conf.5: pluralization correction
Submitted by:	bcr in review D22259
MFC with:	r354399
2019-11-06 17:01:35 +00:00
Ed Maste
e3a90f49ad blacklist: update to NetBSD snapshot on 20191106
Cursory review:	cem
MFC after:	3 months
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22259
2019-11-06 16:21:35 +00:00
Ed Maste
6dc32306e9 blacklistd: remove reference to NetBSD npfctl
Xr pfctl instead.

PR:		221069
Submitted by:	"fml"
MFC after:	3 days
2019-10-22 18:30:51 +00:00
Kurt Lidl
ff92380399 Fixup syslog() call that should have used logging function pointer
PR:		236614
Submitted by:	Helge Oldach <freebsd@oldach.net>
2019-03-18 15:45:06 +00:00
Kurt Lidl
896571557d Document signal handling in blacklistd(8).
Reviewed by:	bcr@, 0mp@
Approved by:	re (gjb@)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D17423
2018-10-05 16:52:21 +00:00
Ruslan Bukin
7d729cedcc Revert 335888 ("Ensure va_list is declared by including stdarg.h.")
The issue was caused by header pollution brought by GCC 8.1.

We now have to remove include-fixed headers in the GCC installation
directory.

Sponsored by:	DARPA, AFRL
Pointed out by:	jhb
2018-07-03 15:48:34 +00:00
Ruslan Bukin
ab40f58ccf o Ensure va_list is declared by including stdarg.h.
o Also move printf.h to go after it since it does require declaration
  of va_list.

This fixes build with latest RISC-V GNU Toolchain with GCC 8.1

Sponsored by:	DARPA, AFRL
2018-07-03 13:53:54 +00:00
Conrad Meyer
bf799c28ff blacklist: Fix minor memory leak in configuration parsing error case
Ordinarily, the continue clause of the for-loop would free 'line.'  In this
case we instead return early, missing the free.  Add an explicit free to
avoid the leak.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-20 00:16:24 +00:00
Kurt Lidl
5de2cc52e9 Extend libblacklist support with new action types
The original blacklist library supported two notification types:
 - failed auth attempt, which incremented the failed login count
   by one for the remote address
 - successful auth attempt, which reset the failed login count
   to zero for that remote address

When the failed login count reached the limit in the configuration
file, the remote address would be blocked by a packet filter.

This patch implements a new notification type, "abusive behavior",
and accepts, but does not act on an additional type, "bad username".
It is envisioned that a system administrator will configure a small
list of "known bad usernames" that should be blocked immediately.

Reviewed by:	emaste
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D10604
2017-05-23 19:03:07 +00:00
Kurt Lidl
40935b566b Merge latest version of blacklist sources from NetBSD (@ 20170503)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2017-05-04 19:07:37 +00:00
Kurt Lidl
2495a63064 Reset failed login count to zero when removing a blocked address
The blacklistd daemon keeps records of failed login attempts for
each address:port that is flagged as a failed login.  When a
successful login occurs for that address:port combination,
the record's last update time is set to zero, to indicate no current
failed login attempts.

Reset the failed login count to zero, so that at the next failed
login attempt, the counting will restart properly at zero.  Without
this reset to zero, the first failed login after a successful login
will cause the address to be blocked immediately.

When debugging is turned on, output more information about database
state before and after the database updates have occured.

A similar patch has already been upstreamed to NetBSD.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2017-02-23 05:40:59 +00:00
Kurt Lidl
63ecbc6b55 Fix blacklistd's state restoral at startup
The blacklistd daemon attempted to restore the filtering rules
before the database of blocked addresses was opened, so no rules
were being reloaded.  Now the rules are properly recreated when the
daemon is started with '-r'.

This bug was fixed locally, and then sent upstream to NetBSD.
This changeset is the import the NetBSD version of the change,
which added debugging output to alert about a null database.

Reviewed by:	emaste
Obtained from:	NetBSD
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2016-09-30 16:35:30 +00:00
Kurt Lidl
0a1942cc0a Update blacklistd.8 with changes from NetBSD
Obtained from:	NetBSD
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8079
2016-09-30 16:31:12 +00:00
Renato Botelho
d87f5e3055 Move misplaced break statement to right place
Reported by:	Coverity
CID:		1304340
Reviewed by:	lidl
Differential Revision:	https://reviews.freebsd.org/D6749
Sponsored by:	Rubicon Communications (Netgate)
2016-06-08 11:58:03 +00:00
Kurt Lidl
04a83165f2 Bump dates in blacklist related manpages
Reported by:	araujo
Sponsored by:	The FreeBSD Foundation
2016-06-07 16:51:56 +00:00
Kurt Lidl
9349564fec Note blacklist support first appeared in FreeBSD 11
Reported by:	jbeich
Sponsored by:	The FreeBSD Foundation
2016-06-07 16:26:34 +00:00
Kurt Lidl
1d0f5925cd Fixup path in NetBSD supplied documentation for FreeBSD
NetBSD installs the blacklist-helper script in /libexec, and
it goes into /usr/libexec on FreeBSD.  Update the docs to
match FreeBSD's installation location.

Reviewed by:	rpaulo
Approved by:	rpaulo
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6592
2016-06-02 18:25:32 +00:00
Kurt Lidl
12017ca883 Import NetBSD's blacklist source from vendor tree
This import includes The basic blacklist library and utility programs,
to add a system-wide packet filtering notification mechanism to
FreeBSD.

The rational behind the daemon was given by Christos Zoulas in a
presentation at vBSDcon 2015: https://youtu.be/fuuf8G28mjs

Reviewed by:	rpaulo
Approved by:	rpaulo
Obtained from:	NetBSD
Relnotes:	YES
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5912
2016-06-01 22:04:10 +00:00