Module Name: src
Committed By: martin
Date: Sat Dec 30 18:24:50 UTC 2023
Modified Files:
src/external/bsd/blacklist/bin [netbsd-9]: blacklistd.c
Log Message:
Pull up following revision(s) (requested by kim in ticket #1781):
external/bsd/blocklist/bin/blocklistd.c: revision 1.4
(applied to external/bsd/blacklist/bin/blacklistd.c)
PR/57767: Yoshitaka Tokugawa: When restoring, do so from a readonly copy
of the database and update the read-write copy with the new firewall ids.
Before we did not update the state file so it contained the old firewall ids.
To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.38.2.1 src/external/bsd/blacklist/bin/blacklistd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/blacklist/bin/blacklistd.c
diff -u src/external/bsd/blacklist/bin/blacklistd.c:1.38 src/external/bsd/blacklist/bin/blacklistd.c:1.38.2.1
--- src/external/bsd/blacklist/bin/blacklistd.c:1.38 Wed Feb 27 02:20:18 2019
+++ src/external/bsd/blacklist/bin/blacklistd.c Sat Dec 30 18:24:50 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $ */
+/* $NetBSD: blacklistd.c,v 1.38.2.1 2023/12/30 18:24:50 martin 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.38 2019/02/27 02:20:18 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.38.2.1 2023/12/30 18:24:50 martin Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -387,15 +387,25 @@ rules_flush(void)
static void
rules_restore(void)
{
+ DB *db;
struct conf c;
struct dbinfo dbi;
unsigned int f;
- for (f = 1; state_iterate(state, &c, &dbi, f) == 1; f = 0) {
+ db = state_open(dbfile, O_RDONLY, 0);
+ if (db == NULL) {
+ (*lfun)(LOG_ERR, "Can't open `%s' to restore state (%m)",
+ dbfile);
+ return;
+ }
+ for (f = 1; state_iterate(db, &c, &dbi, f) == 1; f = 0) {
if (dbi.id[0] == '\0')
continue;
(void)run_change("add", &c, dbi.id, sizeof(dbi.id));
+ state_put(state, &c, &dbi);
}
+ state_close(db);
+ state_sync(state);
}
int