10 Commits

Author SHA1 Message Date
alexhudson 2d1708f9cc Tagging 0.6 release. 2009-08-30 17:38:20 +00:00
alexhudson f81addc50e Minor fix to distribution version 2009-08-30 17:37:54 +00:00
alexhudson c352aae824 Merge in install fix from trunk 2009-08-30 17:14:32 +00:00
alexhudson 51820ccde5 Set version number on branch for release 2009-08-30 17:14:05 +00:00
alexhudson 906368d5a9 Take last trunk merge for 0.6 2009-08-30 16:32:45 +00:00
alexhudson a1f3775418 Re-merge trunk to releng-0.6 including r1171/1172 mixup... 2009-08-23 16:54:18 +00:00
alexhudson bf4ce71c5e Don't always run Bongo as the 'root' user 2009-08-23 16:45:42 +00:00
alexhudson fca127c820 Merge latest changes from trunk 2009-08-23 13:55:27 +00:00
alexhudson 13a73ebb6e Merge 0.6 with latest trunk bits 2009-08-21 15:40:01 +00:00
alexhudson a03597ae55 Branching for 0.6 release 2009-08-19 09:01:10 +00:00
49 changed files with 150 additions and 91 deletions
+15 -3
View File
@@ -6,6 +6,11 @@ cmake_minimum_required(VERSION 2.6)
cmake_policy(VERSION 2.6) cmake_policy(VERSION 2.6)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(BONGO_V_MAJOR 0)
set(BONGO_V_MINOR 6)
set(BONGO_V_BUILD 0)
set(BONGO_V_STR "${BONGO_V_MAJOR}.${BONGO_V_MINOR}.${BONGO_V_BUILD}")
# arguments we can supply to the build system - TODO # arguments we can supply to the build system - TODO
set(BONGO_USER "root" CACHE STRING "User account Bongo should run under") set(BONGO_USER "root" CACHE STRING "User account Bongo should run under")
option(CONN_TRACE "Enable connection tracing" OFF) option(CONN_TRACE "Enable connection tracing" OFF)
@@ -35,16 +40,23 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
# now build our various libraries, agents, binaries. # now build our various libraries, agents, binaries.
foreach (LIBRARY xpl streamio logging msgapi connio bongoutil # DO NOT ALTER (SO)VERSION ON LIBRARIES WITHOUT ASKING!
json cal nmap python/libbongo python/bongo) foreach (LIBRARY xpl streamio logging msgapi connio util json cal nmap)
add_subdirectory (src/libs/${LIBRARY}) add_subdirectory (src/libs/${LIBRARY})
set_target_properties(bongo${LIBRARY} PROPERTIES
SOVERSION 0
VERSION ${BONGO_V_STR}
)
endforeach (LIBRARY) endforeach (LIBRARY)
add_subdirectory(src/libs/python/libbongo)
add_subdirectory(src/libs/python/bongo)
foreach (AGENT antispam avirus imap pop queue rules smtp store) foreach (AGENT antispam avirus imap pop queue rules smtp store)
add_subdirectory (src/agents/${AGENT}) add_subdirectory (src/agents/${AGENT})
endforeach (AGENT) endforeach (AGENT)
foreach (EXECUTABLE config manager testtool queuetool storetool) foreach (EXECUTABLE config manager testtool queuetool storetool sendmail backup)
add_subdirectory (src/apps/${EXECUTABLE}) add_subdirectory (src/apps/${EXECUTABLE})
endforeach (EXECUTABLE) endforeach (EXECUTABLE)
+5 -2
View File
@@ -21,7 +21,10 @@ if (DEBUG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -g3 -ggdb -O0" PARENT_SCOPE) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -g3 -ggdb -O0" PARENT_SCOPE)
endif (DEBUG) endif (DEBUG)
option(STRICTCOMPILE "Enable strict compilation rules" ON)
function (StrictCompile) function (StrictCompile)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -std=c99 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE" PARENT_SCOPE) if (STRICTCOMPILE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -std=c++98 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE" PARENT_SCOPE) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -std=c99 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE" PARENT_SCOPE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -std=c++98 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200112 -D_GNU_SOURCE" PARENT_SCOPE)
endif (STRICTCOMPILE)
endfunction (StrictCompile) endfunction (StrictCompile)
+3 -3
View File
@@ -2,9 +2,9 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mail and calendering made simple")
set(CPACK_PACKAGE_VENDOR "Bongo Project") set(CPACK_PACKAGE_VENDOR "Bongo Project")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MAJOR "${BONGO_V_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "1") set(CPACK_PACKAGE_VERSION_MINOR "${BONGO_V_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "0") set(CPACK_PACKAGE_VERSION_PATCH "${BONGO_V_BUILD}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
+1 -1
View File
@@ -1,5 +1,5 @@
/* The username which bongo runs as. */ /* The username which bongo runs as. */
#cmakedefine BONGO_USER "root" #cmakedefine BONGO_USER "@BONGO_USER@"
// our package name // our package name
#cmakedefine PACKAGE "@CMAKE_PROJECT_NAME@" #cmakedefine PACKAGE "@CMAKE_PROJECT_NAME@"
+1 -1
View File
@@ -96,7 +96,7 @@ typedef struct _BongoConfigItem {
} BongoConfigItem; } BongoConfigItem;
BOOL ReadBongoConfiguration(BongoConfigItem *config, char *filename); BOOL ReadBongoConfiguration(BongoConfigItem *config, char *filename);
BOOL ProcessBongoConfiguration(BongoConfigItem *config, const BongoJsonNode *node); BOOL ProcessBongoConfiguration(BongoConfigItem *config, BongoJsonNode *node);
BOOL SetBongoConfigItem(BongoConfigItem *schema, BongoJsonNode *node); BOOL SetBongoConfigItem(BongoConfigItem *schema, BongoJsonNode *node);
void FreeBongoConfiguration(BongoConfigItem *config); void FreeBongoConfiguration(BongoConfigItem *config);
+1 -1
View File
@@ -356,7 +356,7 @@ int BongoListVoidToInt (void * ptr);
typedef int (*ArrayCompareFunc)(const void *, const void *); typedef int (*ArrayCompareFunc)(const void *, const void *);
int GArrayFindUnsorted(GArray *array, void *needle, ArrayCompareFunc compare); int GArrayFindUnsorted(GArray *array, void *needle, ArrayCompareFunc compare);
int GArrayFindSorted(GArray *array, void *needle, ArrayCompareFunc compare); int GArrayFindSorted(GArray *array, void *needle, ssize_t type_size, ArrayCompareFunc compare);
#if 0 #if 0
typedef struct _BongoArray BongoArray; typedef struct _BongoArray BongoArray;
+2 -1
View File
@@ -209,9 +209,10 @@ EXPORT BOOL MsgFindUserNmap(const unsigned char *user, unsigned char *nmap, int
EXPORT unsigned long MsgGetHostIPAddress(void); EXPORT unsigned long MsgGetHostIPAddress(void);
EXPORT unsigned long MsgGetAgentBindIPAddress(void); EXPORT unsigned long MsgGetAgentBindIPAddress(void);
EXPORT const char *MsgGetUnprivilegedUser(void); EXPORT const char *MsgGetUnprivilegedUser(void);
EXPORT void MsgMakePath(char *path); EXPORT void MsgMakePath(char *path);
EXPORT void MsgMakePathChown(char *path, int uid, int gid);
EXPORT BOOL MsgCleanPath(char *path); EXPORT BOOL MsgCleanPath(char *path);
EXPORT BOOL MsgResolveStart(); EXPORT BOOL MsgResolveStart();
+6 -3
View File
@@ -4,10 +4,11 @@
# #
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: bongo # Provides: bongo
# Required-Start: $network # Required-Start: $network $remote_fs
# Required-Stop: $remote_fs # Required-Stop: $remote_fs
# Default-Start: 3 4 5 # Default-Start: 3 4 5
# Default-Stop: 0 1 2 6 # Default-Stop: 0 1 2 6
# Short-Description: Start and stops Bongo
# Description: Bongo collaboration system, visit: http://www.bongo-project.com # Description: Bongo collaboration system, visit: http://www.bongo-project.com
### END INIT INFO ### END INIT INFO
@@ -28,6 +29,8 @@ BONGO_NAME=bongo-manager
BONGO_CONFIG=bongo-config BONGO_CONFIG=bongo-config
BONGO_LIST="bongoantisapm bongoavirus bongo-config bongoimap bongo-manager bongopop3 bongoqueue bongo-queuetool bongorules bongosmtp bongosmtpc bongostore bongo-testtool" BONGO_LIST="bongoantisapm bongoavirus bongo-config bongoimap bongo-manager bongopop3 bongoqueue bongo-queuetool bongorules bongosmtp bongosmtpc bongostore bongo-testtool"
BONGO_DATA=@CMAKE_INSTALL_PREFIX@/var/bongo/dbf/userdb.sqlite BONGO_DATA=@CMAKE_INSTALL_PREFIX@/var/bongo/dbf/userdb.sqlite
echo $BONGO_BIN/$BONGO_NAME
test -x $BONGO_BIN/$BONGO_NAME || exit 5 test -x $BONGO_BIN/$BONGO_NAME || exit 5
# Shell functions sourced from /etc/rc.status: # Shell functions sourced from /etc/rc.status:
@@ -77,7 +80,7 @@ case "$1" in
# Remember status and be verbose # Remember status and be verbose
rc_status -v rc_status -v
;; ;;
restart) reload|restart)
## Stop the service and regardless of whether it was ## Stop the service and regardless of whether it was
## running or not, start it again. ## running or not, start it again.
$0 stop $0 stop
@@ -92,7 +95,7 @@ case "$1" in
rc_status -v rc_status -v
;; ;;
*) *)
echo "Usage: $0 {start|stop|status|restart}" echo "Usage: $0 {start|stop|status|restart|reload}"
exit 1 exit 1
;; ;;
esac esac
+1 -1
View File
@@ -347,7 +347,7 @@ SpamdReadConfiguration(SpamdConfig *spamd)
char *hostitem = g_array_index(ASpam.spamd.hostlist, char*, i); char *hostitem = g_array_index(ASpam.spamd.hostlist, char*, i);
char *lHost = MemStrdup(hostitem); char *lHost = MemStrdup(hostitem);
char *host; char *host;
int port, weight; int port=SPAMD_DEFAULT_PORT, weight=SPAMD_DEFAULT_WEIGHT;
ParseHost(lHost, &host, &port, &weight); ParseHost(lHost, &host, &port, &weight);
ConnAddressPoolAddHost(&ASpam.spamd.hosts, host, port, weight); ConnAddressPoolAddHost(&ASpam.spamd.hosts, host, port, weight);
MemFree(lHost); MemFree(lHost);
+3 -1
View File
@@ -38,6 +38,8 @@
#include <logger.h> #include <logger.h>
#include "avirus.h" #include "avirus.h"
#define AVIRUS_DEFAULT_PORT 3310
#define AVIRUS_DEFAULT_WEIGHT 1
static void SignalHandler(int sigtype); static void SignalHandler(int sigtype);
@@ -423,7 +425,7 @@ ReadConfiguration(void) {
char *hostitem = g_array_index(AVirus.clamd.hostlist, char*, i); char *hostitem = g_array_index(AVirus.clamd.hostlist, char*, i);
char *lHost = MemStrdup(hostitem); char *lHost = MemStrdup(hostitem);
char *host; char *host;
int port, weight; int port=AVIRUS_DEFAULT_PORT, weight=AVIRUS_DEFAULT_WEIGHT;
ParseHost(lHost, &host, &port, &weight); ParseHost(lHost, &host, &port, &weight);
ConnAddressPoolAddHost(&AVirus.clamd.hosts, host, port, weight); ConnAddressPoolAddHost(&AVirus.clamd.hosts, host, port, weight);
MemFree(lHost); MemFree(lHost);
+2
View File
@@ -464,6 +464,8 @@ ConnectUserToNMAPServer(POP3Client *client, unsigned char *username, unsigned ch
XplSafeIncrement(POP3.stats.badPasswords); XplSafeIncrement(POP3.stats.badPasswords);
Log(LOG_NOTICE, "Incorrect password for user %s from host %s", username, Log(LOG_NOTICE, "Incorrect password for user %s from host %s", username,
LOGIP(client->conn->socketAddress)); LOGIP(client->conn->socketAddress));
/* the use was not found. Error, don't continue */
return(POP3_NMAP_USER_UNKNOWN);
} }
MsgAuthGetUserStore(username, &nmap); MsgAuthGetUserStore(username, &nmap);
+2 -1
View File
@@ -22,6 +22,7 @@
#include <config.h> #include <config.h>
#include "queued.h"
#include "conf.h" #include "conf.h"
#include "queue.h" #include "queue.h"
@@ -203,7 +204,7 @@ ReadConfiguration (BOOL *recover)
unsigned int x; unsigned int x;
for(x=0;x<Conf.domains->len;x++) { for(x=0;x<Conf.domains->len;x++) {
unsigned char *aconfig; char *aconfig;
unsigned char path[100]; unsigned char path[100];
BongoJsonNode *node; BongoJsonNode *node;
struct _AliasStruct a; struct _AliasStruct a;
+3 -3
View File
@@ -228,7 +228,7 @@ SendMimeDetails(Connection *conn, MIMEReportStruct *report)
for (i=0; i < parts; i++) { for (i=0; i < parts; i++) {
/* 2002 <type> <subtype> <charset> <encoding> <name> <part-head-start> <part-head-size> <part-start-pos> <Size> <RFC822 Header-Size> <lines> */ /* 2002 <type> <subtype> <charset> <encoding> <name> <part-head-start> <part-head-size> <part-start-pos> <Size> <RFC822 Header-Size> <lines> */
if (XplStrCaseCmp(part[i].subtype, "RFC822") && ((i + 1) < parts)) { if (XplStrCaseCmp(part[i].subtype, "RFC822") && ((i + 1) < parts)) {
ccode = ConnWriteF(conn, "2002-%s %s %s %s \"%s\" %d %lu %lu %lu %lu %lu\r\n", ccode = ConnWriteF(conn, "2002-%s %s %s %s \"%s\" %ld %lu %lu %lu %lu %lu\r\n",
part[i].type, part[i].type,
part[i].subtype, part[i].subtype,
part[i].charset, part[i].charset,
@@ -241,7 +241,7 @@ SendMimeDetails(Connection *conn, MIMEReportStruct *report)
part[i + 1].start - part[i].start, part[i + 1].start - part[i].start,
part[i].lines); part[i].lines);
} else if (XplStrCaseCmp(part[i].type, "TEXT")) { } else if (XplStrCaseCmp(part[i].type, "TEXT")) {
ccode = ConnWriteF(conn, "2002-%s %s %s %s \"%s\" %d %lu %lu %lu 0 %lu\r\n", ccode = ConnWriteF(conn, "2002-%s %s %s %s \"%s\" %ld %lu %lu %lu 0 %lu\r\n",
part[i].type, part[i].type,
part[i].subtype, part[i].subtype,
part[i].charset, part[i].charset,
@@ -253,7 +253,7 @@ SendMimeDetails(Connection *conn, MIMEReportStruct *report)
part[i].length, part[i].length,
part[i].lines); part[i].lines);
} else { } else {
ccode = ConnWriteF(conn, "2002-%s %s %s %s \"%s\" %d %lu %lu %lu 0 0\r\n", ccode = ConnWriteF(conn, "2002-%s %s %s %s \"%s\" %ld %lu %lu %lu 0 0\r\n",
part[i].type, part[i].type,
part[i].subtype, part[i].subtype,
part[i].charset, part[i].charset,
+4 -4
View File
@@ -313,7 +313,7 @@ AddPushAgent(QueueClient *client,
/* first look through the list to find the right queue */ /* first look through the list to find the right queue */
tempQueue.queue = queue; tempQueue.queue = queue;
ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue); ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, sizeof(QueueList *), FindQueue);
if (ItemIndex < 0) { if (ItemIndex < 0) {
/* there is no queue item in the array yet. we need to initialize one */ /* there is no queue item in the array yet. we need to initialize one */
CurrentQueue = MemNew0(QueueList, 1); CurrentQueue = MemNew0(QueueList, 1);
@@ -326,7 +326,7 @@ AddPushAgent(QueueClient *client,
/* CurrentQueue should be set now */ /* CurrentQueue should be set now */
strncpy(tempPool.identifier, identifier, 100); strncpy(tempPool.identifier, identifier, 100);
ItemIndex = GArrayFindSorted(CurrentQueue->pools, &p_tempPool, FindPool); ItemIndex = GArrayFindSorted(CurrentQueue->pools, &p_tempPool, sizeof(QueuePoolList *), FindPool);
if (ItemIndex < 0) { if (ItemIndex < 0) {
/* there is no pool already. we need to initialize one */ /* there is no pool already. we need to initialize one */
CurrentPool = MemNew0(QueuePoolList, 1); CurrentPool = MemNew0(QueuePoolList, 1);
@@ -1432,7 +1432,7 @@ StartOver:
/* i want to get the current queue and iterate over its pools if there are any */ /* i want to get the current queue and iterate over its pools if there are any */
tempQueue.queue = queue; tempQueue.queue = queue;
ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue); ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, sizeof(QueueList *), FindQueue);
if (ItemIndex >= 0) { if (ItemIndex >= 0) {
QueueList *CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex); QueueList *CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex);
for (iter_p=0; iter_p < CurrentQueue->pools->len; iter_p++) { for (iter_p=0; iter_p < CurrentQueue->pools->len; iter_p++) {
@@ -2135,7 +2135,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO
case DELIVER_QUOTA_EXCEEDED: { case DELIVER_QUOTA_EXCEEDED: {
if (Conf.quotaMessage && (Conf.quotaMessage[0] != '\0')) { if (Conf.quotaMessage && (Conf.quotaMessage[0] != '\0')) {
fprintf(rtsData, Conf.quotaMessage); fprintf(rtsData, "%s", Conf.quotaMessage);
} else { } else {
fprintf(rtsData, DEFAULT_QUOTA_MESSAGE); fprintf(rtsData, DEFAULT_QUOTA_MESSAGE);
} }
+9 -6
View File
@@ -158,7 +158,7 @@ BOOL aliasing(char *addr, int *cnt, unsigned char *buffer) {
} }
/* if i get here, i've got a domain name that i can look up in the alias system */ /* if i get here, i've got a domain name that i can look up in the alias system */
i = GArrayFindSorted(Conf.aliasList, domain, (ArrayCompareFunc)aliasFindFunc); i = GArrayFindSorted(Conf.aliasList, domain, sizeof(struct _AliasStruct), (ArrayCompareFunc)aliasFindFunc);
if (i > -1) { if (i > -1) {
char new_addr[1000]; /* FIXME: seems a bit large */ char new_addr[1000]; /* FIXME: seems a bit large */
AliasStruct a; AliasStruct a;
@@ -167,7 +167,7 @@ BOOL aliasing(char *addr, int *cnt, unsigned char *buffer) {
a = g_array_index(Conf.aliasList, AliasStruct, i); a = g_array_index(Conf.aliasList, AliasStruct, i);
/* user aliases should take precedence over domain aliases. check for one of those first */ /* user aliases should take precedence over domain aliases. check for one of those first */
if (a.aliases && a.aliases->len && ((i = GArrayFindSorted(a.aliases, local, (ArrayCompareFunc)aliasFindFunc)) > -1)) { if (a.aliases && a.aliases->len && ((i = GArrayFindSorted(a.aliases, local, sizeof(struct _AliasStruct), (ArrayCompareFunc)aliasFindFunc)) > -1)) {
AliasStruct b; AliasStruct b;
b = g_array_index(a.aliases, AliasStruct, i); b = g_array_index(a.aliases, AliasStruct, i);
result = aliasing(b.to, cnt, buffer); result = aliasing(b.to, cnt, buffer);
@@ -242,7 +242,7 @@ int CommandAddressResolve(void *param) {
unsigned char buffer[1024]; /* FIXME: is this too big? */ unsigned char buffer[1024]; /* FIXME: is this too big? */
QueueClient *client = (QueueClient *)param; QueueClient *client = (QueueClient *)param;
handled = aliasing(client->buffer + 16, &cnt, &buffer); handled = aliasing(client->buffer + 16, &cnt, buffer);
if (!handled) { if (!handled) {
ConnWriteF(client->conn, MSG4001NO_USER"\r\n", client->buffer + 16); ConnWriteF(client->conn, MSG4001NO_USER"\r\n", client->buffer + 16);
} else { } else {
@@ -253,10 +253,11 @@ int CommandAddressResolve(void *param) {
int CommandDomainLocation(void *param) { int CommandDomainLocation(void *param) {
QueueClient *client = (QueueClient *)param; QueueClient *client = (QueueClient *)param;
// FIXME: is this actually used at all with our current aliasing stuff?
/* first find the domain in the request */ /* first find the domain in the request */
unsigned char *domain = client->buffer + 16; unsigned char *domain = client->buffer + 16;
#if 0
/* now search for it */ /* now search for it */
int idx = GArrayFindSorted(Conf.hostedDomains, domain, (ArrayCompareFunc)hostedFindFunc); int idx = GArrayFindSorted(Conf.hostedDomains, domain, (ArrayCompareFunc)hostedFindFunc);
if (idx > -1) { if (idx > -1) {
@@ -265,6 +266,8 @@ int CommandDomainLocation(void *param) {
/* TODO: add the relay domain stuff */ /* TODO: add the relay domain stuff */
ConnWriteF(client->conn, MSG1002REMOTE"\r\n", domain); ConnWriteF(client->conn, MSG1002REMOTE"\r\n", domain);
} }
#endif
ConnWriteF(client->conn, MSG1000LOCAL"\r\n", domain);
return 0; return 0;
} }
@@ -428,7 +431,7 @@ CheckTrustedHost(QueueClient *client)
if (Conf.trustedHosts) { if (Conf.trustedHosts) {
/* TODO: this can be optimized a little bit */ /* TODO: this can be optimized a little bit */
XplRWReadLockAcquire(&Conf.lock); XplRWReadLockAcquire(&Conf.lock);
i = GArrayFindSorted(Conf.trustedHosts, inet_ntoa(client->conn->socketAddress.sin_addr), (ArrayCompareFunc)hostedFindFunc); i = GArrayFindSorted(Conf.trustedHosts, inet_ntoa(client->conn->socketAddress.sin_addr), sizeof (char *), (ArrayCompareFunc)hostedFindFunc);
XplRWReadLockRelease(&Conf.lock); XplRWReadLockRelease(&Conf.lock);
} }
return (i > -1); return (i > -1);
+1 -1
View File
@@ -3969,7 +3969,7 @@ ReadConfiguration (void)
LocalAddress = MsgGetHostIPAddress (); LocalAddress = MsgGetHostIPAddress ();
MsgGetServerCredential(&NMAPHash); MsgGetServerCredential(NMAPHash);
return (TRUE); return (TRUE);
} }
+1
View File
@@ -1,3 +1,4 @@
.section ".note.GNU-stack","",%progbits
.section ".rodata" .section ".rodata"
.globl sql_create_store .globl sql_create_store
.type sql_create_store,@object .type sql_create_store,@object
+12
View File
@@ -0,0 +1,12 @@
add_executable(bongo-backup
backup.c
)
target_link_libraries(bongo-backup
bongomsgapi
bongojson
bongoutil
bongoconnio
)
install(TARGETS bongo-backup DESTINATION ${SBIN_INSTALL_DIR})
+3 -9
View File
@@ -1455,11 +1455,6 @@ main(int argc, char *argv[])
BongoBackup.backup_date = time(NULL); BongoBackup.backup_date = time(NULL);
BongoBackup.verbose = 0; BongoBackup.verbose = 0;
if (!MemoryManagerOpen("Bongo Backup")) {
XplConsolePrintf(_("Failed to initialize memory manager\n"));
return 1;
}
/* parse options */ /* parse options */
while (++next_arg < argc && argv[next_arg][0] == '-') { while (++next_arg < argc && argv[next_arg][0] == '-') {
if ((arg_ptr = strchr(argv[next_arg], '=')) != '\0') { if ((arg_ptr = strchr(argv[next_arg], '=')) != '\0') {
@@ -1539,7 +1534,7 @@ main(int argc, char *argv[])
/* backup */ /* backup */
XplConsolePrintf(_("Backing up data\n")); XplConsolePrintf(_("Backing up data\n"));
if (ConnStartup((300), FALSE)) { if (ConnStartup((300))) {
if ((nmap = GetConnection(NULL))) { if ((nmap = GetConnection(NULL))) {
if (next_backup_arg < 1) { if (next_backup_arg < 1) {
/* full backup */ /* full backup */
@@ -1594,7 +1589,7 @@ main(int argc, char *argv[])
/* restore */ /* restore */
XplConsolePrintf(_("Restoring data\n")); XplConsolePrintf(_("Restoring data\n"));
if (ConnStartup((300), FALSE)) { if (ConnStartup((300))) {
if (next_backup_arg < 1) { if (next_backup_arg < 1) {
/* full restore */ /* full restore */
if ((store_dir = opendir(BongoBackup.store_path))) { if ((store_dir = opendir(BongoBackup.store_path))) {
@@ -1642,9 +1637,8 @@ main(int argc, char *argv[])
XplConsolePrintf(_("Search command not implemented\n")); XplConsolePrintf(_("Search command not implemented\n"));
} else { } else {
/* help */ /* help */
XplConsolePrintf(usage); XplConsolePrintf("%s", usage);
} }
MemoryManagerClose("Bongo Backup");
return 1; return 1;
} }
+1 -2
View File
@@ -179,8 +179,7 @@ InitializeDataArea(void)
for (dir = MSGAPI_DIR_START; dir < MSGAPI_DIR_END; dir++) { for (dir = MSGAPI_DIR_START; dir < MSGAPI_DIR_END; dir++) {
char path[XPL_MAX_PATH]; char path[XPL_MAX_PATH];
if (MsgGetDir(dir, path, XPL_MAX_PATH)) { if (MsgGetDir(dir, path, XPL_MAX_PATH)) {
MsgMakePath(path); MsgMakePathChown(path, uid, gid);
chown(path, uid, gid);
} }
} }
+3 -3
View File
@@ -115,7 +115,7 @@ PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *
char command[1024]; char command[1024];
snprintf(command, 1000, "INFO %s/%s\r\n", collection, filename); snprintf(command, 1000, "INFO %s/%s\r\n", collection, filename);
ccode = NMAPSendCommandF(client->conn, command); ccode = NMAPSendCommandF(client->conn, "%s", command);
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE); ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
while (ccode == 2001) while (ccode == 2001)
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE); ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
@@ -130,7 +130,7 @@ PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *
collection, STORE_DOCTYPE_CONFIG, len, filename); collection, STORE_DOCTYPE_CONFIG, len, filename);
} }
NMAPSendCommandF(client->conn, command); NMAPSendCommandF(client->conn, "%s", command);
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE); ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
if (ccode == 2002) { if (ccode == 2002) {
@@ -151,7 +151,7 @@ BOOL
NMAPSimpleCommand(StoreClient *client, char *command) { NMAPSimpleCommand(StoreClient *client, char *command) {
CCode ccode; CCode ccode;
NMAPSendCommandF(client->conn, command); NMAPSendCommandF(client->conn, "%s", command);
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE); ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
if (1000 == ccode) if (1000 == ccode)
return TRUE; return TRUE;
+1 -1
View File
@@ -302,7 +302,7 @@ StartAgentsWithPriority(int priority, BOOL onlyCrashed, BOOL printMessage)
static BOOL static BOOL
LoadAgentConfiguration() LoadAgentConfiguration()
{ {
unsigned char *config; char *config;
BOOL retcode = FALSE; BOOL retcode = FALSE;
BongoJsonNode *node; BongoJsonNode *node;
BongoJsonResult res; BongoJsonResult res;
+12
View File
@@ -0,0 +1,12 @@
add_executable(bongo-sendmail
sendmail.c
)
target_link_libraries(bongo-sendmail
bongomsgapi
bongojson
bongoutil
bongoconnio
)
install(TARGETS bongo-sendmail DESTINATION ${SBIN_INSTALL_DIR})
+1 -6
View File
@@ -76,11 +76,7 @@ main (int argc, char *argv[])
char command[200]; char command[200];
int i; int i;
if (! MemoryManagerOpen("BongoSendmail")) { ConnStartup((15*60));
FatalError(1, "unable to initialise memory manager.");
}
ConnStartup((15*60), TRUE);
MsgInit(); MsgInit();
NMAPInitialize(); NMAPInitialize();
@@ -177,7 +173,6 @@ main (int argc, char *argv[])
NMAPQuit(nmap); NMAPQuit(nmap);
CONN_TRACE_SHUTDOWN(); CONN_TRACE_SHUTDOWN();
MemoryManagerClose("BongoSendmail");
return(0); return(0);
} }
+1 -1
View File
@@ -596,7 +596,7 @@ BongoCalObjectGetInstance(BongoCalObject *cal, const char *uid, BongoCalTime rec
data.uid = uid; data.uid = uid;
data.recurid = recurid; data.recurid = recurid;
i = GArrayFindSorted(cal->instances, &data, FindInstanceById); i = GArrayFindSorted(cal->instances, &data, sizeof(BongoCalInstance *), FindInstanceById);
if (i != -1) { if (i != -1) {
return g_array_index(cal->instances, BongoCalInstance *, i); return g_array_index(cal->instances, BongoCalInstance *, i);
} else { } else {
+8 -4
View File
@@ -447,11 +447,15 @@ ConnNegotiate(Connection *conn, bongo_ssl_context *context)
CONN_TRACE_EVENT(c, CONN_TRACE_EVENT_SSL_CONNECT); CONN_TRACE_EVENT(c, CONN_TRACE_EVENT_SSL_CONNECT);
return(TRUE); return(TRUE);
} }
gnutls_deinit(c->ssl.context); if (c->ssl.context) {
gnutls_certificate_free_credentials(c->ssl.credentials); gnutls_deinit(c->ssl.context);
c->ssl.context = NULL;
}
if (c->ssl.credentials) {
gnutls_certificate_free_credentials(c->ssl.credentials);
c->ssl.credentials = NULL;
}
c->ssl.enable = FALSE; c->ssl.enable = FALSE;
c->ssl.context = NULL;
c->ssl.credentials = NULL;
} }
return(FALSE); return(FALSE);
+1 -1
View File
@@ -158,7 +158,7 @@ MsgAuthDeleteCookie(const char *username, const char *token)
// next, clear the existing file // next, clear the existing file
rewind(cookiefile); rewind(cookiefile);
ftruncate((int)cookiefile, 0); ftruncate(fileno(cookiefile), 0);
// now, go through memory writing out only the cookies we want to keep // now, go through memory writing out only the cookies we want to keep
for (i = 0; i < cookiecount; i++) { for (i = 0; i < cookiecount; i++) {
+35 -21
View File
@@ -210,30 +210,44 @@ MsgCleanPath(char *path)
EXPORT void EXPORT void
MsgMakePath(char *path) MsgMakePath(char *path)
{ {
char *ptr = path; return MsgMakePathChown(path, -1, -1);
char *ptr2; }
struct stat sb;
ptr = strchr(path, '/'); EXPORT void
if (!ptr) MsgMakePathChown(char *path, int uid, int gid)
ptr=strchr(path, '\\'); {
char *ptr = path;
char *ptr2;
struct stat sb;
while (ptr) { ptr = strchr(path, '/');
*ptr = '\0'; if (!ptr)
if (stat(path, &sb) != 0) { ptr=strchr(path, '\\');
XplMakeDir(path);
}
*ptr = '/'; while (ptr) {
ptr2 = ptr; *ptr = '\0';
ptr = strchr(ptr2 + 1, '/'); if (stat(path, &sb) != 0) {
if (!ptr) XplMakeDir(path);
ptr = strchr(ptr2 + 1, '\\'); if ((uid != -1) && (gid != -1)) {
} // TODO: this assumes success. Usually we
// ought to be root when calling this, so...
if (stat(path, &sb) != 0) { chown(path, uid, gid);
XplMakeDir(path); }
} }
*ptr = '/';
ptr2 = ptr;
ptr = strchr(ptr2 + 1, '/');
if (!ptr)
ptr = strchr(ptr2 + 1, '\\');
}
if (stat(path, &sb) != 0) {
XplMakeDir(path);
if ((uid != -1) && (gid != -1)) {
chown(path, uid, gid);
}
}
} }
EXPORT const char * EXPORT const char *
+8 -6
View File
@@ -180,7 +180,7 @@ MsgSQLBeginTransaction(MsgSQLHandle *handle)
case SQLITE_BUSY: case SQLITE_BUSY:
return -2; return -2;
default: default:
printf("Database error %d : %s\n", result, sqlite3_errmsg(stmt->stmt)); printf("Database error %d : %s\n", result, sqlite3_errmsg(handle->db));
//DStoreStmtError(handle, stmt); //DStoreStmtError(handle, stmt);
return -1; return -1;
} }
@@ -212,7 +212,7 @@ MsgSQLCommitTransaction(MsgSQLHandle *handle)
if (SQLITE_DONE != result) { if (SQLITE_DONE != result) {
// DStoreStmtError(handle, stmt); // DStoreStmtError(handle, stmt);
printf("Database commit error %d: %s\n", result, sqlite3_errmsg(stmt->stmt)); printf("Database commit error %d: %s\n", result, sqlite3_errmsg(handle->db));
return -1; return -1;
} }
return 0; return 0;
@@ -440,10 +440,8 @@ MsgSQLResultInt64(MsgSQLStatement *_stmt, int column)
int int
MsgSQLResultText(MsgSQLStatement *_stmt, int column, char *result, size_t result_size) MsgSQLResultText(MsgSQLStatement *_stmt, int column, char *result, size_t result_size)
{ {
char *out; const char *out = sqlite3_column_text(_stmt->stmt, column);
DEBUG(" - result text %ld\n", _stmt->stmt) DEBUG(" - result text %ld\n", _stmt->stmt)
out = sqlite3_column_text(_stmt->stmt, column);
if (out != NULL) if (out != NULL)
strncpy(result, out, result_size); strncpy(result, out, result_size);
@@ -453,6 +451,10 @@ MsgSQLResultText(MsgSQLStatement *_stmt, int column, char *result, size_t result
int int
MsgSQLResultTextPtr(MsgSQLStatement *_stmt, int column, char **ptr) MsgSQLResultTextPtr(MsgSQLStatement *_stmt, int column, char **ptr)
{ {
*ptr = sqlite3_column_text(_stmt->stmt, column); *ptr = NULL;
char *result = sqlite3_column_text(_stmt->stmt, column);
if (result != NULL) *ptr = g_strdup(result);
return 0; return 0;
} }
+1 -1
View File
@@ -274,7 +274,7 @@ ReadBongoConfiguration(BongoConfigItem *config, char *filename) {
*/ */
BOOL BOOL
ProcessBongoConfiguration(BongoConfigItem *config, const BongoJsonNode *node) ProcessBongoConfiguration(BongoConfigItem *config, BongoJsonNode *node)
{ {
while (config->type != BONGO_JSON_NULL) { while (config->type != BONGO_JSON_NULL) {
BongoJsonNode *result = BongoJsonJPath(node, config->source); BongoJsonNode *result = BongoJsonJPath(node, config->source);
@@ -20,9 +20,8 @@ GArrayFindUnsorted(GArray *array, void *needle, ArrayCompareFunc compare)
return -1; return -1;
} }
/* TODO: the old function had a char *. should this be more generic somehow? */
int int
GArrayFindSorted(GArray *array, void *needle, ArrayCompareFunc compare) GArrayFindSorted(GArray *array, void *needle, ssize_t type_size, ArrayCompareFunc compare)
{ {
void *data; void *data;
@@ -30,10 +29,10 @@ GArrayFindSorted(GArray *array, void *needle, ArrayCompareFunc compare)
return -1; return -1;
} }
data = bsearch(needle, array->data, array->len, sizeof(char *), compare); data = bsearch(needle, array->data, array->len, type_size, compare);
if (data) { if (data) {
return ((char*)data - (char*)array->data) / sizeof(char *); return ((void *)data - (void *)array->data) / type_size;
} else { } else {
return -1; return -1;
} }