Module Name:    src
Committed By:   martin
Date:           Mon Dec 25 18:59:46 UTC 2023

Modified Files:
        src/external/bsd/blocklist/bin [netbsd-10]: blocklistd.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #519):

        external/bsd/blocklist/bin/blocklistd.c: revision 1.4

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.3.2.1 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.3.2.1
--- src/external/bsd/blocklist/bin/blocklistd.c:1.3	Wed Oct 12 18:36:02 2022
+++ src/external/bsd/blocklist/bin/blocklistd.c	Mon Dec 25 18:59:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: blocklistd.c,v 1.3 2022/10/12 18:36:02 christos Exp $	*/
+/*	$NetBSD: blocklistd.c,v 1.3.2.1 2023/12/25 18:59:46 martin 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.3.2.1 2023/12/25 18:59:46 martin 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

Reply via email to