Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/blacklist Works on both linux and macosx
details: https://anonhg.NetBSD.org/src/rev/3e587f561803
branches: trunk
changeset: 335720:3e587f561803
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 22 04:13:04 2015 +0000
description:
Works on both linux and macosx
diffstat:
external/bsd/blacklist/bin/blacklistd.c | 9 +++++----
external/bsd/blacklist/bin/conf.c | 10 ++++++++--
external/bsd/blacklist/bin/run.c | 22 +++++++++-------------
external/bsd/blacklist/bin/run.h | 7 +++----
external/bsd/blacklist/bin/state.c | 8 ++++++--
external/bsd/blacklist/test/srvtest.c | 6 +++---
6 files changed, 34 insertions(+), 28 deletions(-)
diffs (197 lines):
diff -r a39f3055a6b9 -r 3e587f561803 external/bsd/blacklist/bin/blacklistd.c
--- a/external/bsd/blacklist/bin/blacklistd.c Thu Jan 22 03:48:07 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistd.c Thu Jan 22 04:13:04 2015 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/types.h>
#include <sys/socket.h>
@@ -162,7 +162,8 @@
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 @@
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 -r a39f3055a6b9 -r 3e587f561803 external/bsd/blacklist/bin/conf.c
--- a/external/bsd/blacklist/bin/conf.c Thu Jan 22 03:48:07 2015 +0000
+++ b/external/bsd/blacklist/bin/conf.c Thu Jan 22 04:13:04 2015 +0000
@@ -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 <sys/cdefs.h>
-__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 <stdio.h>
#include <string.h>
@@ -519,6 +519,12 @@
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 -r a39f3055a6b9 -r 3e587f561803 external/bsd/blacklist/bin/run.c
--- a/external/bsd/blacklist/bin/run.c Thu Jan 22 03:48:07 2015 +0000
+++ b/external/bsd/blacklist/bin/run.c Thu Jan 22 04:13:04 2015 +0000
@@ -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 <sys/cdefs.h>
-__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 <stdio.h>
#ifdef HAVE_UTIL_H
@@ -100,7 +100,7 @@
}
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 @@
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 -r a39f3055a6b9 -r 3e587f561803 external/bsd/blacklist/bin/run.h
--- a/external/bsd/blacklist/bin/run.h Thu Jan 22 03:48:07 2015 +0000
+++ b/external/bsd/blacklist/bin/run.h Thu Jan 22 04:13:04 2015 +0000
@@ -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 @@
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 -r a39f3055a6b9 -r 3e587f561803 external/bsd/blacklist/bin/state.c
--- a/external/bsd/blacklist/bin/state.c Thu Jan 22 03:48:07 2015 +0000
+++ b/external/bsd/blacklist/bin/state.c Thu Jan 22 04:13:04 2015 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/types.h>
#include <sys/socket.h>
@@ -75,6 +75,10 @@
{
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 -r a39f3055a6b9 -r 3e587f561803 external/bsd/blacklist/test/srvtest.c
--- a/external/bsd/blacklist/test/srvtest.c Thu Jan 22 03:48:07 2015 +0000
+++ b/external/bsd/blacklist/test/srvtest.c Thu Jan 22 04:13:04 2015 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/types.h>
#include <sys/socket.h>
@@ -94,7 +94,7 @@
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)
Home |
Main Index |
Thread Index |
Old Index