diff --git a/external/bsd/blacklist/bin/blacklistd.c b/external/bsd/blacklist/bin/blacklistd.c index 3ce65cd6e058..45b9ecd74662 100644 --- a/external/bsd/blacklist/bin/blacklistd.c +++ b/external/bsd/blacklist/bin/blacklistd.c @@ -1,4 +1,4 @@ -/* $NetBSD: blacklistd.c,v 1.15 2015/01/22 03:48:07 christos Exp $ */ +/* $NetBSD: blacklistd.c,v 1.16 2015/01/22 04:13:04 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include "config.h" #endif #include -__RCSID("$NetBSD: blacklistd.c,v 1.15 2015/01/22 03:48:07 christos Exp $"); +__RCSID("$NetBSD: blacklistd.c,v 1.16 2015/01/22 04:13:04 christos Exp $"); #include #include @@ -162,7 +162,8 @@ process(bl_t bl) goto out; } if (c.c_nfail != -1 && dbi.count >= c.c_nfail) { - int res = run_add(&c, &rss, dbi.id, sizeof(dbi.id)); + int res = run_change("add", &c, &rss, + dbi.id, sizeof(dbi.id)); if (res == -1) goto out; sockaddr_snprintf(rbuf, sizeof(rbuf), "%a", @@ -218,7 +219,7 @@ update(void) if (c.c_duration == -1 || when >= ts.tv_sec) continue; if (dbi.id[0]) { - run_rem(&c, dbi.id); + run_change("rem", &c, &ss, dbi.id, 0); sockaddr_snprintf(buf, sizeof(buf), "%a", (void *)&ss); syslog(LOG_INFO, "Released %s at port %d after %d seconds", diff --git a/external/bsd/blacklist/bin/conf.c b/external/bsd/blacklist/bin/conf.c index 986ce4e0bfeb..65bf9f2ae099 100644 --- a/external/bsd/blacklist/bin/conf.c +++ b/external/bsd/blacklist/bin/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.10 2015/01/22 03:10:49 christos Exp $ */ +/* $NetBSD: conf.c,v 1.11 2015/01/22 04:13:04 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #endif #include -__RCSID("$NetBSD: conf.c,v 1.10 2015/01/22 03:10:49 christos Exp $"); +__RCSID("$NetBSD: conf.c,v 1.11 2015/01/22 04:13:04 christos Exp $"); #include #include @@ -519,6 +519,12 @@ conf_parse(const char *f) for (; (line = fparseln(fp, &len, &lineno, NULL, 0)) != NULL; free(line)) { +#ifdef __APPLE__ + if (!*line) + continue; + if (debug > 4) + printf("%s, %zu: [%s]\n", f, lineno, line); +#endif if (nc == mc) { mc += 10; tc = realloc(c, mc * sizeof(*c)); diff --git a/external/bsd/blacklist/bin/run.c b/external/bsd/blacklist/bin/run.c index 0afe2c063bd7..c181ef39920c 100644 --- a/external/bsd/blacklist/bin/run.c +++ b/external/bsd/blacklist/bin/run.c @@ -1,4 +1,4 @@ -/* $NetBSD: run.c,v 1.7 2015/01/22 03:10:49 christos Exp $ */ +/* $NetBSD: run.c,v 1.8 2015/01/22 04:13:04 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #endif #include -__RCSID("$NetBSD: run.c,v 1.7 2015/01/22 03:10:49 christos Exp $"); +__RCSID("$NetBSD: run.c,v 1.8 2015/01/22 04:13:04 christos Exp $"); #include #ifdef HAVE_UTIL_H @@ -100,7 +100,7 @@ run_flush(const struct conf *c) } int -run_add(const struct conf *c, +run_change(const char *how, const struct conf *c, const struct sockaddr_storage *ss, char *id, size_t len) { const char *prname; @@ -122,18 +122,14 @@ run_add(const struct conf *c, snprintf(poname, sizeof(poname), "%d", c->c_port); sockaddr_snprintf(adname, sizeof(adname), "%a", (const void *)ss); - rv = run("add", c->c_name, prname, adname, poname, NULL); + rv = run(how, c->c_name, prname, adname, poname, id, NULL); if (rv == NULL) return -1; - rv[strcspn(rv, "\n")] = '\0'; - off = strncmp(rv, "OK ", 3) == 0 ? 3 : 0; - strlcpy(id, rv + off, len); + if (len != 0) { + rv[strcspn(rv, "\n")] = '\0'; + off = strncmp(rv, "OK ", 3) == 0 ? 3 : 0; + strlcpy(id, rv + off, len); + } free(rv); return 0; } - -void -run_rem(const struct conf *c, const char *id) -{ - free(run("rem", c->c_name, id, NULL)); -} diff --git a/external/bsd/blacklist/bin/run.h b/external/bsd/blacklist/bin/run.h index e4ff67e0b66c..79c21d5a73be 100644 --- a/external/bsd/blacklist/bin/run.h +++ b/external/bsd/blacklist/bin/run.h @@ -1,4 +1,4 @@ -/* $NetBSD: run.h,v 1.3 2015/01/21 19:24:03 christos Exp $ */ +/* $NetBSD: run.h,v 1.4 2015/01/22 04:13:04 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -35,9 +35,8 @@ __BEGIN_DECLS struct conf; void run_flush(const struct conf *); struct sockaddr_storage; -int run_add(const struct conf *, const struct sockaddr_storage *, - char *, size_t); -void run_rem(const struct conf *, const char *); +int run_change(const char *, const struct conf *, + const struct sockaddr_storage *, char *, size_t); __END_DECLS #endif /* _RUN_H */ diff --git a/external/bsd/blacklist/bin/state.c b/external/bsd/blacklist/bin/state.c index 399d891daec7..7d22383be296 100644 --- a/external/bsd/blacklist/bin/state.c +++ b/external/bsd/blacklist/bin/state.c @@ -1,4 +1,4 @@ -/* $NetBSD: state.c,v 1.7 2015/01/22 03:10:49 christos Exp $ */ +/* $NetBSD: state.c,v 1.8 2015/01/22 04:13:04 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #endif #include -__RCSID("$NetBSD: state.c,v 1.7 2015/01/22 03:10:49 christos Exp $"); +__RCSID("$NetBSD: state.c,v 1.8 2015/01/22 04:13:04 christos Exp $"); #include #include @@ -75,6 +75,10 @@ state_open(const char *dbname, int flags, mode_t perm) { DB *db; +#ifdef __APPLE__ + flags &= O_CREAT|O_EXCL|O_EXLOCK|O_NONBLOCK|O_RDONLY| + O_RDWR|O_SHLOCK|O_TRUNC; +#endif db = dbopen(dbname, flags, perm, DB_HASH, &openinfo); if (db == NULL) { if (errno == ENOENT && (flags & O_CREAT) == 0) diff --git a/external/bsd/blacklist/test/srvtest.c b/external/bsd/blacklist/test/srvtest.c index 994294b6bf9b..6c06e524689d 100644 --- a/external/bsd/blacklist/test/srvtest.c +++ b/external/bsd/blacklist/test/srvtest.c @@ -1,4 +1,4 @@ -/* $NetBSD: srvtest.c,v 1.6 2015/01/22 03:48:07 christos Exp $ */ +/* $NetBSD: srvtest.c,v 1.7 2015/01/22 04:13:04 christos Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #endif #include -__RCSID("$NetBSD: srvtest.c,v 1.6 2015/01/22 03:48:07 christos Exp $"); +__RCSID("$NetBSD: srvtest.c,v 1.7 2015/01/22 04:13:04 christos Exp $"); #include #include @@ -94,7 +94,7 @@ cr(int af, int type, in_port_t p) s6->sin6_port = p; } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - ss->ss_len = slen; + ss.ss_len = slen; #endif if (bind(sfd, (const void *)&ss, slen) == -1)