Module Name: src Committed By: christos Date: Sat Dec 23 21:53:54 UTC 2023
Modified Files: src/external/bsd/blocklist/bin: blocklistd.c Log Message: 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.3 -r1.4 src/external/bsd/blocklist/bin/blocklistd.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/blocklist/bin/blocklistd.c diff -u src/external/bsd/blocklist/bin/blocklistd.c:1.3 src/external/bsd/blocklist/bin/blocklistd.c:1.4 --- src/external/bsd/blocklist/bin/blocklistd.c:1.3 Wed Oct 12 14:36:02 2022 +++ src/external/bsd/blocklist/bin/blocklistd.c Sat Dec 23 16:53:54 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: blocklistd.c,v 1.3 2022/10/12 18:36:02 christos Exp $ */ +/* $NetBSD: blocklistd.c,v 1.4 2023/12/23 21:53:54 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "config.h" #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: blocklistd.c,v 1.3 2022/10/12 18:36:02 christos Exp $"); +__RCSID("$NetBSD: blocklistd.c,v 1.4 2023/12/23 21:53:54 christos Exp $"); #include <sys/types.h> #include <sys/socket.h> @@ -395,15 +395,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