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.
This commit is contained in:
martin 2023-12-30 18:24:50 +00:00
parent 8a031694f2
commit 3ef19c3972
1 changed files with 13 additions and 3 deletions

View File

@ -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