Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/blacklist/bin PR/51801: Matthew Mondor: Support...
details: https://anonhg.NetBSD.org/src/rev/46c6a041b491
branches: trunk
changeset: 820409:46c6a041b491
user: christos <christos%NetBSD.org@localhost>
date: Mon Jan 09 03:05:48 2017 +0000
description:
PR/51801: Matthew Mondor: Support multiple -s options and -P and -s at the
same time.
diffstat:
external/bsd/blacklist/bin/blacklistd.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diffs (78 lines):
diff -r 51d095beffee -r 46c6a041b491 external/bsd/blacklist/bin/blacklistd.c
--- a/external/bsd/blacklist/bin/blacklistd.c Mon Jan 09 02:54:18 2017 +0000
+++ b/external/bsd/blacklist/bin/blacklistd.c Mon Jan 09 03:05:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: blacklistd.c,v 1.35 2016/09/26 19:43:43 christos Exp $ */
+/* $NetBSD: blacklistd.c,v 1.36 2017/01/09 03:05:48 christos 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.35 2016/09/26 19:43:43 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.36 2017/01/09 03:05:48 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -394,12 +394,14 @@
main(int argc, char *argv[])
{
int c, tout, flags, flush, restore;
- const char *spath, *blsock;
+ const char *spath, **blsock;
+ size_t nblsock, maxblsock;
setprogname(argv[0]);
spath = NULL;
- blsock = _PATH_BLSOCK;
+ blsock = NULL;
+ maxblsock = nblsock = 0;
flush = 0;
restore = 0;
tout = 0;
@@ -431,7 +433,17 @@
restore++;
break;
case 's':
- blsock = optarg;
+ if (nblsock >= maxblsock) {
+ maxblsock += 10;
+ void *p = realloc(blsock,
+ sizeof(*blsock) * maxblsock);
+ if (p == NULL)
+ err(EXIT_FAILURE,
+ "Can't allocate memory for %zu sockets",
+ maxblsock);
+ blsock = p;
+ }
+ blsock[nblsock++] = optarg;
break;
case 't':
tout = atoi(optarg) * 1000;
@@ -478,9 +490,11 @@
size_t nfd = 0;
size_t maxfd = 0;
- if (spath == NULL)
- addfd(&pfd, &bl, &nfd, &maxfd, blsock);
- else {
+ for (size_t i = 0; i < nblsock; i++)
+ addfd(&pfd, &bl, &nfd, &maxfd, blsock[i]);
+ free(blsock);
+
+ if (spath) {
FILE *fp = fopen(spath, "r");
char *line;
if (fp == NULL)
@@ -490,6 +504,8 @@
addfd(&pfd, &bl, &nfd, &maxfd, line);
fclose(fp);
}
+ if (nfd == 0)
+ addfd(&pfd, &bl, &nfd, &maxfd, _PATH_BLSOCK);
state = state_open(dbfile, flags, 0600);
if (state == NULL)
Home |
Main Index |
Thread Index |
Old Index