From owner-svn-src-all@freebsd.org Fri Oct 7 02:33:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62BA7BED8DC; Fri, 7 Oct 2016 02:33:46 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25C14EDC; Fri, 7 Oct 2016 02:33:46 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u972Xjxg096867; Fri, 7 Oct 2016 02:33:45 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u972XjGO096865; Fri, 7 Oct 2016 02:33:45 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201610070233.u972XjGO096865@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Fri, 7 Oct 2016 02:33:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306799 - stable/11/contrib/blacklist/bin X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2016 02:33:46 -0000 Author: lidl Date: Fri Oct 7 02:33:45 2016 New Revision: 306799 URL: https://svnweb.freebsd.org/changeset/base/306799 Log: MFC r306508: 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. Sponsored by: The FreeBSD Foundation Modified: stable/11/contrib/blacklist/bin/blacklistd.c stable/11/contrib/blacklist/bin/state.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/blacklist/bin/blacklistd.c ============================================================================== --- stable/11/contrib/blacklist/bin/blacklistd.c Fri Oct 7 02:32:01 2016 (r306798) +++ stable/11/contrib/blacklist/bin/blacklistd.c Fri Oct 7 02:33:45 2016 (r306799) @@ -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 -__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 #include @@ -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: stable/11/contrib/blacklist/bin/state.c ============================================================================== --- stable/11/contrib/blacklist/bin/state.c Fri Oct 7 02:32:01 2016 (r306798) +++ stable/11/contrib/blacklist/bin/state.c Fri Oct 7 02:33:45 2016 (r306799) @@ -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 -__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 #include @@ -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;