Index: Makefile =================================================================== RCS file: /home/pcvs/ports/net/relayd/Makefile,v retrieving revision 1.5 diff -u -r1.5 Makefile --- Makefile 6 Jan 2009 17:59:12 -0000 1.5 +++ Makefile 27 May 2010 09:35:52 -0000 @@ -5,13 +5,12 @@ # $FreeBSD: ports/net/relayd/Makefile,v 1.5 2009/01/06 17:59:12 pav Exp $ PORTNAME= relayd -PORTVERSION= 4.2.20071221 -PORTREVISION= 1 +PORTVERSION= 4.6.20090813 CATEGORIES= net MASTER_SITES= ${MASTER_SITE_LOCAL} -MASTER_SITE_SUBDIR= kuriyama +MASTER_SITE_SUBDIR= mm -MAINTAINER= kuriyama@FreeBSD.org +MAINTAINER= mm@FreeBSD.org COMMENT= OpenBSD Relay Daemon LIB_DEPENDS= event-1.4:${PORTSDIR}/devel/libevent @@ -28,6 +27,11 @@ _MAKE= ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_ARGS} RUSER= _relayd RGROUP= _relayd +PKGINSTALL= ${WRKDIR}/pkginstall +SUB_FILES+= pkg-install + +SUB_LIST+= RUSER=${RUSER} \ + RGROUP=${RGROUP} post-extract: ${MKDIR} ${WRKSRC} @@ -44,7 +48,7 @@ (cd ${WRKSRCD}; ${_MAKE} ${ALL_TARGET}) pre-su-install: - @${SETENV} PKG_PREFIX=${PREFIX} RUSER=${RUSER} RGROUP=${RGROUP} \ + @${SETENV} PKG_PREFIX=${PREFIX} \ ${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL do-install: Index: distinfo =================================================================== RCS file: /home/pcvs/ports/net/relayd/distinfo,v retrieving revision 1.1 diff -u -r1.1 distinfo --- distinfo 20 Jan 2008 21:38:25 -0000 1.1 +++ distinfo 27 May 2010 09:35:52 -0000 @@ -1,3 +1,3 @@ -MD5 (relayd-4.2.20071221.tar.gz) = 3e6060c3228f2427d4dc3f3740cd4b15 -SHA256 (relayd-4.2.20071221.tar.gz) = e92d777408e87e9c60d5a439affddc6c2ea005fcb116ced937f3ce977e9b3d0d -SIZE (relayd-4.2.20071221.tar.gz) = 84150 +MD5 (relayd-4.6.20090813.tar.gz) = c28dbf8e02f136889a4c7c9841fc8804 +SHA256 (relayd-4.6.20090813.tar.gz) = 89b82e0829a9dfc01daaaddd587a142fef7158035ef5fd440268ab19dc55ca07 +SIZE (relayd-4.6.20090813.tar.gz) = 100125 Index: pkg-install =================================================================== RCS file: pkg-install diff -N pkg-install --- pkg-install 20 Jan 2008 21:38:25 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,36 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: ports/net/relayd/pkg-install,v 1.1 2008/01/20 21:38:25 kuriyama Exp $ - -case $2 in -PRE-INSTALL) - USER=${RUSER} - GROUP=${RGROUP} - UID=913 - GID=913 - - if pw group show "${GROUP}" 2>/dev/null; then - echo "You already have a group \"${GROUP}\", so I will use it." - else - if pw groupadd ${GROUP} -g ${GID}; then - echo "Added group \"${GROUP}\"." - else - echo "Adding group \"${GROUP}\" failed..." - exit 1 - fi - fi - - if pw user show "${USER}" 2>/dev/null; then - echo "You already have a user \"${USER}\", so I will use it." - else - if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ - -d /var/empty -c "Relay Daemon" -s /usr/sbin/nologin - then - echo "Added user \"${USER}\"." - else - echo "Adding user \"${USER}\" failed..." - exit 1 - fi - fi - ;; -esac Index: files/patch-ctl-Makefile =================================================================== RCS file: files/patch-ctl-Makefile diff -N files/patch-ctl-Makefile --- files/patch-ctl-Makefile 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,20 +0,0 @@ ---- relayctl/Makefile.orig Tue Jan 9 09:45:32 2007 -+++ relayctl/Makefile Wed Jun 6 18:58:57 2007 -@@ -8,9 +8,16 @@ - MAN= relayctl.8 - - CFLAGS+= -Wall -Werror -I${.CURDIR} -I${.CURDIR}/../relayd -+CFLAGS+= -I${PREFIX}/include -D__dead='' - CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes - CFLAGS+= -Wmissing-declarations - CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual --CFLAGS+= -Wsign-compare -Wbounded -+CFLAGS+= -Wsign-compare -+ -+install: -+ $(INSTALL) -m 555 -g wheel -o root relayctl $(PREFIX)/sbin -+ -+install-man: -+ $(INSTALL) -o root -g wheel -m 444 relayctl.8 $(PREFIX)/man/man8 - - .include Index: files/patch-ctl-parser.c =================================================================== RCS file: files/patch-ctl-parser.c diff -N files/patch-ctl-parser.c --- files/patch-ctl-parser.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ ---- relayctl/parser.c.orig Wed May 30 07:41:48 2007 -+++ relayctl/parser.c Mon Jan 7 21:32:16 2008 -@@ -18,7 +18,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include -+#include - #include - #include - #include -@@ -118,6 +118,9 @@ - }; - - static struct parse_result res; -+ -+const struct token *match_token(const char *, const struct token []); -+void show_valid_args(const struct token []); - - struct parse_result * - parse(int argc, char *argv[]) Index: files/patch-ctl-parser.h =================================================================== RCS file: files/patch-ctl-parser.h diff -N files/patch-ctl-parser.h --- files/patch-ctl-parser.h 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,8 +0,0 @@ ---- relayctl/parser.h.orig Wed Jun 6 18:25:59 2007 -+++ relayctl/parser.h Wed Jun 6 18:27:58 2007 -@@ -38,5 +38,3 @@ - }; - - struct parse_result *parse(int, char *[]); --const struct token *match_token(const char *, const struct token []); --void show_valid_args(const struct token []); Index: files/patch-ctl-relayctl.c =================================================================== RCS file: files/patch-ctl-relayctl.c diff -N files/patch-ctl-relayctl.c --- files/patch-ctl-relayctl.c 8 Apr 2008 15:57:29 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,28 +0,0 @@ ---- relayctl/relayctl.c.orig 2007-12-20 21:15:43.000000000 +0100 -+++ relayctl/relayctl.c 2008-03-20 17:15:14.000000000 +0100 -@@ -20,6 +20,7 @@ - */ - - #include -+#include - #include - #include - #include -@@ -297,7 +298,7 @@ - imn = monitor_lookup(imsg->hdr.type); - printf("%s: imsg type %u len %u peerid %u pid %d\n", imn->name, - imsg->hdr.type, imsg->hdr.len, imsg->hdr.peerid, imsg->hdr.pid); -- printf("\ttimestamp: %u, %s", now, ctime(&now)); -+ printf("\ttimestamp: %lu, %s", (unsigned long)now, ctime(&now)); - if (imn->type == -1) - done = 1; - if (imn->func != NULL) -@@ -508,7 +509,7 @@ - printf("\t%8s\ttotal: %llu sessions\n" - "\t%8s\tlast: %u/%us %u/h %u/d sessions\n" - "\t%8s\taverage: %u/%us %u/h %u/d sessions\n", -- "", crs.cnt, -+ "", (long long unsigned)crs.cnt, - "", crs.last, crs.interval, - crs.last_hour, crs.last_day, - "", crs.avg, crs.interval, Index: files/patch-d-Makefile =================================================================== RCS file: files/patch-d-Makefile diff -N files/patch-d-Makefile --- files/patch-d-Makefile 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,26 +0,0 @@ ---- relayd/Makefile.orig Tue Feb 27 04:35:43 2007 -+++ relayd/Makefile Tue Jun 5 20:57:45 2007 -@@ -6,13 +6,20 @@ - check_icmp.c check_tcp.c relay.c carp.c - MAN= relayd.8 relayd.conf.5 - --LDADD= -levent -lssl -lcrypto -+LDADD= -lmd -L${PREFIX}/lib -levent -lssl -lcrypto - DPADD= ${LIBEVENT} ${LIBSSL} ${LIBCRYPTO} --CFLAGS+= -Wall -I${.CURDIR} -+CFLAGS+= -Wall -I${.CURDIR} -I${PREFIX}/include -D__dead='' -DSHA1_DIGEST_LENGTH=SHA_DIGEST_LENGTH -DSHA1_DIGEST_STRING_LENGTH=SHA_DIGEST_LENGTH -DOPENSSL_NO_SHA -DOPENSSL_NO_MD5 - CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes - CFLAGS+= -Wmissing-declarations - CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual --CFLAGS+= -Wsign-compare -Wbounded -+CFLAGS+= -Wsign-compare - CLEANFILES+= y.tab.h -+ -+install: -+ $(INSTALL) -m 555 -g wheel -o root relayd $(PREFIX)/sbin -+ -+install-man: -+ $(INSTALL) -m 444 -g wheel -o root relayd.conf.5 $(PREFIX)/man/man5 -+ $(INSTALL) -m 444 -g wheel -o root relayd.8 $(PREFIX)/man/man8 - - .include Index: files/patch-d-carp.c =================================================================== RCS file: files/patch-d-carp.c diff -N files/patch-d-carp.c --- files/patch-d-carp.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,44 +0,0 @@ ---- relayd/carp.c.orig 2007-12-08 02:17:00.000000000 +0900 -+++ relayd/carp.c 2008-01-14 08:43:07.745281030 +0900 -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - - #include - -@@ -105,6 +106,7 @@ - int - carp_demote_get(char *group) - { -+#if 0 - int s; - struct ifgroupreq ifgr; - -@@ -131,6 +133,9 @@ - - close(s); - return ((int)ifgr.ifgr_attrib.ifg_carp_demoted); -+#else -+ return (-1); -+#endif - } - - int -@@ -188,6 +193,7 @@ - int - carp_demote_ioctl(char *group, int demote) - { -+#if 0 - int s, res; - struct ifgroupreq ifgr; - -@@ -214,4 +220,7 @@ - - close(s); - return (res); -+#else -+ return (-1); -+#endif - } Index: files/patch-d-check_icmp.c =================================================================== RCS file: files/patch-d-check_icmp.c diff -N files/patch-d-check_icmp.c --- files/patch-d-check_icmp.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ ---- relayd/check_icmp.c.orig 2008-01-14 10:10:32.881133017 +0900 -+++ relayd/check_icmp.c 2008-01-14 10:10:45.169385174 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include -+#include - #include - #include - Index: files/patch-d-check_tcp.c =================================================================== RCS file: files/patch-d-check_tcp.c diff -N files/patch-d-check_tcp.c --- files/patch-d-check_tcp.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,47 +0,0 @@ ---- relayd/check_tcp.c.orig 2007-12-08 02:17:00.000000000 +0900 -+++ relayd/check_tcp.c 2008-01-14 16:47:41.131892553 +0900 -@@ -31,7 +31,7 @@ - #include - #include - #include --#include -+#include - - #include - -@@ -285,7 +285,7 @@ - if (b == NULL) - fatal("out of memory"); - *b = '\0'; -- if (fnmatch(cte->table->conf.exbuf, cte->buf->buf, 0) == 0) { -+ if (fnmatch(cte->table->conf.exbuf, (char *)cte->buf->buf, 0) == 0) { - cte->host->up = HOST_UP; - return (0); - } -@@ -316,7 +316,7 @@ - fatal("out of memory"); - *b = '\0'; - -- head = cte->buf->buf; -+ head = (char *)cte->buf->buf; - host = cte->host; - if (strncmp(head, "HTTP/1.1 ", strlen("HTTP/1.1 ")) && - strncmp(head, "HTTP/1.0 ", strlen("HTTP/1.0 "))) { -@@ -363,7 +363,7 @@ - fatal("out of memory"); - *b = '\0'; - -- head = cte->buf->buf; -+ head = (char *)cte->buf->buf; - host = cte->host; - if ((head = strstr(head, "\r\n\r\n")) == NULL) { - log_debug("check_http_digest: %s failed " -@@ -373,7 +373,7 @@ - } - head += strlen("\r\n\r\n"); - -- digeststr(cte->table->conf.digest_type, head, strlen(head), digest); -+ digeststr(cte->table->conf.digest_type, (u_int8_t*)head, strlen(head), digest); - - if (strcmp(cte->table->conf.digest, digest)) { - log_warnx("check_http_digest: %s failed " Index: files/patch-d-log.c =================================================================== RCS file: files/patch-d-log.c diff -N files/patch-d-log.c --- files/patch-d-log.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ ---- relayd/log.c.orig 2008-01-14 09:59:27.825621568 +0900 -+++ relayd/log.c 2008-01-14 09:59:36.888069516 +0900 -@@ -16,7 +16,7 @@ - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include -+#include - #include - #include - #include Index: files/patch-d-parse.y =================================================================== RCS file: files/patch-d-parse.y diff -N files/patch-d-parse.y --- files/patch-d-parse.y 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ ---- relayd/parse.y.orig Tue Jun 5 20:12:20 2007 -+++ relayd/parse.y Tue Jun 5 20:12:51 2007 -@@ -1561,7 +1561,7 @@ - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /* DUMMY */ - error = getaddrinfo(s, NULL, &hints, &res0); -- if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) -+ if (error == EAI_AGAIN || error == EAI_NONAME) - return (0); - if (error) { - log_warnx("host_dns: could not parse \"%s\": %s", s, Index: files/patch-d-pfe.c =================================================================== RCS file: files/patch-d-pfe.c diff -N files/patch-d-pfe.c --- files/patch-d-pfe.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,10 +0,0 @@ ---- relayd/pfe.c.orig 2008-01-14 10:06:37.013495830 +0900 -+++ relayd/pfe.c 2008-01-14 10:06:47.508856711 +0900 -@@ -17,6 +17,7 @@ - */ - - #include -+#include - #include - #include - #include Index: files/patch-d-pfe_filter.c =================================================================== RCS file: files/patch-d-pfe_filter.c diff -N files/patch-d-pfe_filter.c --- files/patch-d-pfe_filter.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,45 +0,0 @@ ---- relayd/pfe_filter.c.orig 2007-12-21 05:15:43.000000000 +0900 -+++ relayd/pfe_filter.c 2008-01-20 15:31:28.856798863 +0900 -@@ -89,6 +89,7 @@ - sizeof(tables[i].pfrt_name)) - goto toolong; - tables[i].pfrt_flags |= PFR_TFLAG_PERSIST; -+ log_debug("init_tables: prepare anchor \"%s\" and table \"%s\"", tables[i].pfrt_anchor, tables[i].pfrt_name); - i++; - } - if (i != env->rdrcount) -@@ -239,10 +240,15 @@ - sizeof(io.pfrio_table.pfrt_name)) >= - sizeof(io.pfrio_table.pfrt_name)) - goto toolong; -+ /* pfctl -Tflush */ - if (ioctl(env->pf->dev, DIOCRCLRADDRS, &io) == -1) - fatal("flush_table: cannot flush table addresses"); -+ /* pfctl -Tzero */ -+#if 0 -+ /* XXX: ioctl(DIOCRCLRTSTATS) requires io.pfrio_esize to be set as sizeof(struct pfr_table), but here doesn't set it. */ - if (ioctl(env->pf->dev, DIOCRCLRTSTATS, &io) == -1) - fatal("flush_table: cannot flush table stats"); -+#endif - log_debug("flush_table: flushed table %s", rdr->conf.name); - return; - -@@ -321,7 +327,9 @@ - rio.rule.dst.addr.type = PF_ADDR_ADDRMASK; - rio.rule.dst.port_op = PF_OP_EQ; - rio.rule.dst.port[0] = address->port; -+#if 0 - rio.rule.rtableid = -1; /* stay in the main routing table */ -+#endif - rio.rule.action = PF_RDR; - if (strlen(rdr->conf.tag)) - (void)strlcpy(rio.rule.tagname, rdr->conf.tag, -@@ -362,7 +370,7 @@ - - if (ioctl(env->pf->dev, DIOCADDRULE, &rio) == -1) - fatal("cannot add rule"); -- log_debug("sync_ruleset: rule added"); -+ log_debug("sync_ruleset: rule added into anchor \"%s\", table \"%s\"", rio.anchor, pio.addr.addr.v.tblname); - } - if (transaction_commit(env) == -1) - log_warn("sync_ruleset: add rules transaction failed"); Index: files/patch-d-relay.c =================================================================== RCS file: files/patch-d-relay.c diff -N files/patch-d-relay.c --- files/patch-d-relay.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,72 +0,0 @@ ---- relayd/relay.c.orig 2007-12-09 05:36:36.000000000 +0900 -+++ relayd/relay.c 2008-01-14 10:26:05.345356528 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include -+#include - #include - #include - #include -@@ -675,6 +675,7 @@ - &val, sizeof(val)) == -1) - goto bad; - } -+#if 0 - if (proto->tcpflags & (TCPFLAG_SACK|TCPFLAG_NSACK)) { - if (proto->tcpflags & TCPFLAG_NSACK) - val = 0; -@@ -684,6 +685,7 @@ - &val, sizeof(val)) == -1) - goto bad; - } -+#endif - - return (s); - -@@ -1000,7 +1002,7 @@ - } - } - if (strstr(val, "$TIMEOUT") != NULL) { -- snprintf(ibuf, sizeof(ibuf), "%lu", rlay->conf.timeout.tv_sec); -+ snprintf(ibuf, sizeof(ibuf), "%lu", (unsigned long)rlay->conf.timeout.tv_sec); - if (expand_string(buf, len, "$TIMEOUT", ibuf) != 0) - return (NULL); - } -@@ -1565,7 +1567,7 @@ - switch (type) { - case DIGEST_SHA1: - case DIGEST_MD5: -- if ((md = digeststr(type, val, strlen(val), NULL)) == NULL) { -+ if ((md = digeststr(type, (u_int8_t*)val, strlen(val), NULL)) == NULL) { - relay_close_http(con, 500, - "failed to allocate digest", 0); - goto fail; -@@ -2469,7 +2471,7 @@ - goto err; - - /* Set session context to the local relay name */ -- if (!SSL_CTX_set_session_id_context(ctx, rlay->conf.name, -+ if (!SSL_CTX_set_session_id_context(ctx, (unsigned char*)rlay->conf.name, - strlen(rlay->conf.name))) - goto err; - -@@ -2849,7 +2851,7 @@ - if (fstat(fd, &st) != 0) - goto fail; - size = st.st_size; -- if ((buf = (char *)calloc(1, size + 1)) == NULL) -+ if ((buf = (u_int8_t *)calloc(1, size + 1)) == NULL) - goto fail; - if (read(fd, buf, size) != size) - goto fail; -@@ -2857,7 +2859,7 @@ - close(fd); - - *len = size + 1; -- return (buf); -+ return (char *)(buf); - - fail: - if (buf != NULL) Index: files/patch-d-relay_udp.c =================================================================== RCS file: files/patch-d-relay_udp.c diff -N files/patch-d-relay_udp.c --- files/patch-d-relay_udp.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ ---- relayd/relay_udp.c.orig 2008-01-14 10:09:08.345280942 +0900 -+++ relayd/relay_udp.c 2008-01-14 10:09:21.665469901 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include -+#include - #include - #include - #include Index: files/patch-d-relayd.8 =================================================================== RCS file: files/patch-d-relayd.8 diff -N files/patch-d-relayd.8 --- files/patch-d-relayd.8 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,20 +0,0 @@ ---- relayd/relayd.8.orig 2007-12-12 23:55:12.000000000 +0900 -+++ relayd/relayd.8 2008-01-14 08:47:34.673073391 +0900 -@@ -116,7 +116,7 @@ - .It Fl f Ar file - Specify an alternative configuration file. - The default is --.Pa /etc/relayd.conf . -+.Pa %%PREFIX%%/etc/relayd.conf . - .It Fl n - Configtest mode. - Only check the configuration file for validity. -@@ -125,7 +125,7 @@ - .El - .Sh FILES - .Bl -tag -width "/var/run/relayd.sockXX" -compact --.It /etc/relayd.conf -+.It %%PREFIX%%/etc/relayd.conf - Default configuration file. - .It /var/run/relayd.sock - Unix-domain socket used for communication with Index: files/patch-d-relayd.c =================================================================== RCS file: files/patch-d-relayd.c diff -N files/patch-d-relayd.c --- files/patch-d-relayd.c 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,29 +0,0 @@ ---- relayd/relayd.c.orig 2008-01-14 10:00:21.487354557 +0900 -+++ relayd/relayd.c 2008-01-14 16:44:45.705572691 +0900 -@@ -16,7 +16,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - --#include -+#include - #include - #include - #include -@@ -36,7 +36,7 @@ - #include - #include - #include --#include -+#include - #include - - #include -@@ -943,7 +943,7 @@ - { - switch (type) { - case DIGEST_SHA1: -- return (SHA1Data(data, len, buf)); -+ return (SHA1_Data(data, len, buf)); - break; - case DIGEST_MD5: - return (MD5Data(data, len, buf)); Index: files/patch-d-relayd.conf.5 =================================================================== RCS file: files/patch-d-relayd.conf.5 diff -N files/patch-d-relayd.conf.5 --- files/patch-d-relayd.conf.5 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,33 +0,0 @@ ---- relayd/relayd.conf.5.orig 2007-12-12 23:55:12.000000000 +0900 -+++ relayd/relayd.conf.5 2008-01-14 08:49:46.404074048 +0900 -@@ -101,20 +101,7 @@ - Here are the settings that can be set globally: - .Pp - .Bl -tag -width Ds -compact --.It Ic demote Ar group --Enable the global --.Xr carp 4 --demotion option, resetting the carp demotion counter for the --specified interface group to zero on startup and to 128 on shutdown of --the daemon. --For more information on interface groups, --see the --.Ic group --keyword in --.Xr ifconfig 8 . --.Pp --.It Xo --.Ic interval Ar number -+.It Ic interval Ar number - .Xc - Set the interval in seconds at which the hosts will be checked. - The default interval is 10 seconds. -@@ -894,7 +881,7 @@ - .El - .Sh FILES - .Bl -tag -width "/etc/ssl/private/address.keyXX" -compact --.It Pa /etc/relayd.conf -+.It Pa %%PREFIX%%/etc/relayd.conf - .Xr relayd 8 - configuration file. - .Pp Index: files/patch-d-relayd.h =================================================================== RCS file: files/patch-d-relayd.h diff -N files/patch-d-relayd.h --- files/patch-d-relayd.h 20 Jan 2008 21:38:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,27 +0,0 @@ ---- relayd/relayd.h.orig 2007-12-21 05:15:43.000000000 +0900 -+++ relayd/relayd.h 2008-01-14 10:02:42.803752108 +0900 -@@ -20,7 +20,7 @@ - - #include - --#define CONF_FILE "/etc/relayd.conf" -+#define CONF_FILE "%%PREFIX%%/etc/relayd.conf" - #define RELAYD_SOCKET "/var/run/relayd.sock" - #define PF_SOCKET "/dev/pf" - #define RELAYD_USER "_relayd" -@@ -56,6 +56,15 @@ - #define PURGE_PROTOS 0x08 - #define PURGE_EVERYTHING 0xff - -+#define SIMPLEQ_HEAD STAILQ_HEAD -+#define SIMPLEQ_FIRST STAILQ_FIRST -+#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD -+#define SIMPLEQ_ENTRY STAILQ_ENTRY -+#define SIMPLEQ_INIT STAILQ_INIT -+#define SIMPLEQ_EMPTY STAILQ_EMPTY -+#define SIMPLEQ_NEXT STAILQ_NEXT -+#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL -+ - /* buffer */ - struct buf { - TAILQ_ENTRY(buf) entry; Index: files/patch-freebsd-relayctl =================================================================== RCS file: files/patch-freebsd-relayctl diff -N files/patch-freebsd-relayctl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-freebsd-relayctl 27 May 2010 09:35:52 -0000 @@ -0,0 +1,96 @@ +diff -Naur relayctl.orig/Makefile relayctl/Makefile +--- relayctl.orig/Makefile 2007-12-07 18:17:01.000000000 +0100 ++++ relayctl/Makefile 2010-05-27 08:59:16.000000000 +0200 +@@ -8,9 +8,16 @@ + MAN= relayctl.8 + + CFLAGS+= -Wall -Werror -I${.CURDIR} -I${.CURDIR}/../relayd ++CFLAGS+= -I${PREFIX}/include -D__dead='' + CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes + CFLAGS+= -Wmissing-declarations + CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual +-CFLAGS+= -Wsign-compare -Wbounded ++CFLAGS+= -Wsign-compare ++ ++install: ++ $(INSTALL) -m 555 -g wheel -o root relayctl $(PREFIX)/sbin ++ ++install-man: ++ $(INSTALL) -o root -g wheel -m 444 relayctl.8 $(PREFIX)/man/man8 + + .include +diff -Naur relayctl.orig/parser.c relayctl/parser.c +--- relayctl.orig/parser.c 2007-12-20 21:15:43.000000000 +0100 ++++ relayctl/parser.c 2010-05-27 10:12:35.000000000 +0200 +@@ -18,7 +18,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include ++#else + #include ++#endif + #include + #include + +@@ -124,6 +128,11 @@ + + static struct parse_result res; + ++#ifdef __FreeBSD__ ++const struct token *match_token(const char *, const struct token []); ++void show_valid_args(const struct token []); ++#endif ++ + struct parse_result * + parse(int argc, char *argv[]) + { +diff -Naur relayctl.orig/parser.h relayctl/parser.h +--- relayctl.orig/parser.h 2007-12-20 21:15:43.000000000 +0100 ++++ relayctl/parser.h 2010-05-27 10:12:03.000000000 +0200 +@@ -41,5 +41,7 @@ + }; + + struct parse_result *parse(int, char *[]); ++#ifndef __FreeBSD__ + const struct token *match_token(const char *, const struct token []); + void show_valid_args(const struct token []); ++#endif +diff -Naur relayctl.orig/relayctl.c relayctl/relayctl.c +--- relayctl.orig/relayctl.c 2009-06-06 01:39:51.000000000 +0200 ++++ relayctl/relayctl.c 2010-05-27 10:11:39.000000000 +0200 +@@ -20,6 +20,9 @@ + */ + + #include ++#ifdef __FreeBSD__ ++#include ++#endif + #include + #include + #include +@@ -290,7 +293,11 @@ + imn = monitor_lookup(imsg->hdr.type); + printf("%s: imsg type %u len %u peerid %u pid %d\n", imn->name, + imsg->hdr.type, imsg->hdr.len, imsg->hdr.peerid, imsg->hdr.pid); ++#ifdef __FreeBSD__ ++ printf("\ttimestamp: %lu, %s", (unsigned long)now, ctime(&now)); ++#else + printf("\ttimestamp: %u, %s", now, ctime(&now)); ++#endif + if (imn->type == -1) + done = 1; + if (imn->func != NULL) +@@ -509,7 +516,11 @@ + printf("\t%8s\ttotal: %llu sessions\n" + "\t%8s\tlast: %u/%us %u/h %u/d sessions\n" + "\t%8s\taverage: %u/%us %u/h %u/d sessions\n", ++#ifdef __FreeBSD__ ++ "", (long long unsigned)crs.cnt, ++#else + "", crs.cnt, ++#endif + "", crs.last, crs.interval, + crs.last_hour, crs.last_day, + "", crs.avg, crs.interval, Index: files/patch-freebsd-relayd =================================================================== RCS file: files/patch-freebsd-relayd diff -N files/patch-freebsd-relayd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-freebsd-relayd 27 May 2010 09:35:52 -0000 @@ -0,0 +1,709 @@ +diff -Naur relayd.orig/Makefile relayd/Makefile +--- relayd.orig/Makefile 2010-05-27 11:05:52.874794374 +0200 ++++ relayd/Makefile 2010-05-27 11:05:58.265594265 +0200 +@@ -3,17 +3,27 @@ + PROG= relayd + SRCS= parse.y log.c control.c buffer.c imsg.c ssl.c ssl_privsep.c \ + relayd.c pfe.c pfe_filter.c hce.c relay.c relay_udp.c \ +- carp.c check_icmp.c check_tcp.c check_script.c name2id.c \ +- snmp.c shuffle.c ++ check_icmp.c check_tcp.c check_script.c name2id.c \ ++ shuffle.c + MAN= relayd.8 relayd.conf.5 + +-LDADD= -levent -lssl -lcrypto ++LDADD= -lmd -L${PREFIX}/lib -levent -lssl -lcrypto + DPADD= ${LIBEVENT} ${LIBSSL} ${LIBCRYPTO} +-CFLAGS+= -Wall -I${.CURDIR} -I${.CURDIR}/../snmpd ++CFLAGS+= -Wall -I${.CURDIR} -I${PREFIX}/include -D__dead='' \ ++ -DSHA1_DIGEST_LENGTH=SHA_DIGEST_LENGTH \ ++ -DSHA1_DIGEST_STRING_LENGTH=SHA_DIGEST_LENGTH \ ++ -DOPENSSL_NO_SHA -DOPENSSL_NO_MD5 + CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes + CFLAGS+= -Wmissing-declarations + CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual +-CFLAGS+= -Wsign-compare -Wbounded ++CFLAGS+= -Wsign-compare + CLEANFILES+= y.tab.h + ++install: ++ $(INSTALL) -m 555 -g wheel -o root relayd $(PREFIX)/sbin ++ ++install-man: ++ $(INSTALL) -m 444 -g wheel -o root relayd.conf.5 $(PREFIX)/man/man5 ++ $(INSTALL) -m 444 -g wheel -o root relayd.8 $(PREFIX)/man/man8 ++ + .include +diff -Naur relayd.orig/check_tcp.c relayd/check_tcp.c +--- relayd.orig/check_tcp.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/check_tcp.c 2010-05-27 11:05:58.269605038 +0200 +@@ -31,7 +31,7 @@ + #include + #include + #include +-#include ++#include + + #include + +@@ -285,7 +285,11 @@ + if (b == NULL) + fatal("out of memory"); + *b = '\0'; ++#ifndef __FreeBSD__ + if (fnmatch(cte->table->conf.exbuf, cte->buf->buf, 0) == 0) { ++#else ++ if (fnmatch(cte->table->conf.exbuf, (char *)cte->buf->buf, 0) == 0) { ++#endif + cte->host->he = HCE_SEND_EXPECT_OK; + cte->host->up = HOST_UP; + return (0); +@@ -318,7 +322,11 @@ + fatal("out of memory"); + *b = '\0'; + ++#ifndef __FreeBSD__ + head = cte->buf->buf; ++#else ++ head = (char *)cte->buf->buf; ++#endif + host = cte->host; + host->he = HCE_HTTP_CODE_ERROR; + +@@ -370,7 +378,11 @@ + fatal("out of memory"); + *b = '\0'; + ++#ifndef __FreeBSD__ + head = cte->buf->buf; ++#else ++ head = (char *)cte->buf->buf; ++#endif + host = cte->host; + host->he = HCE_HTTP_DIGEST_ERROR; + +@@ -382,7 +394,11 @@ + } + head += strlen("\r\n\r\n"); + ++#ifndef __FreeBSD__ + digeststr(cte->table->conf.digest_type, head, strlen(head), digest); ++#else ++ digeststr(cte->table->conf.digest_type, (u_int8_t*)head, strlen(head), digest); ++#endif + + if (strcmp(cte->table->conf.digest, digest)) { + log_warnx("check_http_digest: %s failed " +diff -Naur relayd.orig/hce.c relayd/hce.c +--- relayd.orig/hce.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/hce.c 2010-05-27 11:05:58.270605497 +0200 +@@ -167,7 +167,7 @@ + struct timeval tv; + struct table *table; + +- snmp_init(env, iev_main); ++// snmp_init(env, iev_main); + + if (!TAILQ_EMPTY(env->sc_tables)) { + evtimer_set(&env->sc_ev, hce_launch_checks, env); +@@ -336,8 +336,10 @@ + print_availability(host->check_cnt, host->up_cnt)); + } + ++/* + if (host->last_up != host->up) + snmp_hosttrap(table, host); ++*/ + + host->last_up = host->up; + +diff -Naur relayd.orig/log.c relayd/log.c +--- relayd.orig/log.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/log.c 2010-05-27 11:05:58.271605396 +0200 +@@ -16,7 +16,11 @@ + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include ++#else + #include ++#endif + #include + #include + #include +diff -Naur relayd.orig/parse.y relayd/parse.y +--- relayd.orig/parse.y 2010-05-27 11:05:52.874794374 +0200 ++++ relayd/parse.y 2010-05-27 11:07:06.666448151 +0200 +@@ -343,6 +343,7 @@ + } + conf->sc_prefork_relay = $2; + } ++/* FreeBSD exclude + | DEMOTE STRING { + conf->sc_flags |= F_DEMOTE; + if (strlcpy(conf->sc_demote_group, $2, +@@ -360,6 +361,7 @@ + } + } + | SEND TRAP { conf->sc_flags |= F_TRAP; } ++*/ + ; + + loglevel : UPDATES { $$ = RELAYD_OPT_LOGUPDATE; } +@@ -615,6 +617,7 @@ + bcopy(&$2, &table->conf.timeout, + sizeof(struct timeval)); + } ++/* FreeBSD exclude + | DEMOTE STRING { + table->conf.flags |= F_DEMOTE; + if (strlcpy(table->conf.demote_group, $2, +@@ -632,6 +635,7 @@ + YYERROR; + } + } ++*/ + | INTERVAL NUMBER { + if ($2 < conf->sc_interval.tv_sec || + $2 % conf->sc_interval.tv_sec) { +@@ -1562,7 +1566,7 @@ + { "ciphers", CIPHERS }, + { "code", CODE }, + { "cookie", COOKIE }, +- { "demote", DEMOTE }, ++// FreeBSD { "demote", DEMOTE }, + { "digest", DIGEST }, + { "disable", DISABLE }, + { "error", ERROR }, +@@ -1625,7 +1629,7 @@ + { "timeout", TIMEOUT }, + { "to", TO }, + { "transparent", TRANSPARENT }, +- { "trap", TRAP }, ++// FreeBSD { "trap", TRAP }, + { "ttl", TTL }, + { "updates", UPDATES }, + { "url", URL }, +@@ -2260,7 +2264,8 @@ + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; /* DUMMY */ + error = getaddrinfo(s, NULL, &hints, &res0); +- if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) ++// if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) ++ if (error == EAI_AGAIN || error == EAI_NONAME) + return (0); + if (error) { + log_warnx("host_dns: could not parse \"%s\": %s", s, +diff -Naur relayd.orig/pfe.c relayd/pfe.c +--- relayd.orig/pfe.c 2010-05-27 11:05:52.874794374 +0200 ++++ relayd/pfe.c 2010-05-27 11:05:58.276615510 +0200 +@@ -17,6 +17,9 @@ + */ + + #include ++#ifdef __FreeBSD__ ++#include ++#endif + #include + #include + #include +@@ -859,7 +862,9 @@ + struct table *table; + struct ctl_id id; + struct imsg imsg; ++#ifndef __FreeBSD__ + struct ctl_demote demote; ++#endif + + bzero(&id, sizeof(id)); + bzero(&imsg, sizeof(imsg)); +@@ -920,6 +925,7 @@ + */ + table->conf.flags &= ~(F_CHANGED); + ++#ifndef __FreeBSD__ + /* + * handle demotion. + */ +@@ -942,6 +948,7 @@ + sizeof(demote.group)); + imsg_compose_event(iev_main, IMSG_DEMOTE, 0, 0, -1, + &demote, sizeof(demote)); ++#endif + } + } + +diff -Naur relayd.orig/pfe_filter.c relayd/pfe_filter.c +--- relayd.orig/pfe_filter.c 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/pfe_filter.c 2010-05-27 11:05:58.277615689 +0200 +@@ -97,6 +97,10 @@ + sizeof(tables[i].pfrt_name)) + goto toolong; + tables[i].pfrt_flags |= PFR_TFLAG_PERSIST; ++#ifdef __FreeBSD__ ++ log_debug("init_tables: prepare anchor \"%s\" and table \"%s\"", ++#endif ++ tables[i].pfrt_anchor, tables[i].pfrt_name); + i++; + } + if (i != env->sc_rdrcount) +@@ -280,12 +284,11 @@ + } + + psnk.psnk_af = host->conf.ss.ss_family; +- psnk.psnk_killed = 0; + + if (ioctl(env->sc_pf->dev, + DIOCKILLSRCNODES, &psnk) == -1) + fatal("kill_srcnodes: cannot kill src nodes"); +- cnt += psnk.psnk_killed; ++ cnt += psnk.psnk_af; + } + + return (cnt); +@@ -370,7 +373,11 @@ + struct sockaddr_in6 *sain6; + struct address *address; + char anchor[PF_ANCHOR_NAME_SIZE]; ++#ifndef __FreeBSD__ + int rs; ++#else ++ int rs = 0; ++#endif + struct table *t = rdr->table; + + if (!(env->sc_flags & F_NEEDPF)) +@@ -418,7 +425,9 @@ + + /* Use sloppy state handling for half connections */ + rio.rule.keep_state = PF_STATE_NORMAL; ++#if 0 + rio.rule.rule_flag = PFRULE_STATESLOPPY; ++#endif + break; + default: + fatalx("sync_ruleset: invalid forward mode"); +@@ -437,7 +446,9 @@ + rio.rule.dst.port_op = address->port.op; + rio.rule.dst.port[0] = address->port.val[0]; + rio.rule.dst.port[1] = address->port.val[1]; ++#if 0 + rio.rule.rtableid = -1; /* stay in the main routing table */ ++#endif + + if (rio.rule.proto == IPPROTO_TCP) + rio.rule.timeout[PFTM_TCP_ESTABLISHED] = +diff -Naur relayd.orig/relay.c relayd/relay.c +--- relayd.orig/relay.c 2010-05-27 11:05:52.872794016 +0200 ++++ relayd/relay.c 2010-05-27 11:05:58.280728536 +0200 +@@ -16,7 +16,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include ++#else + #include ++#endif + #include + #include + #include +@@ -683,6 +687,7 @@ + &val, sizeof(val)) == -1) + goto bad; + } ++#ifndef __FreeBSD__ + if (proto->tcpflags & (TCPFLAG_SACK|TCPFLAG_NSACK)) { + if (proto->tcpflags & TCPFLAG_NSACK) + val = 0; +@@ -692,6 +697,7 @@ + &val, sizeof(val)) == -1) + goto bad; + } ++#endif + + return (s); + +@@ -1027,7 +1033,11 @@ + } + if (strstr(val, "$TIMEOUT") != NULL) { + snprintf(ibuf, sizeof(ibuf), "%lu", ++#ifdef __FreeBSD__ ++ (unsigned long)rlay->rl_conf.timeout.tv_sec); ++#else + rlay->rl_conf.timeout.tv_sec); ++#endif + if (expand_string(buf, len, "$TIMEOUT", ibuf) != 0) + return (NULL); + } +@@ -1624,7 +1634,11 @@ + switch (type) { + case DIGEST_SHA1: + case DIGEST_MD5: ++#ifdef __FreeBSD__ ++ if ((md = digeststr(type, (u_int8_t*)val, strlen(val), NULL)) == NULL) { ++#else + if ((md = digeststr(type, val, strlen(val), NULL)) == NULL) { ++#endif + relay_close_http(con, 500, + "failed to allocate digest", 0); + goto fail; +@@ -2642,8 +2656,12 @@ + goto err; + + /* Set session context to the local relay name */ +- if (!SSL_CTX_set_session_id_context(ctx, rlay->rl_conf.name, +- strlen(rlay->rl_conf.name))) ++ if (!SSL_CTX_set_session_id_context(ctx, ++#ifdef __FreeBSD__ ++ (unsigned char*)rlay->rl_conf.name, strlen(rlay->rl_conf.name))) ++#else ++ rlay->rl_conf.name, strlen(rlay->rl_conf.name))) ++#endif + goto err; + + return (ctx); +@@ -3104,7 +3122,11 @@ + if (fstat(fd, &st) != 0) + goto fail; + size = st.st_size; ++#ifndef __FreeBSD__ + if ((buf = (char *)calloc(1, size + 1)) == NULL) ++#else ++ if ((buf = (u_int8_t *)calloc(1, size + 1)) == NULL) ++#endif + goto fail; + if (read(fd, buf, size) != size) + goto fail; +@@ -3112,7 +3134,11 @@ + close(fd); + + *len = size + 1; ++#ifndef __FreeBSD__ + return (buf); ++#else ++ return (char *)(buf); ++#endif + + fail: + if (buf != NULL) +diff -Naur relayd.orig/relay_udp.c relayd/relay_udp.c +--- relayd.orig/relay_udp.c 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/relay_udp.c 2010-05-27 11:05:58.281790178 +0200 +@@ -16,7 +16,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include ++#else + #include ++#endif + #include + #include + #include +diff -Naur relayd.orig/relayd.8 relayd/relayd.8 +--- relayd.orig/relayd.8 2010-05-27 11:05:52.871795234 +0200 ++++ relayd/relayd.8 2010-05-27 11:05:58.282841763 +0200 +@@ -117,7 +117,7 @@ + .It Fl f Ar file + Specify an alternative configuration file. + The default is +-.Pa /etc/relayd.conf . ++.Pa %%PREFIX%%/etc/relayd.conf . + .It Fl n + Configtest mode. + Only check the configuration file for validity. +@@ -126,7 +126,7 @@ + .El + .Sh FILES + .Bl -tag -width "/var/run/relayd.sockXX" -compact +-.It /etc/relayd.conf ++.It %%PREFIX%%/etc/relayd.conf + Default configuration file. + .It /var/run/relayd.sock + Unix-domain socket used for communication with +diff -Naur relayd.orig/relayd.c relayd/relayd.c +--- relayd.orig/relayd.c 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/relayd.c 2010-05-27 11:05:58.284862515 +0200 +@@ -17,7 +17,11 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#ifdef __FreeBSD__ ++#include ++#else + #include ++#endif + #include + #include + #include +@@ -37,7 +41,11 @@ + #include + #include + #include ++#ifdef __FreeBSD__ ++#include ++#else + #include ++#endif + #include + + #include +@@ -292,9 +300,10 @@ + iev_hce->handler, iev_hce); + event_add(&iev_hce->ev, NULL); + ++#ifndef __FreeBSD__ + if (env->sc_flags & F_DEMOTE) + carp_demote_reset(env->sc_demote_group, 0); +- ++#endif + event_dispatch(); + + return (0); +@@ -319,9 +328,11 @@ + } while (pid != -1 || (pid == -1 && errno == EINTR)); + + control_cleanup(); ++#ifndef __FreeBSD__ + carp_demote_shutdown(); + if (env->sc_flags & F_DEMOTE) + carp_demote_reset(env->sc_demote_group, 128); ++#endif + log_info("terminating"); + exit(0); + } +@@ -383,8 +394,10 @@ + memcpy(&env->sc_proto_default, &new_env->sc_proto_default, + sizeof(env->sc_proto_default)); + env->sc_prefork_relay = new_env->sc_prefork_relay; ++#ifndef __FreeBSD__ + (void)strlcpy(env->sc_demote_group, new_env->sc_demote_group, + sizeof(env->sc_demote_group)); ++#endif + + env->sc_tables = new_env->sc_tables; + env->sc_rdrs = new_env->sc_rdrs; +@@ -610,7 +623,9 @@ + struct imsgbuf *ibuf; + struct imsg imsg; + ssize_t n; ++#ifndef __FreeBSD__ + struct ctl_demote demote; ++#endif + + iev = ptr; + ibuf = &iev->ibuf; +@@ -638,6 +653,7 @@ + break; + + switch (imsg.hdr.type) { ++#ifndef __FreeBSD__ + case IMSG_DEMOTE: + if (imsg.hdr.len - IMSG_HEADER_SIZE != + sizeof(demote)) +@@ -646,6 +662,7 @@ + memcpy(&demote, imsg.data, sizeof(demote)); + carp_demote_set(demote.group, demote.level); + break; ++#endif + case IMSG_CTL_RELOAD: + /* + * so far we only get here if no L7 (relay) is done. +@@ -709,9 +726,11 @@ + imsg_compose_event(iev_hce, IMSG_SCRIPT, + 0, 0, -1, &scr, sizeof(scr)); + break; ++/* + case IMSG_SNMPSOCK: + (void)snmp_sendsock(iev); + break; ++*/ + default: + log_debug("main_dispatch_hce: unexpected imsg %d", + imsg.hdr.type); +@@ -1021,7 +1040,11 @@ + { + switch (type) { + case DIGEST_SHA1: ++#ifdef __FreeBSD__ ++ return (SHA1_Data(data, len, buf)); ++#else + return (SHA1Data(data, len, buf)); ++#endif + break; + case DIGEST_MD5: + return (MD5Data(data, len, buf)); +@@ -1258,9 +1281,11 @@ + bnd->bnd_proto == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM, + bnd->bnd_proto)) == -1) + goto fail; ++#ifndef __FreeBSD__ + if (setsockopt(s, SOL_SOCKET, SO_BINDANY, + &v, sizeof(v)) == -1) + goto fail; ++#endif + if (bind(s, (struct sockaddr *)&bnd->bnd_ss, + bnd->bnd_ss.ss_len) == -1) + goto fail; +diff -Naur relayd.orig/relayd.conf.5 relayd/relayd.conf.5 +--- relayd.orig/relayd.conf.5 2010-05-27 11:05:52.873793915 +0200 ++++ relayd/relayd.conf.5 2010-05-27 11:05:58.285863811 +0200 +@@ -103,17 +103,6 @@ + .Sh GLOBAL CONFIGURATION + Here are the settings that can be set globally: + .Bl -tag -width Ds +-.It Ic demote Ar group +-Enable the global +-.Xr carp 4 +-demotion option, resetting the carp demotion counter for the +-specified interface group to zero on startup and to 128 on shutdown of +-the daemon. +-For more information on interface groups, +-see the +-.Ic group +-keyword in +-.Xr ifconfig 8 . + .It Ic interval Ar number + Set the interval in seconds at which the hosts will be checked. + The default interval is 10 seconds. +@@ -143,15 +132,6 @@ + .Xr relayd 8 + runs 5 relay processes by default and every process will handle + all configured relays. +-.It Ic send trap +-Send an SNMP trap when the state of a host changes. +-.Xr relayd 8 +-will try to connect to +-.Xr snmpd 8 +-and request it send a trap to the registered trap receivers; +-see +-.Xr snmpd.conf 5 +-for more information about the configuration. + .It Ic timeout Ar number + Set the global timeout in milliseconds for checks. + This can be overridden by the timeout value in the table definitions. +@@ -349,17 +329,6 @@ + .Pp + The following general table options are available: + .Bl -tag -width Ds +-.It Ic demote Ar group +-Enable the per-table +-.Xr carp 4 +-demotion option. +-This will increment the carp demotion counter for the +-specified interface group if all hosts in the table are down. +-For more information on interface groups, +-see the +-.Ic group +-keyword in +-.Xr ifconfig 8 . + .It Ic interval Ar number + Override the global interval and specify one for this table. + It must be a multiple of the global interval. +@@ -1037,7 +1006,7 @@ + .El + .Sh FILES + .Bl -tag -width "/etc/ssl/private/address.keyXX" -compact +-.It Pa /etc/relayd.conf ++.It Pa %%PREFIX%%/etc/relayd.conf + .Xr relayd 8 + configuration file. + .Pp +@@ -1146,7 +1115,6 @@ + .Sh SEE ALSO + .Xr relayctl 8 , + .Xr relayd 8 , +-.Xr snmpd 8 , + .Xr ssl 8 + .Sh HISTORY + The +diff -Naur relayd.orig/relayd.h relayd/relayd.h +--- relayd.orig/relayd.h 2010-05-27 11:05:52.871795234 +0200 ++++ relayd/relayd.h 2010-05-27 11:05:58.286913720 +0200 +@@ -19,10 +19,18 @@ + */ + + #include ++#ifdef __FreeBSD__ ++#include ++#include ++#endif + + #include + ++#ifdef __FreeBSD__ ++#define CONF_FILE "%%PREFIX%%/etc/relayd.conf" ++#else + #define CONF_FILE "/etc/relayd.conf" ++#endif + #define RELAYD_SOCKET "/var/run/relayd.sock" + #define PF_SOCKET "/dev/pf" + #define RELAYD_USER "_relayd" +@@ -57,7 +65,18 @@ + #define PURGE_PROTOS 0x08 + #define PURGE_EVERYTHING 0xff + ++#ifndef __FreeBSD__ + #define SNMP_RECONNECT_TIMEOUT { 3, 0 } /* sec, usec */ ++#else ++#define SIMPLEQ_HEAD STAILQ_HEAD ++#define SIMPLEQ_FIRST STAILQ_FIRST ++#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD ++#define SIMPLEQ_ENTRY STAILQ_ENTRY ++#define SIMPLEQ_INIT STAILQ_INIT ++#define SIMPLEQ_EMPTY STAILQ_EMPTY ++#define SIMPLEQ_NEXT STAILQ_NEXT ++#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL ++#endif + + #if DEBUG > 1 + #define DPRINTF log_debug +@@ -607,10 +626,11 @@ + struct event sc_statev; + struct timeval sc_statinterval; + ++#ifndef __FreeBSD__ + int sc_snmp; + struct event sc_snmpto; + struct event sc_snmpev; +- ++#endif + int sc_has_icmp; + int sc_has_icmp6; + struct ctl_icmp_event sc_icmp_send; +@@ -688,7 +708,9 @@ + IMSG_HOST_STATUS, /* notifies from hce to pfe */ + IMSG_SYNC, + IMSG_NATLOOK, ++#ifndef __FreeBSD__ + IMSG_DEMOTE, ++#endif + IMSG_STATISTICS, + IMSG_RECONF, /* reconfiguration notifies */ + IMSG_RECONF_TABLE, +@@ -704,7 +726,9 @@ + IMSG_RECONF_RELAY, + IMSG_RECONF_END, + IMSG_SCRIPT, ++#ifndef __FreeBSD__ + IMSG_SNMPSOCK, ++#endif + IMSG_BINDANY + }; + +@@ -857,10 +881,12 @@ + void pn_unref(u_int16_t); + void pn_ref(u_int16_t); + ++#ifndef __FreeBSD__ + /* snmp.c */ + void snmp_init(struct relayd *, struct imsgev *); + int snmp_sendsock(struct imsgev *); + void snmp_hosttrap(struct table *, struct host *); ++#endif + + /* shuffle.c */ + void shuffle_init(struct shuffle *); Index: files/patch-relayctl-parser.c =================================================================== RCS file: files/patch-relayctl-parser.c diff -N files/patch-relayctl-parser.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayctl-parser.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,20 @@ +--- relayctl/parser.c.orig 2010-05-27 11:10:01.109068426 +0200 ++++ relayctl/parser.c 2010-05-27 11:11:24.194566616 +0200 +@@ -166,7 +166,7 @@ + } + + const struct token * +-match_token(const char *word, const struct token table[]) ++match_token(const char *word, const struct token *table) + { + u_int i, match; + const struct token *t = NULL; +@@ -243,7 +243,7 @@ + } + + void +-show_valid_args(const struct token table[]) ++show_valid_args(const struct token *table) + { + int i; + Index: files/patch-relayctl-relayctl.c =================================================================== RCS file: files/patch-relayctl-relayctl.c diff -N files/patch-relayctl-relayctl.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayctl-relayctl.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,27 @@ +--- relayctl/relayctl.c.orig 2010-05-27 11:10:01.111140304 +0200 ++++ relayctl/relayctl.c 2010-05-27 11:10:16.855173170 +0200 +@@ -86,6 +86,7 @@ + }; + + struct imsgbuf *ibuf; ++int error = 0; + + __dead void + usage(void) +@@ -235,7 +236,7 @@ + close(ctl_sock); + free(ibuf); + +- return (0); ++ return (error ? 1 : 0); + } + + struct imsgname * +@@ -431,6 +432,7 @@ + break; + case IMSG_CTL_FAIL: + printf("command failed\n"); ++ error++; + break; + default: + errx(1, "wrong message in summary: %u", imsg->hdr.type); Index: files/patch-relayd-check_icmp.c =================================================================== RCS file: files/patch-relayd-check_icmp.c diff -N files/patch-relayd-check_icmp.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayd-check_icmp.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,11 @@ +--- relayd/check_icmp.c.orig 2009-08-07 13:32:54.000000000 +0200 ++++ relayd/check_icmp.c 2010-05-27 11:22:12.631744485 +0200 +@@ -150,7 +150,7 @@ + if (((struct sockaddr *)&host->conf.ss)->sa_family != + cie->af) + continue; +- if (!(host->flags & F_CHECK_DONE)) { ++ if (!(host->flags & (F_CHECK_DONE|F_DISABLE))) { + host->up = HOST_DOWN; + hce_notify_done(host, he); + } Index: files/patch-relayd-check_tcp.c =================================================================== RCS file: files/patch-relayd-check_tcp.c diff -N files/patch-relayd-check_tcp.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayd-check_tcp.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,10 @@ +--- relayd/check_tcp.c.orig 2010-05-27 11:10:01.114202025 +0200 ++++ relayd/check_tcp.c 2010-05-27 11:22:55.453595437 +0200 +@@ -99,6 +99,7 @@ + + cte->buf = NULL; + cte->host->up = HOST_UP; ++ event_del(&cte->ev); + event_set(&cte->ev, s, EV_TIMEOUT|EV_WRITE, tcp_write, cte); + event_add(&cte->ev, &tv); + return; Index: files/patch-relayd-control.c =================================================================== RCS file: files/patch-relayd-control.c diff -N files/patch-relayd-control.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayd-control.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,11 @@ +--- relayd/control.c.orig 2009-06-06 01:39:51.000000000 +0200 ++++ relayd/control.c 2010-05-27 10:41:16.689809156 +0200 +@@ -142,7 +142,7 @@ + + session_socket_blockmode(connfd, BM_NONBLOCK); + +- if ((c = malloc(sizeof(struct ctl_conn))) == NULL) { ++ if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) { + close(connfd); + log_warn("control_accept"); + return; Index: files/patch-relayd-relay.c =================================================================== RCS file: files/patch-relayd-relay.c diff -N files/patch-relayd-relay.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayd-relay.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,52 @@ +--- relayd/relay.c.orig 2010-05-27 11:10:01.121571779 +0200 ++++ relayd/relay.c 2010-05-27 11:21:34.847047990 +0200 +@@ -105,6 +105,7 @@ + char *, size_t); + void relay_close_http(struct rsession *, u_int, const char *, + u_int16_t); ++void relay_http_request_close(struct ctl_relay_event *); + + SSL_CTX *relay_ssl_ctx_create(struct relay *); + void relay_ssl_transaction(struct rsession *, +@@ -1312,6 +1313,29 @@ + } + + void ++relay_http_request_close(struct ctl_relay_event *cre) ++{ ++ if (cre->path != NULL) { ++ free(cre->path); ++ cre->path = NULL; ++ } ++ ++ cre->args = NULL; ++ cre->version = NULL; ++ ++ if (cre->buf != NULL) { ++ free(cre->buf); ++ cre->buf = NULL; ++ cre->buflen = 0; ++ } ++ ++ cre->line = 0; ++ cre->method = 0; ++ cre->done = 0; ++ cre->chunked = 0; ++} ++ ++void + relay_read_http(struct bufferevent *bev, void *arg) + { + struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; +@@ -1580,10 +1604,7 @@ + if (relay_bufferevent_print(cre->dst, "\r\n") == -1) + goto fail; + +- cre->line = 0; +- cre->method = 0; +- cre->done = 0; +- cre->chunked = 0; ++ relay_http_request_close(cre); + + done: + if (cre->dir == RELAY_DIR_REQUEST && !cre->toread && Index: files/patch-relayd-relayd.c =================================================================== RCS file: files/patch-relayd-relayd.c diff -N files/patch-relayd-relayd.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-relayd-relayd.c 27 May 2010 09:35:52 -0000 @@ -0,0 +1,27 @@ +--- relayd/relayd.c.orig 2010-05-27 11:19:46.619119949 +0200 ++++ relayd/relayd.c 2010-05-27 11:20:21.164983766 +0200 +@@ -306,6 +306,8 @@ + #endif + event_dispatch(); + ++ main_shutdown(env); ++ /* NOTREACHED */ + return (0); + } + +@@ -972,6 +974,7 @@ + if (timercmp(&tv_next, &tv, >)) + bcopy(&tv_next, &tv, sizeof(tv)); + ++ event_del(ev); + event_set(ev, fd, event, fn, arg); + event_add(ev, &tv); + } +@@ -1129,6 +1132,7 @@ + } + pn->key = strdup(pk->key); + if (pn->key == NULL) { ++ free(pn); + log_warn("out of memory"); + return (NULL); + } Index: files/pkg-install.in =================================================================== RCS file: files/pkg-install.in diff -N files/pkg-install.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/pkg-install.in 27 May 2010 09:35:52 -0000 @@ -0,0 +1,36 @@ +#!/bin/sh +# +# $FreeBSD$ + +case $2 in +PRE-INSTALL) + USER=%%RUSER%% + GROUP=%%RGROUP%% + UID=913 + GID=913 + + if pw group show "${GROUP}" 2>/dev/null; then + echo "You already have a group \"${GROUP}\", so I will use it." + else + if pw groupadd ${GROUP} -g ${GID}; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + if pw user show "${USER}" 2>/dev/null; then + echo "You already have a user \"${USER}\", so I will use it." + else + if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \ + -d /var/empty -c "Relay Daemon" -s /usr/sbin/nologin + then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi + fi + ;; +esac