From 44a5d81ccfe0a3790b05d174c8846e5cfdeba51c Mon Sep 17 00:00:00 2001 From: pfelt Date: Sat, 15 Aug 2009 21:39:22 +0000 Subject: [PATCH] -- remove unneeded portions of memmgr, move remaining bits to bongoutil -- refactor a little bit of code --- CMakeLists.txt | 2 +- include/memmgr.h | 7 - src/agents/antispam/CMakeLists.txt | 1 - src/agents/antispam/antispam.h | 1 + src/agents/avirus/CMakeLists.txt | 1 - src/agents/imap/CMakeLists.txt | 1 - src/agents/imap/imapd.c | 19 +- src/agents/pop/CMakeLists.txt | 1 - src/agents/pop/pop3.c | 22 +-- src/agents/queue/CMakeLists.txt | 1 - src/agents/rules/CMakeLists.txt | 1 - src/agents/smtp/CMakeLists.txt | 4 +- src/agents/smtp/smtpd.c | 214 +++++++++++----------- src/agents/store/CMakeLists.txt | 1 - src/apps/config/config.c | 6 - src/apps/manager/manager.c | 4 - src/apps/testtool/testtool.c | 6 - src/libs/bongoutil/CMakeLists.txt | 6 + src/libs/{memmgr => bongoutil}/memmgrp.h | 0 src/libs/{memmgr => bongoutil}/memstack.c | 0 src/libs/{memmgr => bongoutil}/pools.c | 18 -- src/libs/cal/CMakeLists.txt | 1 - src/libs/memmgr/CMakeLists.txt | 13 -- src/libs/memmgr/allocator.c | 2 - src/libs/memmgr/memmgr.c | 0 src/libs/msgapi/CMakeLists.txt | 1 - src/libs/msgapi/msgapi.c | 6 - src/libs/nmap/CMakeLists.txt | 2 +- src/libs/nmap/bongoagent.c | 20 +- 29 files changed, 138 insertions(+), 223 deletions(-) rename src/libs/{memmgr => bongoutil}/memmgrp.h (100%) rename src/libs/{memmgr => bongoutil}/memstack.c (100%) rename src/libs/{memmgr => bongoutil}/pools.c (87%) delete mode 100644 src/libs/memmgr/CMakeLists.txt delete mode 100644 src/libs/memmgr/allocator.c delete mode 100644 src/libs/memmgr/memmgr.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 02a7fa5..bb1d608 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/) # now build our various libraries, agents, binaries. -foreach (LIBRARY xpl streamio logging msgapi memmgr connio bongoutil +foreach (LIBRARY xpl streamio logging msgapi connio bongoutil json cal nmap python/libbongo python/bongo) add_subdirectory (src/libs/${LIBRARY}) endforeach (LIBRARY) diff --git a/include/memmgr.h b/include/memmgr.h index 8d34d6f..a475c58 100644 --- a/include/memmgr.h +++ b/include/memmgr.h @@ -68,17 +68,10 @@ XPL_BEGIN_C_LINKAGE #define MemFree(m) g_free((m)) #define MemCalloc(n, s) g_malloc((n)*(s)) -EXPORT BOOL MemoryManagerOpen(const unsigned char *AgentName); -EXPORT BOOL MemoryManagerClose(const unsigned char *AgentName); - /* Helpers */ #define MemNew0(type, num) ((type*)MemMalloc0(sizeof(type) * (num))) #define MemNew(type, num) ((type*)MemMalloc(sizeof(type) * (num))) -EXPORT void * MemClear(void *Source, size_t Size); - -/* Memory De-Allocation API's */ - /* Private Pool API's */ typedef BOOL (*PoolEntryCB)(void *Buffer, void *ClientData); diff --git a/src/agents/antispam/CMakeLists.txt b/src/agents/antispam/CMakeLists.txt index fbdfbe9..882bf0a 100644 --- a/src/agents/antispam/CMakeLists.txt +++ b/src/agents/antispam/CMakeLists.txt @@ -6,7 +6,6 @@ add_executable(bongoantispam ) target_link_libraries(bongoantispam - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/antispam/antispam.h b/src/agents/antispam/antispam.h index 3caef44..555da6a 100644 --- a/src/agents/antispam/antispam.h +++ b/src/agents/antispam/antispam.h @@ -35,6 +35,7 @@ #include #include #include +#include #define PRODUCT_SHORT_NAME "bongoantispam.nlm" diff --git a/src/agents/avirus/CMakeLists.txt b/src/agents/avirus/CMakeLists.txt index 122be38..e627fac 100644 --- a/src/agents/avirus/CMakeLists.txt +++ b/src/agents/avirus/CMakeLists.txt @@ -3,7 +3,6 @@ add_executable(bongoavirus ) target_link_libraries(bongoavirus - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/imap/CMakeLists.txt b/src/agents/imap/CMakeLists.txt index 1d5f7f2..30640e3 100644 --- a/src/agents/imap/CMakeLists.txt +++ b/src/agents/imap/CMakeLists.txt @@ -12,7 +12,6 @@ add_executable(bongoimap ) target_link_libraries(bongoimap - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/imap/imapd.c b/src/agents/imap/imapd.c index 1d1196a..7475653 100644 --- a/src/agents/imap/imapd.c +++ b/src/agents/imap/imapd.c @@ -3583,8 +3583,6 @@ IMAPServer(void *unused) FreeImapGlobals(); MemPrivatePoolFree(IMAPConnectionPool); - MemoryManagerClose(MSGSRV_AGENT_IMAP); - #if VERBOSE XplConsolePrintf("IMAPD: Shutdown complete\r\n"); #endif @@ -3764,19 +3762,12 @@ XplServiceMain(int argc, char *argv[]) XplSignalHandler(IMAPShutdownSigHandler); - if (MemoryManagerOpen(MSGSRV_AGENT_IMAP) == TRUE) { - IMAPConnectionPool = MemPrivatePoolAlloc("IMAP Connections", sizeof(ImapSession), 0, 3072, TRUE, FALSE, IMAPSessionAllocCB, IMAPSessionFreeCB, NULL); - if (IMAPConnectionPool != NULL) { - XplOpenLocalSemaphore(Imap.server.mainSemaphore, 0); - XplOpenLocalSemaphore(Imap.server.shutdownSemaphore, 1); - } else { - MemoryManagerClose(MSGSRV_AGENT_IMAP); - - XplConsolePrintf("IMAPD: Unable to create command buffer pool; shutting down.\r\n"); - return(-1); - } + IMAPConnectionPool = MemPrivatePoolAlloc("IMAP Connections", sizeof(ImapSession), 0, 3072, TRUE, FALSE, IMAPSessionAllocCB, IMAPSessionFreeCB, NULL); + if (IMAPConnectionPool != NULL) { + XplOpenLocalSemaphore(Imap.server.mainSemaphore, 0); + XplOpenLocalSemaphore(Imap.server.shutdownSemaphore, 1); } else { - XplConsolePrintf("IMAPD: Unable to initialize memory manager; shutting down.\r\n"); + XplConsolePrintf("IMAPD: Unable to create command buffer pool; shutting down.\r\n"); return(-1); } diff --git a/src/agents/pop/CMakeLists.txt b/src/agents/pop/CMakeLists.txt index c0ecc49..568983b 100644 --- a/src/agents/pop/CMakeLists.txt +++ b/src/agents/pop/CMakeLists.txt @@ -3,7 +3,6 @@ add_executable(bongopop3 ) target_link_libraries(bongopop3 - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/pop/pop3.c b/src/agents/pop/pop3.c index 19882b1..a003cf1 100644 --- a/src/agents/pop/pop3.c +++ b/src/agents/pop/pop3.c @@ -1847,7 +1847,6 @@ POP3Server(void *ignored) ConnShutdown(); MemPrivatePoolFree(POP3.client.pool); - MemoryManagerClose(MSGSRV_AGENT_POP); Log(LOG_DEBUG, "Shutdown complete."); @@ -2070,21 +2069,14 @@ XplServiceMain(int argc, char *argv[]) LoadProtocolCommandTree(&POP3.commands, POP3CommandEntries); - if (MemoryManagerOpen(MSGSRV_AGENT_POP) == TRUE) { - POP3.client.pool = MemPrivatePoolAlloc("Pop Connections", sizeof(POP3Client), 0, 3072, TRUE, FALSE, POP3ClientAllocCB, NULL, NULL); - if (POP3.client.pool != NULL) { - XplOpenLocalSemaphore(POP3.sem.main, 0); - XplOpenLocalSemaphore(POP3.sem.shutdown, 1); - XplOpenLocalSemaphore(POP3.client.semaphore, 1); - XplOpenLocalSemaphore(POP3.client.worker.todo, 1); - } else { - MemoryManagerClose(MSGSRV_AGENT_POP); - - Log(LOG_ERROR, "Unable to create connection pool; shutting down."); - return(-1); - } + POP3.client.pool = MemPrivatePoolAlloc("Pop Connections", sizeof(POP3Client), 0, 3072, TRUE, FALSE, POP3ClientAllocCB, NULL, NULL); + if (POP3.client.pool != NULL) { + XplOpenLocalSemaphore(POP3.sem.main, 0); + XplOpenLocalSemaphore(POP3.sem.shutdown, 1); + XplOpenLocalSemaphore(POP3.client.semaphore, 1); + XplOpenLocalSemaphore(POP3.client.worker.todo, 1); } else { - Log(LOG_ERROR, "Unable to initialize memory manager; shutting down."); + Log(LOG_ERROR, "Unable to create connection pool; shutting down."); return(-1); } diff --git a/src/agents/queue/CMakeLists.txt b/src/agents/queue/CMakeLists.txt index 3c41330..a16e034 100644 --- a/src/agents/queue/CMakeLists.txt +++ b/src/agents/queue/CMakeLists.txt @@ -7,7 +7,6 @@ add_executable(bongoqueue ) target_link_libraries(bongoqueue - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/rules/CMakeLists.txt b/src/agents/rules/CMakeLists.txt index c0daa80..985e117 100644 --- a/src/agents/rules/CMakeLists.txt +++ b/src/agents/rules/CMakeLists.txt @@ -4,7 +4,6 @@ add_executable(bongorules ) target_link_libraries(bongorules - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/smtp/CMakeLists.txt b/src/agents/smtp/CMakeLists.txt index 268191c..121e05a 100644 --- a/src/agents/smtp/CMakeLists.txt +++ b/src/agents/smtp/CMakeLists.txt @@ -1,9 +1,10 @@ +#StrictCompile() + add_executable(bongosmtp smtpd.c ) target_link_libraries(bongosmtp - bongomemmgr bongoxpl bongoconnio bongoutil @@ -17,7 +18,6 @@ add_executable(bongosmtpc ) target_link_libraries(bongosmtpc - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/agents/smtp/smtpd.c b/src/agents/smtp/smtpd.c index 7a3ff92..cccc6e0 100644 --- a/src/agents/smtp/smtpd.c +++ b/src/agents/smtp/smtpd.c @@ -119,10 +119,10 @@ time_t LastBounce; time_t BounceInterval; unsigned long MaxBounceCount; unsigned long BounceCount; -unsigned char NMAPServer[20] = "127.0.0.1"; +char NMAPServer[20] = "127.0.0.1"; unsigned long LocalAddress = 0; bongo_ssl_context *SSLContext = NULL; -static unsigned char NMAPHash[NMAP_HASH_SIZE]; +static char NMAPHash[NMAP_HASH_SIZE]; #ifdef USE_HOPCOUNT_DETECTION int MAX_HOPS = 16; @@ -148,7 +148,7 @@ int MAX_HOPS = 16; /* Seconds */ #define MAILBOX_TIMEOUT 15 -#define ChopNL(String) { unsigned char *pTr; pTr=strchr((String), 0x0a); if (pTr) *pTr='\0'; pTr=strrchr((String), 0x0d); if (pTr) *pTr='\0'; } +#define ChopNL(String) { char *pTr; pTr=strchr((String), 0x0a); if (pTr) *pTr='\0'; pTr=strrchr((String), 0x0d); if (pTr) *pTr='\0'; } struct __InternalConnectionStruct { Connection *conn; @@ -168,18 +168,18 @@ typedef struct unsigned long RecipCount; /* Number of recipients */ NMAPMessageFlags MsgFlags; /* current msg flags */ - unsigned char RemoteHost[MAXEMAILNAMESIZE + 1]; /* Name of remote host */ - unsigned char *Command; /* Current command */ - unsigned char *From; /* For Routing Disabled */ - unsigned char *AuthFrom; /* Sender Authenticated As */ - unsigned char User[64]; /* Fixme - Make this bigger */ + char RemoteHost[MAXEMAILNAMESIZE + 1]; /* Name of remote host */ + char *Command; /* Current command */ + char *From; /* For Routing Disabled */ + char *AuthFrom; /* Sender Authenticated As */ + char User[64]; /* Fixme - Make this bigger */ BOOL IsEHLO; /* used for RFC 3848 */ } ConnectionStruct; typedef struct { - unsigned char To[MAXEMAILNAMESIZE+1]; - unsigned char ORecip[MAXEMAILNAMESIZE+1]; + char To[MAXEMAILNAMESIZE+1]; + char ORecip[MAXEMAILNAMESIZE+1]; unsigned long Flags; int Result; } RecipStruct; @@ -200,18 +200,20 @@ void *SMTPConnectionPool = NULL; /* Prototypes */ long ReadConnection(Connection *conn, char **buffer, unsigned long *buflen); void ProcessRemoteEntry (ConnectionStruct * Client, unsigned long Size, int Lines); -int RewriteAddress (Connection * conn, unsigned char *Source, unsigned char *Target, unsigned int TargetSize); +int RewriteAddress (Connection * conn, char *Source, char *Target, unsigned int TargetSize); BOOL FlushClient (ConnectionStruct * Client); BOOL EndClientConnection (ConnectionStruct * Client); -static int PullLine (unsigned char *Line, unsigned long LineSize, unsigned char **NextLine); +static int PullLine (char *Line, unsigned long LineSize, char **NextLine); /* this PullLine will strip off the crlf where the other one only seems to strip off the lf * eventually i'd like to remove the first and convert everything to using the straight connio * stuff for speed and security */ -static int PullLine2 (unsigned char *Line, unsigned long LineSize, unsigned char **NextLine); +static int PullLine2 (char *Line, unsigned long LineSize, char **NextLine); static BOOL SMTPConnectionAllocCB (void *Buffer, void *ClientData) { + UNUSED_PARAMETER(ClientData); + ConnectionStruct *c = (ConnectionStruct *) Buffer; memset (c, 0, sizeof (ConnectionStruct)); @@ -236,12 +238,12 @@ ReturnSMTPConnection (ConnectionStruct * Client) return; } -__inline static unsigned char * -strchrRN (unsigned char *Buffer, unsigned char SrchChar, - unsigned char *EndPtr) +__inline static char * +strchrRN (char *Buffer, char SrchChar, + char *EndPtr) { - unsigned char *ptr = Buffer; - unsigned char srchChar = SrchChar; + char *ptr = Buffer; + char srchChar = SrchChar; do { while (*ptr != '\0') { @@ -281,7 +283,7 @@ strchrRN (unsigned char *Buffer, unsigned char SrchChar, BOOL EndClientConnection (ConnectionStruct * Client) { - unsigned char Reply[BUFSIZE + 1]; + char Reply[BUFSIZE + 1]; if (Client) { if (Client->State == STATE_ENDING) { @@ -358,9 +360,9 @@ HandleConnection (void *param) BOOL AllowAuth = TRUE; BOOL NullSender = FALSE; BOOL TooManyNullSenderRecips = FALSE; - unsigned char *ptr, *ptr2; - unsigned char Answer[BUFSIZE + 1]; - unsigned char Reply[BUFSIZE + 1]; + char *ptr, *ptr2; + char Answer[BUFSIZE + 1]; + char Reply[BUFSIZE + 1]; struct sockaddr_in soc_address; struct sockaddr_in *sin = &soc_address; time_t connectionTime; @@ -505,7 +507,7 @@ HandleConnection (void *param) } case 'A':{ /* AUTH */ - unsigned char *PW; + char *PW; if (AllowAuth == FALSE) { ConnWrite (Client->client.conn, MSG500UNKNOWN, MSG500UNKNOWN_LEN); @@ -598,10 +600,10 @@ HandleConnection (void *param) case 'C':{ /* RCPT TO */ - unsigned char temp, *name; + char temp, *name; BOOL GotFlags = FALSE; - unsigned char To[MAXEMAILNAMESIZE + 1] = ""; - unsigned char *Orcpt = NULL; + char To[MAXEMAILNAMESIZE + 1] = ""; + char *Orcpt = NULL; if (Client->State < STATE_FROM) { ConnWrite (Client->client.conn, MSG501NOSENDER, @@ -875,9 +877,9 @@ HandleConnection (void *param) case 'M':{ /* MAIL FROM */ unsigned long size = 0; - unsigned char temp, *name; - unsigned char *Envid = NULL; - unsigned char *more; + char temp, *name; + char *Envid = NULL; + char *more; if (SMTP.require_auth && !IsTrusted) { ConnWrite (Client->client.conn, MSG553SPAMBLOCK, MSG553SPAMBLOCK_LEN); @@ -1205,9 +1207,9 @@ HandleConnection (void *param) break; case 'D':{ /* DATA */ - unsigned char TimeBuf[80]; + char TimeBuf[80]; unsigned long BReceived = 0; - unsigned char WithProtocol[8]; /* ESMTPSA */ + char WithProtocol[8]; /* ESMTPSA */ #ifdef USE_HOPCOUNT_DETECTION long HopCount = 0; #endif @@ -1531,7 +1533,7 @@ GetEHLO (ConnectionStruct * Client, unsigned long *Extensions, long *Size) { BOOL MultiLine; int Result; - unsigned char *ptr; + char *ptr; *Size = 0; @@ -1579,11 +1581,11 @@ GetEHLO (ConnectionStruct * Client, unsigned long *Extensions, long *Size) static int -GetAnswer (ConnectionStruct * Client, unsigned char *Reply, int ReplyLen) +GetAnswer (ConnectionStruct * Client, char *Reply, int ReplyLen) { BOOL MultiLine; int Result; - unsigned char *ptr; + char *ptr; do { ConnReadToAllocatedBuffer(Client->remotesmtp.conn, &(Client->remotesmtp.buffer), &(Client->remotesmtp.buflen)); @@ -1605,10 +1607,10 @@ GetAnswer (ConnectionStruct * Client, unsigned char *Reply, int ReplyLen) } static BOOL -SendServerEscaped (ConnectionStruct * Client, unsigned char *Data, +SendServerEscaped (ConnectionStruct * Client, char *Data, unsigned long Len, BOOL * EscapedState) { - unsigned char *ptr = Data; + char *ptr = Data; unsigned long Pos, EndPos; EndPos = Len - 1; @@ -1650,21 +1652,21 @@ SendServerEscaped (ConnectionStruct * Client, unsigned char *Data, } static int -DeliverSMTPMessage (ConnectionStruct * Client, unsigned char *Sender, +DeliverSMTPMessage (ConnectionStruct * Client, char *Sender, RecipStruct * Recips, unsigned int RecipCount, - unsigned int MsgFlags, unsigned char *Result, + unsigned int MsgFlags, char *Result, int ResultLen) { unsigned long Extensions = 0; - unsigned char Answer[1026]; - unsigned char Reply[1024]; - unsigned char *ptr, *EnvID = NULL; + char Answer[1026]; + char Reply[1024]; + char *ptr, *EnvID = NULL; int status; long Size, len, MessageSize; unsigned int i; BOOL EscapedState = FALSE; unsigned long LastNMAPContact; - unsigned char TimeBuf[80]; + char TimeBuf[80]; BOOL ehlo=TRUE; BOOL tls=FALSE; @@ -1839,9 +1841,9 @@ DeliverSMTPMessage (ConnectionStruct * Client, unsigned char *Sender, } else { /* Encode according to RFC 1891 */ - unsigned char HexTable[] = "0123456789ABCDEF"; - unsigned char *src; - unsigned char *dst; + char HexTable[] = "0123456789ABCDEF"; + char *src; + char *dst; strcpy (Answer, " ORCPT=rfc822;"); dst = Answer + 14; @@ -2113,13 +2115,13 @@ IPAddressIsLocal (struct in_addr IPAddress) } static int -DeliverRemoteMessage (ConnectionStruct * Client, unsigned char *Sender, +DeliverRemoteMessage (ConnectionStruct * Client, char *Sender, RecipStruct * Recips, unsigned int RecipCount, - unsigned long MsgFlags, unsigned char *Result, + unsigned long MsgFlags, char *Result, int ResultLen) { - unsigned char Host[MAXEMAILNAMESIZE + 1]; - unsigned char *ptr; + char Host[MAXEMAILNAMESIZE + 1]; + char *ptr; int status; int RetVal; XplDns_MxLookup *mx = NULL; @@ -2156,7 +2158,7 @@ DeliverRemoteMessage (ConnectionStruct * Client, unsigned char *Sender, ptr++; if (ptr[0] == '[') { // potential ip address in the host name (e.g. jdoe@[1.1.1.1]) - unsigned char *end; + char *end; end = strchr(ptr, ']'); if (end) { *end = '\0'; @@ -2252,10 +2254,10 @@ finish: } int -RewriteAddress(Connection * conn, unsigned char *Source, unsigned char *Target, unsigned int TargetSize) +RewriteAddress(Connection * conn, char *Source, char *Target, unsigned int TargetSize) { - unsigned char WorkSpace[1024]; - unsigned char *Src, *Dst; + char WorkSpace[1024]; + char *Src, *Dst; unsigned int i; int RetVal = MAIL_BOGUS; @@ -2399,8 +2401,8 @@ RewriteAddress(Connection * conn, unsigned char *Source, unsigned char *Target, /* TODO: i'm not sure this code is functionally equivalient with its replacement due to the address checking */ { - unsigned char addr[1024]; - unsigned char *ptr; + char addr[1024]; + char *ptr; NMAPSendCommandF(conn, "ADDRESS RESOLVE %s\r\n", WorkSpace); RetVal = NMAPReadResponse(conn, addr, 1023, FALSE); @@ -2451,8 +2453,8 @@ RewriteAddress(Connection * conn, unsigned char *Source, unsigned char *Target, static int RecipCompare (const RecipStruct * Recip1, const RecipStruct * Recip2) { - unsigned char *ptr1, *ptr2; - unsigned char char1, char2; + char *ptr1, *ptr2; + char char1, char2; if ((!(Recip1->To[0])) || (!(Recip2->To[0]))) { return (-1); @@ -2476,17 +2478,17 @@ RecipCompare (const RecipStruct * Recip1, const RecipStruct * Recip2) void ProcessRemoteEntry (ConnectionStruct * Client, unsigned long Size, int Lines) { - unsigned char *ptr, *ptr2; - unsigned char From[BUFSIZE + 1]; - unsigned char Reply[BUFSIZE + 1]; - unsigned char Result[BUFSIZE + 1]; + char *ptr, *ptr2; + char From[BUFSIZE + 1]; + char Reply[BUFSIZE + 1]; + char Result[BUFSIZE + 1]; BOOL Local = FALSE; int rc, i, j = 0, len; unsigned long MsgFlags = MSG_FLAG_ENCODING_7BIT; RecipStruct *Recips; int NumRecips = 0; - unsigned char *Envelope; - unsigned char *EnvelopePtr; + char *Envelope; + char *EnvelopePtr; if (!Client) return; @@ -2708,13 +2710,13 @@ RelayRemoteEntry (ConnectionStruct * client, unsigned long size, int lines) int j = 0; int recipCount = 0; unsigned long msgFlags = MSG_FLAG_ENCODING_7BIT; - unsigned char *ptr; - unsigned char *ptr2; - unsigned char *buffer; - unsigned char *bufferPtr; - unsigned char from[BUFSIZE + 1]; - unsigned char reply[BUFSIZE + 1]; - unsigned char result[BUFSIZE + 1]; + char *ptr; + char *ptr2; + char *buffer; + char *bufferPtr; + char from[BUFSIZE + 1]; + char reply[BUFSIZE + 1]; + char result[BUFSIZE + 1]; BOOL local = FALSE; RecipStruct *recips; @@ -2736,10 +2738,10 @@ RelayRemoteEntry (ConnectionStruct * client, unsigned long size, int lines) /* This makes sure the recip structure gets freed if we */ /* go into EndClientConnection for an error or shutdown */ - client->From = (unsigned char *) recips; + client->From = (char *) recips; /* This adds lines * sizeof(RecipStruct) */ - buffer = (unsigned char *) (recips + lines); + buffer = (char *) (recips + lines); bufferPtr = buffer; while ((rc = NMAPReadResponse (client->client.conn, reply, sizeof (reply), FALSE)) != 6021) { @@ -3025,8 +3027,8 @@ RelayRemoteEntry (ConnectionStruct * client, unsigned long size, int lines) return; } -static int PullLine2 (unsigned char *Line, unsigned long LineSize, unsigned char **NextLine) { - unsigned char *ptr; +static int PullLine2 (char *Line, unsigned long LineSize, char **NextLine) { + char *ptr; ptr = *NextLine; *NextLine = strchr (ptr, '\r'); @@ -3049,8 +3051,8 @@ static int PullLine2 (unsigned char *Line, unsigned long LineSize, unsigned char } } -static int PullLine (unsigned char *Line, unsigned long LineSize, unsigned char **NextLine) { - unsigned char *ptr; +static int PullLine (char *Line, unsigned long LineSize, char **NextLine) { + char *ptr; ptr = *NextLine; *NextLine = strchr (ptr, '\n'); @@ -3080,14 +3082,14 @@ RelayLocalEntry (ConnectionStruct * client, unsigned long size, int rc; int flags; unsigned long msgFlags = MSG_FLAG_ENCODING_7BIT; - unsigned char *ptr; - unsigned char *ptr2; - unsigned char *next; - unsigned char *envelope; - unsigned char buffer[1024]; - unsigned char to[MAXEMAILNAMESIZE + 1]; - unsigned char from[BUFSIZE + 1]; - unsigned char reply[BUFSIZE + 1]; + char *ptr; + char *ptr2; + char *next; + char *envelope; + char buffer[1024]; + char to[MAXEMAILNAMESIZE + 1]; + char from[BUFSIZE + 1]; + char reply[BUFSIZE + 1]; BOOL Local = FALSE; envelope = MemMalloc (size + 1); @@ -3278,17 +3280,17 @@ ProcessLocalEntry (ConnectionStruct * Client, unsigned long Size, unsigned long Lines) { unsigned long msgFlags = 0; - unsigned char Line[1024]; - unsigned char Reply[BUFSIZE + 1]; - unsigned char From[BUFSIZE + 1]; - unsigned char To[MAXEMAILNAMESIZE + 1]; - unsigned char *ptr, *ptr2; + char Line[1024]; + char Reply[BUFSIZE + 1]; + char From[BUFSIZE + 1]; + char To[MAXEMAILNAMESIZE + 1]; + char *ptr, *ptr2; int len; int rc, j; int Flags; BOOL Local = FALSE; - unsigned char *Envelope = MemMalloc (Size + 1); - unsigned char *NextLine = Envelope; + char *Envelope = MemMalloc (Size + 1); + char *NextLine = Envelope; while ((rc = NMAPReadResponse (Client->client.conn, Line, sizeof (Line), FALSE)) != 6021) { rc = strlen (Line); @@ -3424,9 +3426,9 @@ static void HandleQueueConnection (void *ClientIn) { int ReplyInt, Queue = Q_INCOMING; - unsigned char Reply[1024]; + char Reply[1024]; ConnectionStruct *Client = (ConnectionStruct *) ClientIn; - unsigned char *ptr; + char *ptr; unsigned long Lines; unsigned long Size; @@ -3823,7 +3825,6 @@ SMTPServer (void *ignored) ConnShutdown (); MemPrivatePoolFree (SMTPConnectionPool); - MemoryManagerClose (MSGSRV_AGENT_SMTP); Log(LOG_DEBUG, "Shutdown complete."); @@ -3844,7 +3845,7 @@ SMTPSSLServer (void *ignored) Connection *conn; int ccode; int arg; - unsigned char *message; + char *message; ConnectionStruct *client; XplThreadID id = 0; @@ -3997,23 +3998,16 @@ int XplServiceMain (int argc, char *argv[]) TGid = XplGetThreadGroupID (); - if (MemoryManagerOpen (MSGSRV_AGENT_SMTP) == TRUE) { - SMTPConnectionPool = - MemPrivatePoolAlloc ("SMTP Connections", - sizeof (ConnectionStruct), 0, 3072, TRUE, - FALSE, SMTPConnectionAllocCB, NULL, NULL); - if (SMTPConnectionPool != NULL) { - XplOpenLocalSemaphore (SMTPServerSemaphore, 0); - XplOpenLocalSemaphore (SMTPShutdownSemaphore, 1); - } - else { - MemoryManagerClose (MSGSRV_AGENT_SMTP); - Log(LOG_ERROR, "Unable to create connection pool, shutting down"); - return (-1); - } + SMTPConnectionPool = + MemPrivatePoolAlloc ("SMTP Connections", + sizeof (ConnectionStruct), 0, 3072, TRUE, + FALSE, SMTPConnectionAllocCB, NULL, NULL); + if (SMTPConnectionPool != NULL) { + XplOpenLocalSemaphore (SMTPServerSemaphore, 0); + XplOpenLocalSemaphore (SMTPShutdownSemaphore, 1); } else { - Log(LOG_ERROR, "Unable to initialize memory manager, shutting down"); + Log(LOG_ERROR, "Unable to create connection pool, shutting down"); return (-1); } diff --git a/src/agents/store/CMakeLists.txt b/src/agents/store/CMakeLists.txt index 2b7515a..e37b95d 100644 --- a/src/agents/store/CMakeLists.txt +++ b/src/agents/store/CMakeLists.txt @@ -27,7 +27,6 @@ add_executable(bongostore watch.c) target_link_libraries(bongostore - bongomemmgr bongoxpl bongoconnio bongoutil diff --git a/src/apps/config/config.c b/src/apps/config/config.c index 6fdd76a..f849497 100644 --- a/src/apps/config/config.c +++ b/src/apps/config/config.c @@ -556,11 +556,6 @@ main(int argc, char *argv[]) { BongoAgent configtool; config.verbose = 0; - if (!MemoryManagerOpen("bongo-config")) { - XplConsolePrintf("ERROR: Failed to initialize memory manager\n"); - return 1; - } - // this just clears up a warning. we don't need this here GlobalConfig[0].type = BONGO_JSON_NULL; @@ -683,6 +678,5 @@ main(int argc, char *argv[]) { if (config.dns) MemFree(config.dns); if (config.domains) BongoJsonNodeFree(config.domains); - MemoryManagerClose("bongo-config"); exit(0); } diff --git a/src/apps/manager/manager.c b/src/apps/manager/manager.c index 78676a4..134e550 100644 --- a/src/apps/manager/manager.c +++ b/src/apps/manager/manager.c @@ -858,10 +858,6 @@ get_lock: } unlockFile = TRUE; - if (!MemoryManagerOpen("bongomanager")) { - fprintf(stderr, _("bongo-manager: failed to initialize memory manager. Exiting\n")); - goto err_handler; - } ConnStartup(DEFAULT_CONNECTION_TIMEOUT); // set startLdap here if we want to start a managed slapd instance diff --git a/src/apps/testtool/testtool.c b/src/apps/testtool/testtool.c index e2cd383..2a27b46 100644 --- a/src/apps/testtool/testtool.c +++ b/src/apps/testtool/testtool.c @@ -61,11 +61,6 @@ main(int argc, char *argv[]) { int next_arg = 0; int command = 0; - if (!MemoryManagerOpen("bongo-testtool")) { - XplConsolePrintf(_("ERROR: Failed to initialize memory manager\n")); - return 1; - } - // parse options while (++next_arg < argc && argv[next_arg][0] == '-') { printf(_("Unrecognized option: %s\n"), argv[next_arg]); @@ -104,6 +99,5 @@ main(int argc, char *argv[]) { break; } - MemoryManagerClose("bongo-testtool"); exit(0); } diff --git a/src/libs/bongoutil/CMakeLists.txt b/src/libs/bongoutil/CMakeLists.txt index d44dfa2..4fa858c 100644 --- a/src/libs/bongoutil/CMakeLists.txt +++ b/src/libs/bongoutil/CMakeLists.txt @@ -1,5 +1,7 @@ add_library(bongoutil SHARED + pools.c + memstack.c array.c fileio.c hashtable.c @@ -11,4 +13,8 @@ add_library(bongoutil SHARED utf7mod.c bongoutil.c) +target_link_libraries(bongoutil + ${GLIB2_LIBRARIES} +) + install(TARGETS bongoutil DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/libs/memmgr/memmgrp.h b/src/libs/bongoutil/memmgrp.h similarity index 100% rename from src/libs/memmgr/memmgrp.h rename to src/libs/bongoutil/memmgrp.h diff --git a/src/libs/memmgr/memstack.c b/src/libs/bongoutil/memstack.c similarity index 100% rename from src/libs/memmgr/memstack.c rename to src/libs/bongoutil/memstack.c diff --git a/src/libs/memmgr/pools.c b/src/libs/bongoutil/pools.c similarity index 87% rename from src/libs/memmgr/pools.c rename to src/libs/bongoutil/pools.c index a3808be..9fd2ca0 100644 --- a/src/libs/memmgr/pools.c +++ b/src/libs/bongoutil/pools.c @@ -75,21 +75,3 @@ MemPrivatePoolReturnEntryDirect(void *PoolHandle, void *Source, const char *Sour g_slice_free1(ref->size, Source); return; } - -EXPORT BOOL -MemoryManagerOpen(const unsigned char *AgentName) -{ - UNUSED_PARAMETER_REFACTOR(AgentName); - - // do we need this? - return(TRUE); -} - -EXPORT BOOL -MemoryManagerClose(const unsigned char *AgentName) -{ - UNUSED_PARAMETER_REFACTOR(AgentName); - - // do we need this? - return(TRUE); -} diff --git a/src/libs/cal/CMakeLists.txt b/src/libs/cal/CMakeLists.txt index ab5474c..fbaf384 100644 --- a/src/libs/cal/CMakeLists.txt +++ b/src/libs/cal/CMakeLists.txt @@ -22,7 +22,6 @@ add_library(bongocal SHARED target_link_libraries(bongocal bongoxpl bongoutil - bongomemmgr ${LIBICAL_LIBRARIES} ) diff --git a/src/libs/memmgr/CMakeLists.txt b/src/libs/memmgr/CMakeLists.txt deleted file mode 100644 index 413fb6d..0000000 --- a/src/libs/memmgr/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -StrictCompile() - -add_library(bongomemmgr SHARED - allocator.c - pools.c - memstack.c -) - -target_link_libraries(bongomemmgr - ${GLIB2_LIBRARIES} -) - -install(TARGETS bongomemmgr DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/libs/memmgr/allocator.c b/src/libs/memmgr/allocator.c deleted file mode 100644 index 139597f..0000000 --- a/src/libs/memmgr/allocator.c +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/memmgr/memmgr.c b/src/libs/memmgr/memmgr.c deleted file mode 100644 index e69de29..0000000 diff --git a/src/libs/msgapi/CMakeLists.txt b/src/libs/msgapi/CMakeLists.txt index c311fa2..46fa8ae 100644 --- a/src/libs/msgapi/CMakeLists.txt +++ b/src/libs/msgapi/CMakeLists.txt @@ -11,7 +11,6 @@ add_library(bongomsgapi SHARED target_link_libraries(bongomsgapi bongoxpl - bongomemmgr bongonmap bongocal ${SQLITE_LIBRARIES} diff --git a/src/libs/msgapi/msgapi.c b/src/libs/msgapi/msgapi.c index d0dc15e..6b3756b 100644 --- a/src/libs/msgapi/msgapi.c +++ b/src/libs/msgapi/msgapi.c @@ -565,13 +565,9 @@ MsgLibraryInit(void) XplOpenLocalSemaphore(MsgGlobal.sem.shutdown, 0); XplMutexInit(MsgGlobal.sem.uid); - MemoryManagerOpen(NULL); - if (!MsgReadConfiguration()) { XplConsolePrintf("Cannot read configuration. Shutting down.\n"); - MemoryManagerClose(NULL); - return(0); } @@ -602,8 +598,6 @@ MsgLibraryShutdown(void) MsgLibraryStop(); - MemoryManagerClose(NULL); - MSGAPIState = LIBRARY_SHUTDOWN; XplSetThreadGroupID(oldGid); diff --git a/src/libs/nmap/CMakeLists.txt b/src/libs/nmap/CMakeLists.txt index 19826cd..d9ff477 100644 --- a/src/libs/nmap/CMakeLists.txt +++ b/src/libs/nmap/CMakeLists.txt @@ -1,3 +1,4 @@ +#StrictCompile() add_library(bongonmap SHARED bongoagent.c @@ -7,7 +8,6 @@ add_library(bongonmap SHARED target_link_libraries(bongonmap bongoconnio - bongomemmgr bongoxpl bongologging bongostreamio diff --git a/src/libs/nmap/bongoagent.c b/src/libs/nmap/bongoagent.c index ae94df9..7317595 100644 --- a/src/libs/nmap/bongoagent.c +++ b/src/libs/nmap/bongoagent.c @@ -92,6 +92,8 @@ BongoAgentHandleSignal(BongoAgent *agent, BOOL ReadConfiguration(BongoAgent *agent); BOOL ReadConfiguration(BongoAgent *agent) { + UNUSED_PARAMETER(agent); + return TRUE; } @@ -111,7 +113,7 @@ FreeBongoConfiguration(BongoConfigItem *config) { /* sub->destination here is the address of a pointer to an array */ GArray **output = (GArray **)sub->destination; if (sub->type == BONGO_JSON_STRING) { - int x; + unsigned int x; for(x=0;x<(*output)->len;x++) { MemFree(g_array_index(*output, char *, x)); } @@ -245,7 +247,7 @@ SetBongoConfigItem(BongoConfigItem *schema, BongoJsonNode *node) { BOOL ReadBongoConfiguration(BongoConfigItem *config, char *filename) { - unsigned char *pconfig = NULL; + char *pconfig = NULL; BongoJsonNode *node = NULL; BOOL retcode; @@ -300,11 +302,6 @@ BongoAgentInit(BongoAgent *agent, LogOpen(agentName); - if (!MemoryManagerOpen(agentName)) { - Log(LOG_ERROR, "Unable to initialize memory manager; shutting down."); - return -1; - } - if (startupResources & BA_STARTUP_CONNIO) { ConnStartup(timeOut); } @@ -607,8 +604,6 @@ BongoAgentShutdown(BongoAgent *agent) CONN_TRACE_SHUTDOWN(); ConnShutdown(); - - MemoryManagerClose(agent->name); } Connection * @@ -653,6 +648,8 @@ BongoQueueAgentGetThreadPoolParameters(BongoAgent *agent, int *maxThreads, int *minSleep) { + UNUSED_PARAMETER(agent); + *minThreads = BONGO_QUEUE_AGENT_MIN_THREADS; *maxThreads = BONGO_QUEUE_AGENT_MAX_THREADS; *minSleep = BONGO_QUEUE_AGENT_MIN_SLEEP; @@ -769,6 +766,11 @@ BongoAgentShutdownFunc (BongoJsonRpcServer *server, GArray *args, void *userData) { + UNUSED_PARAMETER(server); + UNUSED_PARAMETER(method); + UNUSED_PARAMETER(args); + UNUSED_PARAMETER(userData); + kill (getpid (), SIGTERM); /* Might not make it here */