diff options
| author | Jose Luis Duran <jlduran@FreeBSD.org> | 2025-12-16 01:01:50 +0000 |
|---|---|---|
| committer | Jose Luis Duran <jlduran@FreeBSD.org> | 2025-12-16 01:01:50 +0000 |
| commit | bfef098f924950a085927b1e7dd6c6db4e651c5c (patch) | |
| tree | b635f880af714266adcae9ae9338d1e93e8abfe0 | |
| parent | df549a80425635d98419f7f742309d66d367e65f (diff) | |
Vendor import of blocklist 2025-12-15 (8a4b011)vendor/blocklist/20251215vendor/blocklist
Upstream hash 8a4b011dec375ee695b1a72f1ea57394670f359d.
Obtained from: https://github.com/zoulasc/blocklist
| -rw-r--r-- | bin/blocklistd.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/bin/blocklistd.c b/bin/blocklistd.c index 7c39f00106f4..a995fd527eb2 100644 --- a/bin/blocklistd.c +++ b/bin/blocklistd.c @@ -1,4 +1,4 @@ -/* $NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $ */ +/* $NetBSD: blocklistd.c,v 1.14 2025/12/15 15:51:37 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #ifdef HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $"); +__RCSID("$NetBSD: blocklistd.c,v 1.14 2025/12/15 15:51:37 christos Exp $"); #include <sys/types.h> #include <sys/socket.h> @@ -191,12 +191,13 @@ process(bl_t bl) } if (getremoteaddress(bi, &rss, &rsl) == -1) - return; + goto out; if (debug || bi->bi_msg[0]) { sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss); (*lfun)(bi->bi_msg[0] ? LOG_INFO : LOG_DEBUG, - "processing type=%d fd=%d remote=%s msg=\"%s\" uid=%lu gid=%lu", + "processing type=%d fd=%d remote=%s msg=\"%s\" " + "uid=%lu gid=%lu", bi->bi_type, bi->bi_fd, rbuf, bi->bi_msg, (unsigned long)bi->bi_uid, (unsigned long)bi->bi_gid); @@ -204,12 +205,12 @@ process(bl_t bl) if (conf_find(bi->bi_fd, bi->bi_uid, &rss, &c) == NULL) { (*lfun)(LOG_DEBUG, "no rule matched"); - return; + goto out; } if (state_get(state, &c, &dbi) == -1) - return; + goto out; if (debug) { char b1[128], b2[128]; @@ -269,6 +270,8 @@ process(bl_t bl) state_put(state, &c, &dbi); out: + close(bi->bi_fd); + if (debug) { char b1[128], b2[128]; (*lfun)(LOG_DEBUG, "%s: final db state for %s: count=%d/%d " @@ -541,15 +544,16 @@ main(int argc, char *argv[]) state = state_open(dbfile, flags, 0600); if (state == NULL) state = state_open(dbfile, flags | O_CREAT, 0600); + else { + if (restore) { + if (!flush) + rules_flush(); + rules_restore(); + } + } if (state == NULL) return EXIT_FAILURE; - if (restore) { - if (!flush) - rules_flush(); - rules_restore(); - } - if (!debug) { if (daemon(0, 0) == -1) err(EXIT_FAILURE, "daemon failed"); @@ -563,7 +567,7 @@ main(int argc, char *argv[]) conf_parse(configfile); } ret = poll(pfd, (nfds_t)nfd, tout); - if (debug && ret != 0) + if (debug) (*lfun)(LOG_DEBUG, "received %d from poll()", ret); switch (ret) { case -1: |
