(state, &c, &dbi); > + } > + state_close(db); > + state_sync(state); > +} > + > +int > +main(int argc, char *argv[]) > +{ > + int c, tout, flags, flush, restore, ret; > + const char *spath, **blsock; > + size_t nblsock, maxblsock; > + > + setprogname(argv[0]); > + > + spath =3D NULL; > + blsock =3D NULL; > + maxblsock =3D nblsock =3D 0; > + flush =3D 0; > + restore =3D 0; > + tout =3D 0; > + flags =3D O_RDWR|O_EXCL|O_CLOEXEC; > + while ((c =3D getopt(argc, argv, "C:c:D:dfP:rR:s:t:v")) !=3D -1) = { > + switch (c) { > + case 'C': > + controlprog =3D optarg; > + break; > + case 'c': > + configfile =3D optarg; > + break; > + case 'D': > + dbfile =3D optarg; > + break; > + case 'd': > + debug++; > + break; > + case 'f': > + flush++; > + break; > + case 'P': > + spath =3D optarg; > + break; > + case 'R': > + rulename =3D optarg; > + break; > + case 'r': > + restore++; > + break; > + case 's': > + if (nblsock >=3D maxblsock) { > + maxblsock +=3D 10; > + void *p =3D realloc(blsock, > + sizeof(*blsock) * maxblsock); > + if (p =3D=3D NULL) > + err(EXIT_FAILURE, > + "Can't allocate memory for %zu so= ckets", > + maxblsock); > + blsock =3D p; > + } > + blsock[nblsock++] =3D optarg; > + break; > + case 't': > + tout =3D atoi(optarg) * 1000; > + break; > + case 'v': > + vflag++; > + break; > + default: > + usage(c); > + } > + } > + > + argc -=3D optind; > + if (argc) > + usage('?'); > + > + signal(SIGHUP, sighup); > + signal(SIGINT, sigdone); > + signal(SIGQUIT, sigdone); > + signal(SIGTERM, sigdone); > + signal(SIGUSR1, sigusr1); > + signal(SIGUSR2, sigusr2); > + > + openlog(getprogname(), LOG_PID, LOG_DAEMON); > + > + if (debug) { > + lfun =3D dlog; > + if (tout =3D=3D 0) > + tout =3D 5000; > + } else { > + if (tout =3D=3D 0) > + tout =3D 15000; > + } > + > + update_interfaces(); > + conf_parse(configfile); > + if (flush) { > + rules_flush(); > + if (!restore) > + flags |=3D O_TRUNC; > + } > + > + struct pollfd *pfd =3D NULL; > + bl_t *bl =3D NULL; > + size_t nfd =3D 0; > + size_t maxfd =3D 0; > + > + for (size_t i =3D 0; i < nblsock; i++) > + addfd(&pfd, &bl, &nfd, &maxfd, blsock[i]); > + free(blsock); > + > + if (spath) { > + FILE *fp =3D fopen(spath, "r"); > + char *line; > + if (fp =3D=3D NULL) > + err(EXIT_FAILURE, "Can't open `%s'", spath); > + for (; (line =3D fparseln(fp, NULL, NULL, NULL, 0)) !=3D = NULL; > + free(line)) > + addfd(&pfd, &bl, &nfd, &maxfd, line); > + fclose(fp); > + } > + if (nfd =3D=3D 0) > + addfd(&pfd, &bl, &nfd, &maxfd, _PATH_BLSOCK); > + > + state =3D state_open(dbfile, flags, 0600); > + if (state =3D=3D NULL) > + state =3D state_open(dbfile, flags | O_CREAT, 0600); > + if (state =3D=3D NULL) > + return EXIT_FAILURE; > + > + if (restore) { > + if (!flush) > + rules_flush(); > + rules_restore(); > + } > + > + if (!debug) { > + if (daemon(0, 0) =3D=3D -1) > + err(EXIT_FAILURE, "daemon failed"); > + if (pidfile(NULL) =3D=3D -1) > + err(EXIT_FAILURE, "Can't create pidfile"); > + } > + > + for (size_t t =3D 0; !done; t++) { > + if (readconf) { > + readconf =3D 0; > + conf_parse(configfile); > + } > + ret =3D poll(pfd, (nfds_t)nfd, tout); > + if (debug) > + (*lfun)(LOG_DEBUG, "received %d from poll()", ret= ); > + switch (ret) { > + case -1: > + if (errno =3D=3D EINTR) > + continue; > + (*lfun)(LOG_ERR, "poll (%m)"); > + return EXIT_FAILURE; > + case 0: > + state_sync(state); > + break; > + default: > + for (size_t i =3D 0; i < nfd; i++) > + if (pfd[i].revents & POLLIN) > + process(bl[i]); > + } > + if (t % 100 =3D=3D 0) > + state_sync(state); > + if (t % 10000 =3D=3D 0) > + update_interfaces(); > + update(); > + } > + state_close(state); > + return 0; > +} > diff --git a/contrib/blocklist/bin/old_internal.c b/contrib/blocklist/bin= /old_internal.c > new file mode 100644 > index 000000000000..79093cc8b8ab > --- /dev/null > +++ b/contrib/blocklist/bin/old_internal.c > @@ -0,0 +1,50 @@ > +/* $NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $ *= / > + > +/*- > + * Copyright (c) 2015 The NetBSD Foundation, Inc. > + * All rights reserved. > + * > + * This code is derived from software contributed to The NetBSD Foundati= on > + * by Christos Zoulas. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in th= e > + * documentation and/or other materials provided with the distributio= n. > + * > + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBU= TORS > + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L= IMITED > + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTI= CULAR > + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBU= TORS > + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, O= R > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSIN= ESS > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER = IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS= E) > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED O= F THE > + * POSSIBILITY OF SUCH DAMAGE. > + */ > +#ifdef HAVE_CONFIG_H > +#include "config.h" > +#endif > + > +#ifdef HAVE_SYS_CDEFS_H > +#include > +#endif > +__RCSID("$NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $"); > + > +#include > +#include > +#include "conf.h" > +#include "old_internal.h" > + > +int debug; > +const char *rulename =3D "blacklistd"; > +const char *controlprog =3D _PATH_BLCONTROL; > +struct confset lconf, rconf; > +struct ifaddrs *ifas; > +void (*lfun)(int, const char *, ...) =3D syslog; > diff --git a/contrib/blocklist/bin/old_internal.h b/contrib/blocklist/bin= /old_internal.h > new file mode 100644 > index 000000000000..becee563e81d > --- /dev/null > +++ b/contrib/blocklist/bin/old_internal.h > @@ -0,0 +1,58 @@ > +/* $NetBSD: internal.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ = */ > + > +/*- > + * Copyright (c) 2015 The NetBSD Foundation, Inc. > + * All rights reserved. > + * > + * This code is derived from software contributed to The NetBSD Foundati= on > + * by Christos Zoulas. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in th= e > + * documentation and/or other materials provided with the distributio= n. > + * > + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBU= TORS > + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L= IMITED > + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTI= CULAR > + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBU= TORS > + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, O= R > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSIN= ESS > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER = IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS= E) > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED O= F THE > + * POSSIBILITY OF SUCH DAMAGE. > + */ > +#ifndef _OLD_INTERNAL_H > +#define _OLD_INTERNAL_H > + > +#ifndef _PATH_BLCONF > +#define _PATH_BLCONF "/etc/blacklistd.conf" > +#endif > +#ifndef _PATH_BLCONTROL > +#define _PATH_BLCONTROL "/usr/libexec/blacklistd-helper" > +#endif > +#ifndef _PATH_BLSTATE > +/* We want the new name, the old one would be incompatible after 24932b6= */ > +#define _PATH_BLSTATE "/var/db/blocklistd.db" > +#endif > + > +extern struct confset rconf, lconf; > +extern int debug; > +extern const char *rulename; > +extern const char *controlprog; > +extern struct ifaddrs *ifas; > + > +#if !defined(__syslog_attribute__) && !defined(__syslog__) > +#define __syslog__ __printf__ > +#endif > + > +extern void (*lfun)(int, const char *, ...) > + __attribute__((__format__(__syslog__, 2, 3))); > + > *** 2507 LINES SKIPPED *** --=20 Jose Luis Duran