svn commit: r306508 - head/contrib/blacklist/bin

Kurt Lidl lidl at FreeBSD.org
Fri Sep 30 16:35:31 UTC 2016


Author: lidl
Date: Fri Sep 30 16:35:30 2016
New Revision: 306508
URL: https://svnweb.freebsd.org/changeset/base/306508

Log:
  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

Modified:
  head/contrib/blacklist/bin/blacklistd.c
  head/contrib/blacklist/bin/state.c

Modified: head/contrib/blacklist/bin/blacklistd.c
==============================================================================
--- head/contrib/blacklist/bin/blacklistd.c	Fri Sep 30 16:31:12 2016	(r306507)
+++ head/contrib/blacklist/bin/blacklistd.c	Fri Sep 30 16:35:30 2016	(r306508)
@@ -1,4 +1,4 @@
-/*	$NetBSD: blacklistd.c,v 1.34 2016/04/04 15:52:56 christos Exp $	*/
+/*	$NetBSD: blacklistd.c,v 1.35 2016/09/26 19:43:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "config.h"
 #endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistd.c,v 1.34 2016/04/04 15:52:56 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.35 2016/09/26 19:43:43 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -473,9 +473,6 @@ main(int argc, char *argv[])
 		flags |= O_TRUNC;
 	}
 
-	if (restore)
-		rules_restore();
-
 	struct pollfd *pfd = NULL;
 	bl_t *bl = NULL;
 	size_t nfd = 0;
@@ -500,6 +497,9 @@ main(int argc, char *argv[])
 	if (state == NULL)
 		return EXIT_FAILURE;
 
+	if (restore)
+		rules_restore();
+
 	if (!debug) {
 		if (daemon(0, 0) == -1)
 			err(EXIT_FAILURE, "daemon failed");

Modified: head/contrib/blacklist/bin/state.c
==============================================================================
--- head/contrib/blacklist/bin/state.c	Fri Sep 30 16:31:12 2016	(r306507)
+++ head/contrib/blacklist/bin/state.c	Fri Sep 30 16:35:30 2016	(r306508)
@@ -1,4 +1,4 @@
-/*	$NetBSD: state.c,v 1.18 2016/04/04 15:52:56 christos Exp $	*/
+/*	$NetBSD: state.c,v 1.19 2016/09/26 19:43:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: state.c,v 1.18 2016/04/04 15:52:56 christos Exp $");
+__RCSID("$NetBSD: state.c,v 1.19 2016/09/26 19:43:43 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -200,8 +200,10 @@ state_iterate(DB *db, struct conf *c, st
 	int rv;
 	DBT k, v;
 
-	if (db == NULL)
+	if (db == NULL) {
+		(*lfun)(LOG_ERR, "%s: called with no database file", __func__);
 		return -1;
+	}
 
 	first = first ? R_FIRST : R_NEXT;
 


More information about the svn-src-all mailing list