[honeyd/f15] libevent2 build (patch from madriva)

Peter Vrabec pvrabec at fedoraproject.org
Tue Jul 26 11:28:58 UTC 2011


commit 5ffe69a829eaf3294c8099ad34097e4f2acbaaa0
Author: Peter Vrabec <pvrabec at redhat.com>
Date:   Tue Jul 26 13:27:44 2011 +0200

    libevent2 build (patch from madriva)

 honeyd-1.5c-libevent2.patch |  211 +++++++++++++++++++++++++++++++++++++++++++
 honeyd.spec                 |    7 ++-
 2 files changed, 217 insertions(+), 1 deletions(-)
---
diff --git a/honeyd-1.5c-libevent2.patch b/honeyd-1.5c-libevent2.patch
new file mode 100644
index 0000000..34897ee
--- /dev/null
+++ b/honeyd-1.5c-libevent2.patch
@@ -0,0 +1,211 @@
+diff -up honeyd-1.5c/honeydstats.c.libevent2 honeyd-1.5c/honeydstats.c
+--- honeyd-1.5c/honeydstats.c.libevent2	2007-05-28 08:12:52.000000000 +0200
++++ honeyd-1.5c/honeydstats.c	2011-07-26 13:18:14.459666984 +0200
+@@ -330,30 +330,43 @@ signature_process(struct evbuffer *evbuf
+ static int
+ signature_length(struct evbuffer *evbuf)
+ {
+-	struct evbuffer tmp;
++	struct evbuffer *tmp;
+ 	uint32_t length, tlen;
+ 
+-	tmp = *evbuf;
+-
++	tmp = evbuffer_new();
++	tmp = evbuffer_add_reference(tmp, evbuffer_pullup(evbuf, -1),
++				     evbuffer_get_length(evbuf), NULL, NULL);
+ 	/* name */
+-	if (tag_peek_length(&tmp, &tlen) == -1 || EVBUFFER_LENGTH(&tmp) < tlen)
++	if (tag_peek_length(tmp, &tlen) == -1 || EVBUFFER_LENGTH(tmp) < tlen) {
++		evbuffer_free(tmp);
+ 		return (-1);
++	}
++
++	if (evbuffer_drain(tmp, tlen) == -1) {
++		evbuffer_free(tmp);
++		return (-1);
++	}
+ 		
+ 	length = tlen;
+-	tmp.buffer += tlen;
+-	tmp.off -= tlen;
+ 
+ 	/* signature */
+-	if (tag_peek_length(&tmp, &tlen) == -1 || EVBUFFER_LENGTH(&tmp) < tlen)
++	if (tag_peek_length(tmp, &tlen) == -1 || EVBUFFER_LENGTH(tmp) < tlen) {
++		evbuffer_free(tmp);
+ 		return (-1);
++	}
+ 		
++	if (evbuffer_drain(tmp, tlen) == -1) {
++		evbuffer_free(tmp);
++		return (-1);
++	}
++
+ 	length += tlen;
+-	tmp.buffer += tlen;
+-	tmp.off -= tlen;
+ 
+ 	/* data */
+-	if (tag_peek_length(&tmp, &tlen) == -1 || EVBUFFER_LENGTH(&tmp) < tlen)
++	if (tag_peek_length(tmp, &tlen) == -1 || EVBUFFER_LENGTH(tmp) < tlen) {
++		evbuffer_free(tmp);
+ 		return (-1);
++	}
+ 		
+ 	length += tlen;
+ 
+diff -up honeyd-1.5c/tagging.c.libevent2 honeyd-1.5c/tagging.c
+--- honeyd-1.5c/tagging.c.libevent2	2007-05-28 08:12:52.000000000 +0200
++++ honeyd-1.5c/tagging.c	2011-07-26 13:18:14.460666991 +0200
+@@ -73,7 +73,7 @@ tagging_init()
+  */
+ 
+ void
+-encode_int(struct evbuffer *evbuf, uint32_t number)
++encode__int(struct evbuffer *evbuf, uint32_t number)
+ {
+ 	int off = 1, nibbles = 0;
+ 	uint8_t data[5];
+@@ -108,7 +108,7 @@ void
+ tag_marshal(struct evbuffer *evbuf, uint8_t tag, void *data, uint16_t len)
+ {
+ 	evbuffer_add(evbuf, &tag, sizeof(tag));
+-	encode_int(evbuf, len);
++	encode__int(evbuf, len);
+ 	evbuffer_add(evbuf, data, len);
+ }
+ 
+@@ -117,10 +117,10 @@ void
+ tag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer)
+ {
+ 	evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
+-	encode_int(_buf, integer);
++	encode__int(_buf, integer);
+ 
+ 	evbuffer_add(evbuf, &tag, sizeof(tag));
+-	encode_int(evbuf, EVBUFFER_LENGTH(_buf));
++	encode__int(evbuf, EVBUFFER_LENGTH(_buf));
+ 	evbuffer_add_buffer(evbuf, _buf);
+ }
+ 
+@@ -135,8 +135,8 @@ tag_marshal_timeval(struct evbuffer *evb
+ {
+ 	evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
+ 
+-	encode_int(_buf, tv->tv_sec);
+-	encode_int(_buf, tv->tv_usec);
++	encode__int(_buf, tv->tv_sec);
++	encode__int(_buf, tv->tv_usec);
+ 
+ 	tag_marshal(evbuf, tag, EVBUFFER_DATA(_buf),
+ 	    EVBUFFER_LENGTH(_buf));
+diff -up honeyd-1.5c/tagging.h.libevent2 honeyd-1.5c/tagging.h
+--- honeyd-1.5c/tagging.h.libevent2	2007-05-28 08:12:52.000000000 +0200
++++ honeyd-1.5c/tagging.h	2011-07-26 13:18:14.461666999 +0200
+@@ -86,7 +86,7 @@ void addr_marshal(struct evbuffer *, str
+ void tag_marshal(struct evbuffer *evbuf, uint8_t tag, void *data,
+     uint16_t len);
+ 
+-void encode_int(struct evbuffer *evbuf, uint32_t number);
++void encode__int(struct evbuffer *evbuf, uint32_t number);
+ 
+ void tag_marshal_int(struct evbuffer *evbuf, uint8_t tag, uint32_t integer);
+ 
+diff -up honeyd-1.5c/ui.c.libevent2 honeyd-1.5c/ui.c
+--- honeyd-1.5c/ui.c.libevent2	2007-05-28 08:12:52.000000000 +0200
++++ honeyd-1.5c/ui.c	2011-07-26 13:18:14.459666984 +0200
+@@ -246,7 +246,8 @@ ui_writer(int fd, short what, void *arg)
+ 	struct evbuffer *buffer = client->outbuf;
+ 	int n;
+ 
+-	n = write(fd, buffer->buffer, buffer->off);
++	n = write(fd, evbuffer_pullup(buffer, -1),
++		  evbuffer_get_length(buffer));
+ 	if (n == -1) {
+ 		if (errno == EINTR || errno == EAGAIN)
+ 			goto schedule;
+@@ -260,7 +261,7 @@ ui_writer(int fd, short what, void *arg)
+ 	evbuffer_drain(buffer, n);
+ 
+  schedule:
+-	if (buffer->off)
++	if (evbuffer_get_length(buffer))
+ 		event_add(&client->ev_write, NULL);
+ }
+ 
+@@ -277,8 +278,8 @@ ui_handler(int fd, short what, void *arg
+ 		return;
+ 	}
+ 
+-	n = mybuf->off;
+-	p = mybuf->buffer;
++	n = evbuffer_get_length (mybuf);
++	p = evbuffer_pullup (mybuf, -1);
+ 	consumed = 0;
+ 	while (n--) {
+ 		consumed++;
+@@ -289,11 +290,12 @@ ui_handler(int fd, short what, void *arg
+ 		 */
+ 		if (*p == '\n') {
+ 			*p = '\0';
+-			ui_handle_command(client->outbuf, mybuf->buffer);
++			ui_handle_command(client->outbuf,
++					  evbuffer_pullup(mybuf, -1));
+ 
+ 			evbuffer_drain(mybuf, consumed);
+-			n = mybuf->off;
+-			p = mybuf->buffer;
++			n = evbuffer_get_length (mybuf);
++			p = evbuffer_pullup (mybuf, -1);
+ 			consumed = 0;
+ 			continue;
+ 		}
+diff -up honeyd-1.5c/untagging.c.libevent2 honeyd-1.5c/untagging.c
+--- honeyd-1.5c/untagging.c.libevent2	2007-05-28 08:12:52.000000000 +0200
++++ honeyd-1.5c/untagging.c	2011-07-26 13:18:14.461666999 +0200
+@@ -114,22 +114,29 @@ tag_peek(struct evbuffer *evbuf, uint8_t
+ int
+ tag_peek_length(struct evbuffer *evbuf, uint32_t *plength)
+ {
+-	struct evbuffer tmp;
++	struct evbuffer *tmp;
+ 	int res;
+ 
+ 	if (EVBUFFER_LENGTH(evbuf) < 2)
+ 		return (-1);
+ 
+-	tmp = *evbuf;
+-	tmp.buffer += 1;
+-	tmp.off -= 1;
++	tmp = evbuffer_new ();
++	evbuffer_add_reference (tmp, evbuffer_pullup(evbuf, -1),
++				evbuffer_get_length(evbuf), NULL, NULL);
++	if (evbuffer_drain(tmp, 1) == -1) {
++		evbuffer_free (tmp);
++		return (-1);
++	}
+ 
+-	res = decode_int_internal(plength, &tmp, 0);
+-	if (res == -1)
++	res = decode_int_internal(plength, tmp, 0);
++	if (res == -1) {
++		evbuffer_free (tmp);
+ 		return (-1);
++	}
+ 
+ 	*plength += res + 1;
+ 
++	evbuffer_free (tmp);
+ 	return (0);
+ }
+ 
+@@ -438,7 +445,7 @@ tagging_int_test(void)
+ 	for (i = 0; i < TEST_MAX_INT; i++) {
+ 		int oldlen, newlen;
+ 		oldlen = EVBUFFER_LENGTH(tmp);
+-		encode_int(tmp, integers[i]);
++		encode__int(tmp, integers[i]);
+ 		newlen = EVBUFFER_LENGTH(tmp);
+ 		fprintf(stderr, "\t\tencoded 0x%08x with %d bytes\n",
+ 		    integers[i], newlen - oldlen);
diff --git a/honeyd.spec b/honeyd.spec
index 0acbda2..999278d 100644
--- a/honeyd.spec
+++ b/honeyd.spec
@@ -1,7 +1,7 @@
 Summary: Honeypot daemon
 Name: honeyd
 Version: 1.5c
-Release: 13%{?dist}
+Release: 14%{?dist}
 License: GPLv2+ and BSD
 Group: Applications/Internet
 URL: http://www.honeyd.org/
@@ -18,6 +18,7 @@ Patch3: honeyd-1.5c-flags.patch
 Patch4: honeyd-1.5c-withlib.patch
 Patch5: honeyd-1.5c-lt.patch
 Patch6: honeyd-1.5c-extint.patch
+Patch7: honeyd-1.5c-libevent2.patch
 Requires: perl-SNMP_Session
 BuildRequires: readline-devel, zlib-devel
 BuildRequires: python-devel, pcre-devel
@@ -41,6 +42,7 @@ cp -p %{SOURCE6}  ./
 %patch4 -p1 -b .withlib
 %patch5 -p1 -b .lt
 %patch6 -p1 -b .extint
+%patch7 -p1 -b .libevent2
 
 sed -i 's,arpd,farpd,' arpd/arpd.8
 
@@ -112,6 +114,9 @@ fi
 %{_mandir}/man8/farpd.8*
 
 %changelog
+* Tue Jul 26 2011 Peter Vrabec <pvrabec at redhat.com> 1.5c-14
+- merge gentoo and ubuntu patch to make it build with libevent 2.0
+
 * Wed Feb 09 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.5c-13
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list