git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/bongo@2911 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2011-06-08 15:26:24 +00:00
parent b882f7955e
commit 103a7acc29
6 changed files with 1043 additions and 0 deletions

View File

@ -0,0 +1,13 @@
Index: log4c-1.2.1/log4c.m4
===================================================================
--- log4c-1.2.1.orig/log4c.m4
+++ log4c-1.2.1/log4c.m4
@@ -4,7 +4,7 @@
dnl AM_PATH_LOG4C([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for LOG4C, and define LOG4C_CFLAGS and LOG4C_LIBS
dnl
-AC_DEFUN(AM_PATH_LOG4C,
+AC_DEFUN([AM_PATH_LOG4C],
[dnl
dnl Get the cflags and libraries from the log4c-config script
dnl

View File

@ -0,0 +1,107 @@
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="2"
#ESVN_REPO_URI="http://svn.gna.org/svn/${PN}/trunk"
inherit eutils multilib flag-o-matic cmake-utils
DESCRIPTION="A calendar and webmail application, which includes its own MTA"
SRC_URI="http://download.gna.org/bongo/release/${P}.tar.bz2"
HOMEPAGE="http://bongo-project.org/"
LICENSE="LGPL-2"
SLOT="0"
IUSE=""
KEYWORDS=""
RESTRICT="stip"
# regular ebuild
PROVIDE="virtual/mta virtual/mda"
DEPEND="virtual/libc
>=dev-db/sqlite-3
dev-db/unixODBC
>=dev-lang/python-2.3
>=dev-libs/glib-2.10
>=dev-libs/gmime-2.0
dev-libs/libgcrypt
>=dev-libs/libical-0.40
dev-libs/log4c
net-libs/gnutls
dev-python/lxml
net-misc/curl
net-nds/openldap"
RDEPEND="${DEPEND}
>=net-mail/mailbase-0.00
!virtual/mta
!net-mail/mailwrapper"
mycmakeargs="-DBONGO_USER=bongo
-DCMAKE_BUILD_TYPE=Release
-DDEBUG=Off"
pkg_setup() {
enewgroup bongo
enewuser bongo -1 -1 -1 bongo
# filter-ldflags -Wl,--as-needed --as-needed
}
src_prepare() {
epatch ${FILESDIR}/bongo-FORTIFY-1.patch
epatch ${FILESDIR}/bongo-0.6.0-missing_link-1.patch
epatch ${FILESDIR}/bongo-0.6.0-uninitialized-1.patch
epatch ${FILESDIR}/bongo-return_value-1.patch
epatch ${FILESDIR}/bongo-gentoo-1.patch
}
src_install() {
cmake-utils_src_install
newinitd ${FILESDIR}/bongo.init bongo
newconfd ${FILESDIR}/bongo.conf.d bongo
newenvd ${FILESDIR}/70bongo 70bongo
dodir /var/lib/bongo
keepdir /var/lib/bongo
fowners bongo:bongo /var/lib/bongo
fperms 770 /var/lib/bongo
dodir /var/run/bongo
keepdir /var/run/bongo
fowners bongo:bongo /var/run/bongo
fperms 770 /var/run/bongo
dosym /usr/sbin/bongo-sendmail /usr/sbin/sendmail
dosym /usr/sbin/bongo-sendmail /usr/lib/sendmail
dosym /usr/sbin/bongo-sendmail /usr/bin/sendmail
dosym /usr/sbin/bongo-sendmail /usr/sbin/mailq
dosym /usr/sbin/bongo-sendmail /usr/sbin/newaliases
}
pkg_postinst() {
elog "Bongo must be setup."
elog "Please run:"
elog " emerge /usr/sbin/bongo-config install"
elog ""
elog "For more information on bongo-config run /usr/sbin/bongo-config --help"
elog ""
elog "After bongo is set up run /etc/init.d/bongo start to start the service"
elog ""
elog "The default login settings are as follows:"
elog "username: admin"
elog "password: bongo"
}
pkg_config() {
einfo "Setting up Bongo..."
/usr/sbin/bongo-config install
}

View File

@ -0,0 +1,107 @@
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="2"
#ESVN_REPO_URI="http://svn.gna.org/svn/${PN}/trunk"
inherit eutils multilib flag-o-matic cmake-utils
DESCRIPTION="A calendar and webmail application, which includes its own MTA"
SRC_URI="http://download.gna.org/bongo/release/${P}.tar.bz2"
HOMEPAGE="http://bongo-project.org/"
LICENSE="LGPL-2"
SLOT="0"
IUSE=""
KEYWORDS="~x86 ~amd64"
RESTRICT="stip"
# regular ebuild
PROVIDE="virtual/mta virtual/mda"
DEPEND="virtual/libc
>=dev-db/sqlite-3
dev-db/unixODBC
>=dev-lang/python-2.3
>=dev-libs/glib-2.10
>=dev-libs/gmime-2.0
dev-libs/libgcrypt
>=dev-libs/libical-0.40
dev-libs/log4c
net-libs/gnutls
dev-python/lxml
net-misc/curl
net-nds/openldap"
RDEPEND="${DEPEND}
>=net-mail/mailbase-0.00
!virtual/mta
!net-mail/mailwrapper"
mycmakeargs="-DBONGO_USER=bongo
-DCMAKE_BUILD_TYPE=Release
-DDEBUG=Off"
pkg_setup() {
enewgroup bongo
enewuser bongo -1 -1 -1 bongo
# filter-ldflags -Wl,--as-needed --as-needed
}
src_prepare() {
epatch ${FILESDIR}/bongo-FORTIFY-1.patch
epatch ${FILESDIR}/bongo-0.6.0-missing_link-1.patch
epatch ${FILESDIR}/bongo-0.6.0-uninitialized-1.patch
epatch ${FILESDIR}/bongo-return_value-1.patch
epatch ${FILESDIR}/bongo-gentoo-1.patch
}
src_install() {
cmake-utils_src_install
newinitd ${FILESDIR}/bongo.init bongo
newconfd ${FILESDIR}/bongo.conf.d bongo
newenvd ${FILESDIR}/70bongo 70bongo
dodir /var/lib/bongo
keepdir /var/lib/bongo
fowners bongo:bongo /var/lib/bongo
fperms 770 /var/lib/bongo
dodir /var/run/bongo
keepdir /var/run/bongo
fowners bongo:bongo /var/run/bongo
fperms 770 /var/run/bongo
dosym /usr/sbin/bongo-sendmail /usr/sbin/sendmail
dosym /usr/sbin/bongo-sendmail /usr/lib/sendmail
dosym /usr/sbin/bongo-sendmail /usr/bin/sendmail
dosym /usr/sbin/bongo-sendmail /usr/sbin/mailq
dosym /usr/sbin/bongo-sendmail /usr/sbin/newaliases
}
pkg_postinst() {
elog "Bongo must be setup."
elog "Please run:"
elog " emerge /usr/sbin/bongo-config install"
elog ""
elog "For more information on bongo-config run /usr/sbin/bongo-config --help"
elog ""
elog "After bongo is set up run /etc/init.d/bongo start to start the service"
elog ""
elog "The default login settings are as follows:"
elog "username: admin"
elog "password: bongo"
}
pkg_config() {
einfo "Setting up Bongo..."
/usr/sbin/bongo-config install
}

View File

@ -0,0 +1,18 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2009-09-10
Initial Package Version: 0.6.0
Origin: me
Upstream Status: unknown
Description: add missing linking
diff -Naur bongo-0.6.0.orig/src/libs/cal/CMakeLists.txt bongo-0.6.0/src/libs/cal/CMakeLists.txt
--- bongo-0.6.0.orig/src/libs/cal/CMakeLists.txt 2009-09-10 12:54:44.920349087 +0000
+++ bongo-0.6.0/src/libs/cal/CMakeLists.txt 2009-09-10 12:55:41.133348481 +0000
@@ -22,6 +22,7 @@
target_link_libraries(bongocal
bongoxpl
bongoutil
+ bongojson
${LIBICAL_LIBRARIES}
)

View File

@ -0,0 +1,19 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2009-09-10
Initial Package Version: 0.6.0
Origin: me
Upstream Status: unknown
Description: correct some uninitalzed vars
diff -Naur bongo-0.6.0.orig/src/agents/antispam/spamd.c bongo-0.6.0/src/agents/antispam/spamd.c
--- bongo-0.6.0.orig/src/agents/antispam/spamd.c 2009-09-10 12:59:50.614349037 +0000
+++ bongo-0.6.0/src/agents/antispam/spamd.c 2009-09-10 13:02:51.522348913 +0000
@@ -346,7 +346,7 @@
for (i=0; i < ASpam.spamd.hostlist->len; i++) {
char *hostitem = g_array_index(ASpam.spamd.hostlist, char*, i);
char *lHost = MemStrdup(hostitem);
- char *host;
+ char *host = NULL;
int port=SPAMD_DEFAULT_PORT, weight=SPAMD_DEFAULT_WEIGHT;
ParseHost(lHost, &host, &port, &weight);
ConnAddressPoolAddHost(&ASpam.spamd.hosts, host, port, weight);

View File

@ -0,0 +1,779 @@
Index: include/connio.h
===================================================================
--- include/connio.h (revision 1131)
+++ include/connio.h (working copy)
@@ -80,8 +80,11 @@
#define SSL_DISABLE_EMPTY_FRAGMENTS (1 << 4)
#define SSL_DONT_INSERT_EMPTY_FRAGMENTS (1 << 5)
-void CHOP_NEWLINE(unsigned char *s);
-void SET_POINTER_TO_VALUE(unsigned char *p, unsigned char *s); // FIXME: Unused?
+void CHOP_NEWLINE(char *s);
+#if 0
+//TODO: do we need this?
+void SET_POINTER_TO_VALUE(unsigned char *p, unsigned char *s);
+#endif
#if defined (UNIX) || defined(S390RH) || defined(SOLARIS)
@@ -138,12 +141,12 @@
struct {
long type;
- const unsigned char *file;
+ const char *file;
} certificate;
struct {
long type;
- const unsigned char *file;
+ const char *file;
} key;
} ConnSSLConfiguration;
@@ -227,9 +230,9 @@
#include <connio-trace.h>
-void ConnTcpWrite(Connection *c, char *b, size_t l, int *r);
-void ConnTcpRead(Connection *c, char *b, size_t l, int *r);
-void ConnTcpFlush(Connection *c, const char *b, const char *e, int *r);
+int ConnTcpWrite(Connection *c, char *b, size_t l, size_t *r);
+int ConnTcpRead(Connection *c, char *b, size_t l, size_t *r);
+int ConnTcpFlush(Connection *c, const char *b, const char *e, size_t *r);
void ConnTcpClose(Connection *c);
void ConnAddressPoolStartup(AddressPool *pool, unsigned long errorThreshold, unsigned long errorTimeThreshold);
@@ -304,10 +307,13 @@
int XplGetInterfaceList(void);
int XplDestroyInterfaceList(void);
+#if 0
+//TODO: Do we need these? They aren't used anywhere but connmgr */
int XplIPRead(void *sktCtx, unsigned char *Buf, int Len, int socketTimeout);
int XplIPReadSSL(void *sktCtx, unsigned char *Buf, int Len, int socketTimeout);
int XplIPWrite(void *sktCtx, unsigned char *Buf, int Len);
int XplIPWriteSSL(void *sktCtx, unsigned char *Buf, int Len);
+#endif
int XplIPConnectWithTimeout(IPSOCKET soc, struct sockaddr *addr, long addrSize, long timeout);
#endif /* _BONGO_CONNIO_H */
Index: src/libs/connio/connio.c
===================================================================
--- src/libs/connio/connio.c (revision 1131)
+++ src/libs/connio/connio.c (working copy)
@@ -114,7 +114,7 @@
gnutls_dh_params_init(&dh_params);
genparams = fopen(XPL_DEFAULT_DHPARAMS_PATH, "r");
if (genparams) {
- char tmpdata[2048];
+ unsigned char tmpdata[2048];
gnutls_datum dh_parameters;
dh_parameters.size = fread(tmpdata, 1, sizeof(tmpdata)-1, genparams);
@@ -137,7 +137,7 @@
gnutls_rsa_params_init(&rsa_params);
genparams = fopen(XPL_DEFAULT_RSAPARAMS_PATH, "r");
if (genparams) {
- char tmpdata[2048];
+ unsigned char tmpdata[2048];
gnutls_datum rsa_parameters;
rsa_parameters.size = fread(tmpdata, 1, sizeof(tmpdata)-1, genparams);
@@ -285,8 +285,8 @@
}
if (ccode != -1) {
- ccode = sizeof(conn->socketAddress);
- IPgetsockname(conn->socket, (struct sockaddr *)&(conn->socketAddress), &ccode);
+ socklen_t len = sizeof(conn->socketAddress);
+ IPgetsockname(conn->socket, (struct sockaddr *)&(conn->socketAddress), &len);
} else {
IPclose(conn->socket);
conn->socket = -1;
@@ -335,6 +335,8 @@
{
int ccode;
+ UNUSED_PARAMETER(destination);
+
conn->socket = IPsocket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (conn->socket != -1) {
if (!saddr) {
@@ -583,7 +585,7 @@
int ConnAccept(Connection *Server, Connection **Client)
{
- int length;
+ socklen_t length;
Connection *c = ConnAlloc(TRUE);
if (c) {
@@ -609,7 +611,7 @@
int
ConnSend(Connection *Conn, char *Buffer, unsigned int Length)
{
- int count;
+ size_t count;
ConnTcpWrite(Conn, Buffer, Length, &count);
@@ -619,7 +621,7 @@
int
ConnReceive(Connection *Conn, char *Buffer, unsigned int Length)
{
- int count;
+ size_t count;
ConnTcpRead(Conn, Buffer, Length, &count);
@@ -639,13 +641,23 @@
int
ConnRead(Connection *Conn, char *Dest, int Length)
{
- int read;
+ size_t read;
+ size_t uLength;
+ int err;
+
Connection *c = Conn;
+ if (Length <= 0) {
+ return 0;
+ }
+
+ /* since i know Length is greater than 0 i should be able to safely cast here */
+ uLength = Length;
+
read = c->receive.write - c->receive.read;
do {
if (read > 0) {
- if (read <= Length) {
+ if (read <= uLength) {
memcpy(Dest, c->receive.read, read);
c->receive.read = c->receive.write = c->receive.buffer;
@@ -655,14 +667,14 @@
return(read);
}
- memcpy(Dest, c->receive.read, Length);
+ memcpy(Dest, c->receive.read, uLength);
- c->receive.read += Length;
+ c->receive.read += uLength;
- return(Length);
+ return(uLength);
}
- ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &read);
+ err = ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &read);
if (read > 0) {
c->receive.read = c->receive.buffer;
c->receive.write = c->receive.buffer + read;
@@ -689,6 +701,7 @@
{
size_t buffered;
size_t remaining = Count;
+ int err;
char *d = Dest;
Connection *c = Conn;
@@ -721,7 +734,7 @@
}
if (remaining < CONN_TCP_MTU) {
- ConnTcpRead(c, c->receive.write, c->receive.remaining, &buffered);
+ err = ConnTcpRead(c, c->receive.write, c->receive.remaining, &buffered);
if (buffered > 0) {
c->receive.write += buffered;
@@ -732,7 +745,7 @@
}
} else {
do {
- ConnTcpRead(c, d, remaining, &buffered);
+ err = ConnTcpRead(c, d, remaining, &buffered);
if (buffered > 0) {
d += buffered;
remaining -= buffered;
@@ -756,7 +769,8 @@
int
ConnReadLine(Connection *Conn, char *Line, int Length)
{
- int count;
+ size_t count;
+ int err;
char *cur;
char *limit;
char *dest;
@@ -844,7 +858,7 @@
}
}
- ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
+ err = ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
if (count > 0) {
cur = c->receive.read = c->receive.buffer;
limit = c->receive.write = cur + count;
@@ -860,11 +874,11 @@
return(dest - Line);
}
-
int
ConnReadAnswer(Connection *Conn, char *Line, int Length)
{
- int count;
+ size_t count;
+ int err;
char *cur;
char *limit;
char *dest;
@@ -974,7 +988,7 @@
}
}
- ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
+ err = ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
if (count > 0) {
cur = c->receive.read = c->receive.buffer;
limit = c->receive.write = cur + count;
@@ -1068,10 +1082,11 @@
while (found_end_of_line == FALSE) {
if (c->receive.read == c->receive.write) {
// we need to fetch more data since the buffers are empty - this blocks
- int count;
+ size_t count;
+ int err;
- ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
- if (count <= 0) {
+ err = ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
+ if ((err < 0) || (count == 0)) {
c->send.remaining = CONN_TCP_MTU;
c->send.read = c->send.write;
return(CONN_ERROR_NETWORK);
@@ -1128,6 +1143,7 @@
{
size_t buffered;
size_t remaining;
+ int err;
Connection *c = Conn;
remaining = Count;
@@ -1164,7 +1180,7 @@
}
}
- ConnTcpRead(c, c->receive.write, c->receive.remaining, &buffered);
+ err = ConnTcpRead(c, c->receive.write, c->receive.remaining, &buffered);
if (buffered > 0) {
c->receive.write += buffered;
c->receive.remaining -= buffered;
@@ -1184,6 +1200,7 @@
{
int written = 0;
size_t count;
+ int err;
char *cur;
char *limit;
BOOL finished = FALSE;
@@ -1274,7 +1291,7 @@
Src->receive.write[0] = '\0';
}
- ConnTcpRead(Src, Src->receive.write, Src->receive.remaining, &count);
+ err = ConnTcpRead(Src, Src->receive.write, Src->receive.remaining, &count);
if (count > 0) {
Src->receive.read = Src->receive.buffer;
Src->receive.write += count;
@@ -1293,15 +1310,17 @@
int
ConnReadToConn(Connection *Src, Connection *Dest, int Count)
{
- unsigned int sent;
+ size_t sent;
size_t buffered;
size_t remaining;
+ int err;
+
Connection *s = Src;
Connection *d = Dest;
if ((remaining = Count) > 0) {
- ConnTcpFlush(d, d->send.read, d->send.write, &sent);
- if (sent >= 0) {
+ err = ConnTcpFlush(d, d->send.read, d->send.write, &sent);
+ if (err == 0) {
d->send.read = d->send.write = d->send.buffer;
d->send.remaining = CONN_TCP_MTU;
@@ -1317,7 +1336,7 @@
buffered = s->receive.write - s->receive.read;
if (buffered > 0) {
if (remaining <= buffered) {
- ConnTcpWrite(d, s->receive.read, remaining, &sent);
+ err = ConnTcpWrite(d, s->receive.read, remaining, &sent);
if (sent == remaining) {
s->receive.read += sent;
if (s->receive.read == s->receive.write) {
@@ -1334,7 +1353,7 @@
}
if ((remaining > s->receive.remaining) && (s->receive.remaining < CONN_TCP_THRESHOLD)) {
- ConnTcpWrite(d, s->receive.read, buffered, &sent);
+ err = ConnTcpWrite(d, s->receive.read, buffered, &sent);
if (sent == buffered) {
remaining -= sent;
@@ -1348,7 +1367,7 @@
}
}
- ConnTcpRead(s, s->receive.write, s->receive.remaining, &buffered);
+ err = ConnTcpRead(s, s->receive.write, s->receive.remaining, &buffered);
if (buffered > 0) {
s->receive.write += buffered;
s->receive.remaining -= buffered;
@@ -1367,13 +1386,14 @@
ConnReadToConnUntilEOS(Connection *Src, Connection *Dest)
{
int written = 0;
- int count;
+ size_t count;
+ int err;
char *cur;
char *limit;
BOOL finished = FALSE;
- ConnTcpFlush(Dest, Dest->send.read, Dest->send.write, &count);
- if (count >= 0) {
+ err = ConnTcpFlush(Dest, Dest->send.read, Dest->send.write, &count);
+ if (err == 0) {
Dest->send.read = Dest->send.write = Dest->send.buffer;
Dest->send.remaining = CONN_TCP_MTU;
@@ -1410,10 +1430,13 @@
*cur++ = ' ';
continue;
}
-
+
if (Src->receive.read < cur) {
- ConnTcpFlush(Dest, Src->receive.read, cur, &count);
- if ((cur - Src->receive.read) == count) {
+ int distance;
+
+ err = ConnTcpFlush(Dest, Src->receive.read, cur, &count);
+ distance = cur - Src->receive.read;
+ if ((distance > 0) && ((size_t)distance == count)) {
written += count;
if (!finished) {
@@ -1444,7 +1467,7 @@
}
}
- ConnTcpRead(Src, Src->receive.write, Src->receive.remaining, &count);
+ err = ConnTcpRead(Src, Src->receive.write, Src->receive.remaining, &count);
if (count > 0) {
Src->receive.read = Src->receive.buffer;
Src->receive.write += count;
@@ -1464,7 +1487,8 @@
ConnWrite(Connection *Conn, const char *Buffer, int Length)
{
const char *b;
- int i;
+ size_t i;
+ int err;
size_t r;
Connection *c = Conn;
@@ -1488,7 +1512,7 @@
c->send.write += c->send.remaining;
- ConnTcpFlush(c, c->send.read, c->send.write, &i);
+ err = ConnTcpFlush(c, c->send.read, c->send.write, &i);
if (i > 0) {
c->send.read = c->send.write = c->send.buffer;
c->send.remaining = CONN_TCP_MTU;
@@ -1503,7 +1527,7 @@
}
do {
- ConnTcpFlush(c, b, b + r, &i);
+ err = ConnTcpFlush(c, b, b + r, &i);
if (i > 0) {
b += r;
r -= r;
@@ -1523,7 +1547,8 @@
int
ConnWriteFromFile(Connection *Conn, FILE *Source, int Count)
{
- int i;
+ size_t i;
+ int err;
size_t n;
size_t r;
Connection *c = Conn;
@@ -1547,7 +1572,7 @@
return(-1);
}
- ConnTcpFlush(c, c->send.read, c->send.write, &i);
+ err = ConnTcpFlush(c, c->send.read, c->send.write, &i);
if (i > 0) {
c->send.read = c->send.write = c->send.buffer;
c->send.remaining = CONN_TCP_MTU;
@@ -1565,7 +1590,8 @@
int
ConnWriteFile(Connection *Conn, FILE *Source)
{
- int i;
+ size_t i;
+ int err;
size_t n;
size_t r;
Connection *c = Conn;
@@ -1586,7 +1612,7 @@
n += c->send.write - c->send.read;
- ConnTcpFlush(c, c->send.read, c->send.write, &i);
+ err = ConnTcpFlush(c, c->send.read, c->send.write, &i);
if (i > 0) {
c->send.read = c->send.write = c->send.buffer;
c->send.remaining = r = CONN_TCP_MTU;
@@ -1605,6 +1631,8 @@
ConnWriteVF(Connection *c, const char *format, va_list ap)
{
int i;
+ size_t unused;
+ int err;
do {
if (CONN_BUFSIZE < c->send.remaining) {
@@ -1641,8 +1669,8 @@
va_end(ap2);
}
- ConnTcpFlush(c, c->send.read, c->send.write, &i);
- if (i > 0) {
+ err = ConnTcpFlush(c, c->send.read, c->send.write, &unused);
+ if (unused > 0) {
c->send.read = c->send.write = c->send.buffer;
c->send.remaining = CONN_TCP_MTU;
@@ -1670,12 +1698,13 @@
int
ConnFlush(Connection *Conn)
{
- int count;
+ size_t count;
+ int err;
Connection *c = Conn;
- ConnTcpFlush(c, c->send.read, c->send.write, &count);
+ err = ConnTcpFlush(c, c->send.read, c->send.write, &count);
- if (count >= 0) {
+ if (err == 0) {
c->send.read += count;
if (c->send.read == c->send.write) {
c->send.read = c->send.write = c->send.buffer;
Index: src/libs/connio/unix-ip.c
===================================================================
--- src/libs/connio/unix-ip.c (revision 1131)
+++ src/libs/connio/unix-ip.c (working copy)
@@ -366,6 +366,8 @@
}
#endif
+#if 0
+/*TODO: do we need this? This isn't used anywhere but connmgr */
int
XplIPRead(void *socket, unsigned char *Buf, int Len, int readTimeout)
{
@@ -405,8 +407,10 @@
return(-1);
}
+#endif
-
+#if 0
+/*TODO: do we need this? it isn't used anywhere but connmgr */
int
XplIPWrite(void * socket, unsigned char *Buf, int Len)
{
@@ -424,6 +428,7 @@
return(-1);
}
+#endif
__inline static BOOL
MakeSocketNonBlocking(int soc)
Index: src/libs/connio/sockets.c
===================================================================
--- src/libs/connio/sockets.c (revision 1131)
+++ src/libs/connio/sockets.c (working copy)
@@ -7,9 +7,9 @@
#include "config.h"
void
-CHOP_NEWLINE(unsigned char *s)
+CHOP_NEWLINE(char *s)
{
- unsigned char *p;
+ char *p;
p = strchr(s, 0x0A);
if (p) {
*p = '\0';
@@ -20,6 +20,8 @@
}
}
+#if 0
+//do we need this?
void
SET_POINTER_TO_VALUE(unsigned char *p, unsigned char *s)
{
@@ -35,16 +37,19 @@
p++;
}
}
+#endif
-void
-ConnTcpFlush(Connection *c, const char *b, const char *e, int *r)
+int
+ConnTcpFlush(Connection *c, const char *b, const char *e, size_t *r)
{
+ int Result=0;
+
if (b < e) {
char *curPTR = (char *)b;
while (curPTR < e) {
- ConnTcpWrite(c, curPTR, e - curPTR, r);
+ Result = ConnTcpWrite(c, curPTR, e - curPTR, r);
if (*r > 0) {
- curPTR = curPTR + (int)*r;
+ curPTR = curPTR + *r;
continue;
}
break;
@@ -52,11 +57,14 @@
if (curPTR == e) {
*r = e - b;
} else {
- *r = -1;
+ *r = 0;
+ Result = -1;
}
} else {
*r = 0;
}
+
+ return Result;
}
void
@@ -88,104 +96,85 @@
}
}
-//#if defined(S390RH) || defined(SOLARIS)
-
-// TODO: is this correct for Solaris?
-
-void
-ConnTcpRead(Connection *c, char *b, size_t l, int *r)
+int
+ConnTcpRead(Connection *c, char *b, size_t l, size_t *r)
{
+ int Result=0;
+
struct pollfd pfd;
do {
pfd.fd = (int)c->socket;
pfd.events = POLLIN;
- *r = poll(&pfd, 1, c->receive.timeOut * 1000);
- if (*r > 0) {
+ Result = poll(&pfd, 1, c->receive.timeOut * 1000);
+ if (Result > 0) {
if ((pfd.revents & (POLLIN | POLLPRI))) {
do {
if (!c->ssl.enable) {
- *r = IPrecv((c)->socket, b, l, 0);
+ Result = IPrecv((c)->socket, b, l, 0);
} else {
- *r = gnutls_record_recv(c->ssl.context, (void *)b, l);
- if (*r < 0) {
- CONN_TRACE_ERROR(c, "RECV", *r);
- break;
- }
+ Result = gnutls_record_recv(c->ssl.context, (void *)b, l);
}
- if (*r >= 0) {
- CONN_TRACE_DATA(c, CONN_TRACE_EVENT_READ, b, *r);
+ if (Result >= 0) {
+ CONN_TRACE_DATA(c, CONN_TRACE_EVENT_READ, b, Result);
+ /* we actually worked. reset Result to 0 indicating that */
+ /* Result is > 0 so i should be able to safely cast it here */
+ *r = (size_t)Result;
+ Result = 0;
break;
} else if (errno == EINTR) {
continue;
}
- CONN_TRACE_ERROR(c, "RECV", *r);
+ /* we failed with something other than eintr... we'll reset Result below */
+ CONN_TRACE_ERROR(c, "RECV", Result);
break;
} while (TRUE);
break;
} else if ((pfd.revents & (POLLERR | POLLHUP | POLLNVAL))) {
- CONN_TRACE_ERROR(c, "POLL EVENT", *r);
- *r = -2;
+ CONN_TRACE_ERROR(c, "POLL EVENT", Result);
+ *r = 0;
+ Result = -2;
break;
}
}
if (errno == EINTR) {
continue;
}
- CONN_TRACE_ERROR(c, "POLL", *r);
- *r = -3;
+ CONN_TRACE_ERROR(c, "POLL", Result);
+ Result = -3;
+ *r = 0;
break;
} while (TRUE);
+
+ return Result;
}
-void
-ConnTcpWrite(Connection *c, char *b, size_t l, int *r)
+int
+ConnTcpWrite(Connection *c, char *b, size_t l, size_t *r)
{
+ int Result=0;
+
do {
if (!c->ssl.enable) {
- *r = IPsend(c->socket, b, l, MSG_NOSIGNAL);
+ Result = IPsend(c->socket, b, l, MSG_NOSIGNAL);
} else {
- *r = gnutls_record_send(c->ssl.context, (void *)b, l);
+ Result = gnutls_record_send(c->ssl.context, (void *)b, l);
}
- if (*r >= 0) {
- CONN_TRACE_DATA(c, CONN_TRACE_EVENT_WRITE, b, *r);
+ if (Result >= 0) {
+ CONN_TRACE_DATA(c, CONN_TRACE_EVENT_WRITE, b, Result);
+ /* we actually worked. reset Result to 0 indicating that */
+ /* Result is > 0 so i should be able to safely cast here */
+ *r = Result;
+ Result = 0;
break;
} else if (errno == EINTR) {
continue;
}
- CONN_TRACE_ERROR(c, "POLL", *r);
- *r = -1;
+ CONN_TRACE_ERROR(c, "POLL", Result);
+ Result = -1;
+ *r = 0;
break;
} while (TRUE);
-}
-//#else
-#if 0
-
-void
-ConnTcpRead(Connection *c, char *b, size_t l, int *r)
-{
- fd_set rfds;
- struct timeval timeout;
- FD_ZERO(&rfds);
- FD_SET(c->socket, &rfds);
- timeout.tv_usec = 0;
- timeout.tv_sec = c->receive.timeOut;
- *r = select(FD_SETSIZE, &rfds, NULL, NULL, &timeout);
- if (*r > 0) {
- *r = recv(c->socket, b, l, 0);
- CONN_TRACE_DATA_AND_ERROR(c, CONN_TRACE_EVENT_READ, b, *r, "RECV");
- } else {
- CONN_TRACE_ERROR(c, "SELECT", *r);
- *r = -1;
- }
+ return Result;
}
-void
-ConnTcpWrite(Connection *c, char *b, size_t l, int *r)
-{
- *r = IPsend(c->socket, b, l, 0);
- CONN_TRACE_DATA_AND_ERROR(c, CONN_TRACE_EVENT_WRITE, b, *r, "SEND");
-}
-
-
-#endif
Index: src/libs/connio/CMakeLists.txt
===================================================================
--- src/libs/connio/CMakeLists.txt (revision 1131)
+++ src/libs/connio/CMakeLists.txt (working copy)
@@ -1,10 +1,10 @@
-#StrictCompile()
+StrictCompile()
add_library(bongoconnio SHARED
+ sockets.c
connio.c
trace.c
addrpool.c
- sockets.c
unix-ip.c
)
Index: src/libs/nmap/nmap.c
===================================================================
--- src/libs/nmap/nmap.c (revision 1131)
+++ src/libs/nmap/nmap.c (working copy)
@@ -112,7 +112,8 @@
__inline static unsigned char *
FindEndOfLine(Connection *conn)
{
- int count;
+ size_t count;
+ int err;
char *newLine;
Connection *c = conn;
@@ -126,7 +127,7 @@
if (count < CONN_TCP_MTU) {
if (count == 0) {
- ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
+ err = ConnTcpRead(c, c->receive.buffer, CONN_TCP_MTU, &count);
if (count > 0) {
c->receive.read = c->receive.buffer;
c->receive.write = c->receive.buffer + count;
@@ -143,7 +144,7 @@
c->receive.read = c->receive.buffer;
c->receive.write = c->receive.buffer + count;
c->receive.remaining = CONN_TCP_MTU - count;
- ConnTcpRead(c, c->receive.write, c->receive.remaining, &count);
+ err = ConnTcpRead(c, c->receive.write, c->receive.remaining, &count);
if (count > 0) {
c->receive.write += count;
c->receive.remaining -= count;