Compare commits
11 Commits
master
...
releng-0.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a5c310ad6 | |||
| 0339297cd1 | |||
| f81addc50e | |||
| c352aae824 | |||
| 51820ccde5 | |||
| 906368d5a9 | |||
| a1f3775418 | |||
| bf4ce71c5e | |||
| fca127c820 | |||
| 13a73ebb6e | |||
| a03597ae55 |
+20
-8
@@ -6,6 +6,11 @@ cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(VERSION 2.6)
|
||||
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 1)
|
||||
set(BONGO_V_STR "${BONGO_V_MAJOR}.${BONGO_V_MINOR}.${BONGO_V_BUILD}")
|
||||
|
||||
# arguments we can supply to the build system - TODO
|
||||
set(BONGO_USER "root" CACHE STRING "User account Bongo should run under")
|
||||
option(CONN_TRACE "Enable connection tracing" OFF)
|
||||
@@ -14,15 +19,15 @@ include(cmake/BongoCompiler.cmake)
|
||||
# find our various build requirements
|
||||
include(cmake/Requirements.cmake)
|
||||
|
||||
# set up defines for build directories
|
||||
include(cmake/Directories.cmake)
|
||||
include(cmake/DefineInstallationPaths.cmake)
|
||||
|
||||
# define RPATH for debug/etc. builds - allows us to install libraries
|
||||
# in non-system location and the binaries still link to them
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH "${XPL_DEFAULT_LIB_DIR}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# set up defines for build directories
|
||||
include(cmake/DefineInstallationPaths.cmake)
|
||||
include(cmake/Directories.cmake)
|
||||
|
||||
# any legacy defines which we want to get rid of eventually
|
||||
include(cmake/Legacy.cmake)
|
||||
|
||||
@@ -35,16 +40,23 @@ 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 connio bongoutil
|
||||
json cal nmap python/libbongo python/bongo)
|
||||
# DO NOT ALTER (SO)VERSION ON LIBRARIES WITHOUT ASKING!
|
||||
foreach (LIBRARY xpl streamio logging msgapi connio util json cal nmap)
|
||||
add_subdirectory (src/libs/${LIBRARY})
|
||||
set_target_properties(bongo${LIBRARY} PROPERTIES
|
||||
SOVERSION 0
|
||||
VERSION ${BONGO_V_STR}
|
||||
)
|
||||
endforeach (LIBRARY)
|
||||
|
||||
add_subdirectory(src/libs/python/libbongo)
|
||||
add_subdirectory(src/libs/python/bongo)
|
||||
|
||||
foreach (AGENT antispam avirus imap pop queue rules smtp store)
|
||||
add_subdirectory (src/agents/${AGENT})
|
||||
endforeach (AGENT)
|
||||
|
||||
foreach (EXECUTABLE config manager testtool queuetool storetool)
|
||||
foreach (EXECUTABLE config manager testtool queuetool storetool sendmail backup)
|
||||
add_subdirectory (src/apps/${EXECUTABLE})
|
||||
endforeach (EXECUTABLE)
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ if (DEBUG)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -g3 -ggdb -O0" PARENT_SCOPE)
|
||||
endif (DEBUG)
|
||||
|
||||
option(STRICTCOMPILE "Enable strict compilation rules" ON)
|
||||
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)
|
||||
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)
|
||||
if (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)
|
||||
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)
|
||||
|
||||
@@ -54,7 +54,7 @@ if (UNIX)
|
||||
CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
|
||||
)
|
||||
SET(LIB_INSTALL_DIR
|
||||
"${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
|
||||
"${EXEC_INSTALL_PREFIX}/${LIB_DIR_NAME}"
|
||||
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/lib)"
|
||||
)
|
||||
SET(LIBEXEC_INSTALL_DIR
|
||||
|
||||
+11
-2
@@ -1,9 +1,18 @@
|
||||
# various directory definitions we use throughout Bongo
|
||||
|
||||
if(EXISTS /lib64)
|
||||
set(_LIB_DIR_NAME lib64)
|
||||
else(EXISTS /lib64)
|
||||
set(_LIB_DIR_NAME lib)
|
||||
endif(EXISTS /lib64)
|
||||
|
||||
set(LIB_DIR_NAME ${_LIB_DIR_NAME} CACHE PATH
|
||||
"Name of library location (arch-specific), usually 'lib' or 'lib64'")
|
||||
|
||||
# 'default' locations for where objects get built
|
||||
set(BINDIR ${PROJECT_BINARY_DIR}/bin)
|
||||
set(SBINDIR ${PROJECT_BINARY_DIR}/sbin)
|
||||
set(LIBDIR ${LIBRARY_OUTPUT_PATH})
|
||||
set(LIBDIR ${PROJECT_BINARY_DIR}/${LIB_DIR_NAME})
|
||||
set(LIBEXECDIR ${PROJECT_BINARY_DIR}/libexec)
|
||||
set(DATAROOTDIR ${PROJECT_BINARY_DIR}/share)
|
||||
set(DATADIR ${PROJECT_BINARY_DIR}/share)
|
||||
@@ -15,7 +24,7 @@ set(XPL_DEFAULT_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/bongo)
|
||||
set(XPL_DEFAULT_STATE_DIR ${CMAKE_INSTALL_PREFIX}/var/bongo)
|
||||
|
||||
set(XPL_DEFAULT_BIN_DIR ${CMAKE_INSTALL_PREFIX}/sbin)
|
||||
set(XPL_DEFAULT_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set(XPL_DEFAULT_LIB_DIR ${CMAKE_INSTALL_PREFIX}/${LIB_DIR_NAME})
|
||||
set(XPL_DEFAULT_CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc/bongo)
|
||||
set(XPL_DEFAULT_NLS_DIR ${CMAKE_INSTALL_PREFIX}/share/bongo/nls)
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mail and calendering made simple")
|
||||
set(CPACK_PACKAGE_VENDOR "Bongo Project")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "1")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${BONGO_V_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${BONGO_V_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${BONGO_V_BUILD}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/* The username which bongo runs as. */
|
||||
#cmakedefine BONGO_USER "root"
|
||||
#cmakedefine BONGO_USER "@BONGO_USER@"
|
||||
|
||||
// our package name
|
||||
#cmakedefine PACKAGE "@CMAKE_PROJECT_NAME@"
|
||||
|
||||
@@ -96,7 +96,7 @@ typedef struct _BongoConfigItem {
|
||||
} BongoConfigItem;
|
||||
|
||||
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);
|
||||
void FreeBongoConfiguration(BongoConfigItem *config);
|
||||
|
||||
|
||||
+1
-1
@@ -356,7 +356,7 @@ int BongoListVoidToInt (void * ptr);
|
||||
typedef int (*ArrayCompareFunc)(const void *, const void *);
|
||||
|
||||
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
|
||||
typedef struct _BongoArray BongoArray;
|
||||
|
||||
+2
-1
@@ -209,9 +209,10 @@ EXPORT BOOL MsgFindUserNmap(const unsigned char *user, unsigned char *nmap, int
|
||||
EXPORT unsigned long MsgGetHostIPAddress(void);
|
||||
EXPORT unsigned long MsgGetAgentBindIPAddress(void);
|
||||
|
||||
EXPORT const char *MsgGetUnprivilegedUser(void);
|
||||
EXPORT const char *MsgGetUnprivilegedUser(void);
|
||||
|
||||
EXPORT void MsgMakePath(char *path);
|
||||
EXPORT void MsgMakePathChown(char *path, int uid, int gid);
|
||||
EXPORT BOOL MsgCleanPath(char *path);
|
||||
|
||||
EXPORT BOOL MsgResolveStart();
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: bongo
|
||||
# Required-Start: $network
|
||||
# Required-Start: $network $remote_fs
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Description: Bongo collaboration system, visit: http://www.bongo-project.com
|
||||
# Short-Description: Start and stops Bongo
|
||||
# Description: Bongo collaboration system, for info visit: http://www.bongo-project.com
|
||||
### END INIT INFO
|
||||
|
||||
# Source SuSE config
|
||||
@@ -28,6 +29,8 @@ BONGO_NAME=bongo-manager
|
||||
BONGO_CONFIG=bongo-config
|
||||
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
|
||||
|
||||
echo $BONGO_BIN/$BONGO_NAME
|
||||
test -x $BONGO_BIN/$BONGO_NAME || exit 5
|
||||
|
||||
# Shell functions sourced from /etc/rc.status:
|
||||
@@ -77,7 +80,7 @@ case "$1" in
|
||||
# Remember status and be verbose
|
||||
rc_status -v
|
||||
;;
|
||||
restart)
|
||||
reload|restart)
|
||||
## Stop the service and regardless of whether it was
|
||||
## running or not, start it again.
|
||||
$0 stop
|
||||
@@ -92,7 +95,7 @@ case "$1" in
|
||||
rc_status -v
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|restart}"
|
||||
echo "Usage: $0 {start|stop|status|restart|reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -347,7 +347,7 @@ SpamdReadConfiguration(SpamdConfig *spamd)
|
||||
char *hostitem = g_array_index(ASpam.spamd.hostlist, char*, i);
|
||||
char *lHost = MemStrdup(hostitem);
|
||||
char *host;
|
||||
int port, weight;
|
||||
int port=SPAMD_DEFAULT_PORT, weight=SPAMD_DEFAULT_WEIGHT;
|
||||
ParseHost(lHost, &host, &port, &weight);
|
||||
ConnAddressPoolAddHost(&ASpam.spamd.hosts, host, port, weight);
|
||||
MemFree(lHost);
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <logger.h>
|
||||
|
||||
#include "avirus.h"
|
||||
#define AVIRUS_DEFAULT_PORT 3310
|
||||
#define AVIRUS_DEFAULT_WEIGHT 1
|
||||
|
||||
static void SignalHandler(int sigtype);
|
||||
|
||||
@@ -423,7 +425,7 @@ ReadConfiguration(void) {
|
||||
char *hostitem = g_array_index(AVirus.clamd.hostlist, char*, i);
|
||||
char *lHost = MemStrdup(hostitem);
|
||||
char *host;
|
||||
int port, weight;
|
||||
int port=AVIRUS_DEFAULT_PORT, weight=AVIRUS_DEFAULT_WEIGHT;
|
||||
ParseHost(lHost, &host, &port, &weight);
|
||||
ConnAddressPoolAddHost(&AVirus.clamd.hosts, host, port, weight);
|
||||
MemFree(lHost);
|
||||
|
||||
@@ -464,6 +464,8 @@ ConnectUserToNMAPServer(POP3Client *client, unsigned char *username, unsigned ch
|
||||
XplSafeIncrement(POP3.stats.badPasswords);
|
||||
Log(LOG_NOTICE, "Incorrect password for user %s from host %s", username,
|
||||
LOGIP(client->conn->socketAddress));
|
||||
/* the use was not found. Error, don't continue */
|
||||
return(POP3_NMAP_USER_UNKNOWN);
|
||||
}
|
||||
|
||||
MsgAuthGetUserStore(username, &nmap);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "queued.h"
|
||||
#include "conf.h"
|
||||
#include "queue.h"
|
||||
|
||||
@@ -203,7 +204,7 @@ ReadConfiguration (BOOL *recover)
|
||||
|
||||
unsigned int x;
|
||||
for(x=0;x<Conf.domains->len;x++) {
|
||||
unsigned char *aconfig;
|
||||
char *aconfig;
|
||||
unsigned char path[100];
|
||||
BongoJsonNode *node;
|
||||
struct _AliasStruct a;
|
||||
|
||||
@@ -228,7 +228,7 @@ SendMimeDetails(Connection *conn, MIMEReportStruct *report)
|
||||
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> */
|
||||
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].subtype,
|
||||
part[i].charset,
|
||||
@@ -241,7 +241,7 @@ SendMimeDetails(Connection *conn, MIMEReportStruct *report)
|
||||
part[i + 1].start - part[i].start,
|
||||
part[i].lines);
|
||||
} 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].subtype,
|
||||
part[i].charset,
|
||||
@@ -253,7 +253,7 @@ SendMimeDetails(Connection *conn, MIMEReportStruct *report)
|
||||
part[i].length,
|
||||
part[i].lines);
|
||||
} 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].subtype,
|
||||
part[i].charset,
|
||||
|
||||
@@ -313,7 +313,7 @@ AddPushAgent(QueueClient *client,
|
||||
|
||||
/* first look through the list to find the right 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) {
|
||||
/* there is no queue item in the array yet. we need to initialize one */
|
||||
CurrentQueue = MemNew0(QueueList, 1);
|
||||
@@ -326,7 +326,7 @@ AddPushAgent(QueueClient *client,
|
||||
|
||||
/* CurrentQueue should be set now */
|
||||
strncpy(tempPool.identifier, identifier, 100);
|
||||
ItemIndex = GArrayFindSorted(CurrentQueue->pools, &p_tempPool, FindPool);
|
||||
ItemIndex = GArrayFindSorted(CurrentQueue->pools, &p_tempPool, sizeof(QueuePoolList *), FindPool);
|
||||
if (ItemIndex < 0) {
|
||||
/* there is no pool already. we need to initialize one */
|
||||
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 */
|
||||
tempQueue.queue = queue;
|
||||
ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue);
|
||||
ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, sizeof(QueueList *), FindQueue);
|
||||
if (ItemIndex >= 0) {
|
||||
QueueList *CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
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: {
|
||||
if (Conf.quotaMessage && (Conf.quotaMessage[0] != '\0')) {
|
||||
fprintf(rtsData, Conf.quotaMessage);
|
||||
fprintf(rtsData, "%s", Conf.quotaMessage);
|
||||
} else {
|
||||
fprintf(rtsData, DEFAULT_QUOTA_MESSAGE);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
i = GArrayFindSorted(Conf.aliasList, domain, (ArrayCompareFunc)aliasFindFunc);
|
||||
i = GArrayFindSorted(Conf.aliasList, domain, sizeof(struct _AliasStruct), (ArrayCompareFunc)aliasFindFunc);
|
||||
if (i > -1) {
|
||||
char new_addr[1000]; /* FIXME: seems a bit large */
|
||||
AliasStruct a;
|
||||
@@ -167,7 +167,7 @@ BOOL aliasing(char *addr, int *cnt, unsigned char *buffer) {
|
||||
a = g_array_index(Conf.aliasList, AliasStruct, i);
|
||||
|
||||
/* 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;
|
||||
b = g_array_index(a.aliases, AliasStruct, i);
|
||||
result = aliasing(b.to, cnt, buffer);
|
||||
@@ -242,7 +242,7 @@ int CommandAddressResolve(void *param) {
|
||||
unsigned char buffer[1024]; /* FIXME: is this too big? */
|
||||
QueueClient *client = (QueueClient *)param;
|
||||
|
||||
handled = aliasing(client->buffer + 16, &cnt, &buffer);
|
||||
handled = aliasing(client->buffer + 16, &cnt, buffer);
|
||||
if (!handled) {
|
||||
ConnWriteF(client->conn, MSG4001NO_USER"\r\n", client->buffer + 16);
|
||||
} else {
|
||||
@@ -253,10 +253,11 @@ int CommandAddressResolve(void *param) {
|
||||
|
||||
int CommandDomainLocation(void *param) {
|
||||
QueueClient *client = (QueueClient *)param;
|
||||
|
||||
// FIXME: is this actually used at all with our current aliasing stuff?
|
||||
/* first find the domain in the request */
|
||||
unsigned char *domain = client->buffer + 16;
|
||||
|
||||
|
||||
#if 0
|
||||
/* now search for it */
|
||||
int idx = GArrayFindSorted(Conf.hostedDomains, domain, (ArrayCompareFunc)hostedFindFunc);
|
||||
if (idx > -1) {
|
||||
@@ -265,6 +266,8 @@ int CommandDomainLocation(void *param) {
|
||||
/* TODO: add the relay domain stuff */
|
||||
ConnWriteF(client->conn, MSG1002REMOTE"\r\n", domain);
|
||||
}
|
||||
#endif
|
||||
ConnWriteF(client->conn, MSG1000LOCAL"\r\n", domain);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -428,7 +431,7 @@ CheckTrustedHost(QueueClient *client)
|
||||
if (Conf.trustedHosts) {
|
||||
/* TODO: this can be optimized a little bit */
|
||||
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);
|
||||
}
|
||||
return (i > -1);
|
||||
|
||||
@@ -3969,7 +3969,7 @@ ReadConfiguration (void)
|
||||
|
||||
LocalAddress = MsgGetHostIPAddress ();
|
||||
|
||||
MsgGetServerCredential(&NMAPHash);
|
||||
MsgGetServerCredential(NMAPHash);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ StoreSetupCommands()
|
||||
BongoHashtablePutNoReplace(CommandTable, "COOKIE", (void *) STORE_COMMAND_COOKIE) ||
|
||||
BongoHashtablePutNoReplace(CommandTable, "QUIT", (void *) STORE_COMMAND_QUIT) ||
|
||||
BongoHashtablePutNoReplace(CommandTable, "STORE", (void *) STORE_COMMAND_STORE) ||
|
||||
BongoHashtablePutNoReplace(CommandTable, "STORES", (void *) STORE_COMMAND_STORES) ||
|
||||
BongoHashtablePutNoReplace(CommandTable, "TOKEN", (void *) STORE_COMMAND_TOKEN) ||
|
||||
BongoHashtablePutNoReplace(CommandTable, "TOKENS", (void *) STORE_COMMAND_TOKENS) ||
|
||||
BongoHashtablePutNoReplace(CommandTable, "USER", (void *) STORE_COMMAND_USER) ||
|
||||
@@ -1133,7 +1134,13 @@ StoreCommandLoop(StoreClient *client)
|
||||
/* SHUTDOWN */
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
||||
case STORE_COMMAND_STORES:
|
||||
if (TOKEN_OK == (ccode = RequireIdentity(client))) {
|
||||
ccode = StoreCommandSTORES(client);
|
||||
}
|
||||
break;
|
||||
|
||||
case STORE_COMMAND_STORE:
|
||||
/* STORE [<storename>] */
|
||||
|
||||
@@ -2119,7 +2126,7 @@ StoreCommandLIST(StoreClient *client,
|
||||
int ccode;
|
||||
|
||||
ccode = StoreObjectCheckAuthorization(client, collection, STORE_PRIV_LIST);
|
||||
if (ccode) return ccode;
|
||||
if (ccode) return ConnWriteStr(client->conn, MSG4240NOPERMISSION);
|
||||
|
||||
return StoreObjectIterCollectionContents(client, collection, start,
|
||||
end, flagsmask, flags, props, propcount, NULL, NULL, FALSE);
|
||||
@@ -2698,6 +2705,23 @@ StoreCommandRESET(StoreClient *client)
|
||||
return ConnWriteStr(client->conn, MSG1000OK);
|
||||
}
|
||||
|
||||
CCode
|
||||
StoreCommandSTORES(StoreClient *client)
|
||||
{
|
||||
char **userlist;
|
||||
int result;
|
||||
|
||||
result = MsgAuthUserList(&userlist);
|
||||
if (result) {
|
||||
int i;
|
||||
|
||||
for (i = 0; userlist[i] != 0; i++) {
|
||||
ConnWriteF(client->conn, "2001 %s\r\n", userlist[i]);
|
||||
}
|
||||
MsgAuthUserListFree(&userlist);
|
||||
}
|
||||
return ConnWriteStr(client->conn, MSG1000OK);
|
||||
}
|
||||
|
||||
CCode
|
||||
StoreCommandSTORE(StoreClient *client, char *user)
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef enum {
|
||||
STORE_COMMAND_IDENTITY,
|
||||
STORE_COMMAND_MANAGE,
|
||||
STORE_COMMAND_QUIT,
|
||||
STORE_COMMAND_STORES,
|
||||
STORE_COMMAND_STORE,
|
||||
STORE_COMMAND_TOKEN,
|
||||
STORE_COMMAND_TOKENS,
|
||||
@@ -239,6 +240,8 @@ CCode StoreCommandRESET(StoreClient *client);
|
||||
|
||||
CCode StoreCommandSEARCH(StoreClient *client, uint64_t guid, StoreSearchInfo *query);
|
||||
|
||||
CCode StoreCommandSTORES(StoreClient *client);
|
||||
|
||||
CCode StoreCommandSTORE(StoreClient *client, char *user);
|
||||
|
||||
CCode StoreCommandTIMEOUT(StoreClient *client, int timeout);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
.section ".note.GNU-stack","",%progbits
|
||||
.section ".rodata"
|
||||
.globl sql_create_store
|
||||
.type sql_create_store,@object
|
||||
|
||||
@@ -105,6 +105,7 @@ StoreObjectDBCreate(StoreClient *client)
|
||||
StoreObjectCreate(client, &collection);
|
||||
|
||||
collection.guid = STORE_CALENDARS_PERSONAL_GUID;
|
||||
collection.collection_guid = STORE_CALENDARS_GUID;
|
||||
snprintf(collection.filename, MAX_FILE_NAME, "/calendars/personal");
|
||||
StoreObjectCreate(client, &collection);
|
||||
|
||||
|
||||
@@ -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})
|
||||
@@ -1455,11 +1455,6 @@ main(int argc, char *argv[])
|
||||
BongoBackup.backup_date = time(NULL);
|
||||
BongoBackup.verbose = 0;
|
||||
|
||||
if (!MemoryManagerOpen("Bongo Backup")) {
|
||||
XplConsolePrintf(_("Failed to initialize memory manager\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* parse options */
|
||||
while (++next_arg < argc && argv[next_arg][0] == '-') {
|
||||
if ((arg_ptr = strchr(argv[next_arg], '=')) != '\0') {
|
||||
@@ -1539,7 +1534,7 @@ main(int argc, char *argv[])
|
||||
/* backup */
|
||||
XplConsolePrintf(_("Backing up data\n"));
|
||||
|
||||
if (ConnStartup((300), FALSE)) {
|
||||
if (ConnStartup((300))) {
|
||||
if ((nmap = GetConnection(NULL))) {
|
||||
if (next_backup_arg < 1) {
|
||||
/* full backup */
|
||||
@@ -1594,7 +1589,7 @@ main(int argc, char *argv[])
|
||||
/* restore */
|
||||
XplConsolePrintf(_("Restoring data\n"));
|
||||
|
||||
if (ConnStartup((300), FALSE)) {
|
||||
if (ConnStartup((300))) {
|
||||
if (next_backup_arg < 1) {
|
||||
/* full restore */
|
||||
if ((store_dir = opendir(BongoBackup.store_path))) {
|
||||
@@ -1642,9 +1637,8 @@ main(int argc, char *argv[])
|
||||
XplConsolePrintf(_("Search command not implemented\n"));
|
||||
} else {
|
||||
/* help */
|
||||
XplConsolePrintf(usage);
|
||||
XplConsolePrintf("%s", usage);
|
||||
}
|
||||
|
||||
MemoryManagerClose("Bongo Backup");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -179,8 +179,7 @@ InitializeDataArea(void)
|
||||
for (dir = MSGAPI_DIR_START; dir < MSGAPI_DIR_END; dir++) {
|
||||
char path[XPL_MAX_PATH];
|
||||
if (MsgGetDir(dir, path, XPL_MAX_PATH)) {
|
||||
MsgMakePath(path);
|
||||
chown(path, uid, gid);
|
||||
MsgMakePathChown(path, uid, gid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *
|
||||
char command[1024];
|
||||
|
||||
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);
|
||||
while (ccode == 2001)
|
||||
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);
|
||||
}
|
||||
|
||||
NMAPSendCommandF(client->conn, command);
|
||||
NMAPSendCommandF(client->conn, "%s", command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
|
||||
if (ccode == 2002) {
|
||||
@@ -151,7 +151,7 @@ BOOL
|
||||
NMAPSimpleCommand(StoreClient *client, char *command) {
|
||||
CCode ccode;
|
||||
|
||||
NMAPSendCommandF(client->conn, command);
|
||||
NMAPSendCommandF(client->conn, "%s", command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
if (1000 == ccode)
|
||||
return TRUE;
|
||||
|
||||
@@ -302,7 +302,7 @@ StartAgentsWithPriority(int priority, BOOL onlyCrashed, BOOL printMessage)
|
||||
static BOOL
|
||||
LoadAgentConfiguration()
|
||||
{
|
||||
unsigned char *config;
|
||||
char *config;
|
||||
BOOL retcode = FALSE;
|
||||
BongoJsonNode *node;
|
||||
BongoJsonResult res;
|
||||
|
||||
@@ -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})
|
||||
@@ -76,11 +76,7 @@ main (int argc, char *argv[])
|
||||
char command[200];
|
||||
int i;
|
||||
|
||||
if (! MemoryManagerOpen("BongoSendmail")) {
|
||||
FatalError(1, "unable to initialise memory manager.");
|
||||
}
|
||||
|
||||
ConnStartup((15*60), TRUE);
|
||||
ConnStartup((15*60));
|
||||
|
||||
MsgInit();
|
||||
NMAPInitialize();
|
||||
@@ -177,7 +173,6 @@ main (int argc, char *argv[])
|
||||
|
||||
NMAPQuit(nmap);
|
||||
CONN_TRACE_SHUTDOWN();
|
||||
MemoryManagerClose("BongoSendmail");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ BongoCalObjectGetInstance(BongoCalObject *cal, const char *uid, BongoCalTime rec
|
||||
data.uid = uid;
|
||||
data.recurid = recurid;
|
||||
|
||||
i = GArrayFindSorted(cal->instances, &data, FindInstanceById);
|
||||
i = GArrayFindSorted(cal->instances, &data, sizeof(BongoCalInstance *), FindInstanceById);
|
||||
if (i != -1) {
|
||||
return g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
} else {
|
||||
|
||||
@@ -76,9 +76,6 @@ __gnutls_new(Connection *conn, bongo_ssl_context *context, gnutls_connection_end
|
||||
|
||||
/* store in the credetials loaded earler */
|
||||
ccode = gnutls_credentials_set(conn->ssl.context, GNUTLS_CRD_CERTIFICATE, context->cert_cred);
|
||||
|
||||
/* initialize the dh bits */
|
||||
gnutls_dh_set_prime_bits(conn->ssl.context, 1024);
|
||||
} else {
|
||||
const int cert_type_priority[4] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
|
||||
|
||||
@@ -93,6 +90,9 @@ __gnutls_new(Connection *conn, bongo_ssl_context *context, gnutls_connection_end
|
||||
|
||||
/* set the empty credentials in the session */
|
||||
gnutls_credentials_set (conn->ssl.context, GNUTLS_CRD_CERTIFICATE, conn->ssl.credentials);
|
||||
|
||||
/* require at least 512 dh bits */
|
||||
gnutls_dh_set_prime_bits(conn->ssl.context, 512);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -447,11 +447,15 @@ ConnNegotiate(Connection *conn, bongo_ssl_context *context)
|
||||
CONN_TRACE_EVENT(c, CONN_TRACE_EVENT_SSL_CONNECT);
|
||||
return(TRUE);
|
||||
}
|
||||
gnutls_deinit(c->ssl.context);
|
||||
gnutls_certificate_free_credentials(c->ssl.credentials);
|
||||
if (c->ssl.context) {
|
||||
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.context = NULL;
|
||||
c->ssl.credentials = NULL;
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
|
||||
@@ -44,7 +44,7 @@ MsgAuthCreateCookie(const char *username, MsgAuthCookie *cookie, uint64_t timeou
|
||||
xpl_hash_context context;
|
||||
|
||||
// create the cookie
|
||||
cookie->expiration = timeout;
|
||||
cookie->expiration = time(NULL) + timeout;
|
||||
|
||||
XplHashNew(&context, XPLHASH_MD5);
|
||||
snprintf(cookie->token, sizeof(cookie->token), "%x%x",
|
||||
@@ -158,7 +158,7 @@ MsgAuthDeleteCookie(const char *username, const char *token)
|
||||
|
||||
// next, clear the existing file
|
||||
rewind(cookiefile);
|
||||
ftruncate((int)cookiefile, 0);
|
||||
ftruncate(fileno(cookiefile), 0);
|
||||
|
||||
// now, go through memory writing out only the cookies we want to keep
|
||||
for (i = 0; i < cookiecount; i++) {
|
||||
|
||||
+35
-21
@@ -210,30 +210,44 @@ MsgCleanPath(char *path)
|
||||
EXPORT void
|
||||
MsgMakePath(char *path)
|
||||
{
|
||||
char *ptr = path;
|
||||
char *ptr2;
|
||||
struct stat sb;
|
||||
return MsgMakePathChown(path, -1, -1);
|
||||
}
|
||||
|
||||
ptr = strchr(path, '/');
|
||||
if (!ptr)
|
||||
ptr=strchr(path, '\\');
|
||||
EXPORT void
|
||||
MsgMakePathChown(char *path, int uid, int gid)
|
||||
{
|
||||
char *ptr = path;
|
||||
char *ptr2;
|
||||
struct stat sb;
|
||||
|
||||
while (ptr) {
|
||||
*ptr = '\0';
|
||||
if (stat(path, &sb) != 0) {
|
||||
XplMakeDir(path);
|
||||
}
|
||||
ptr = strchr(path, '/');
|
||||
if (!ptr)
|
||||
ptr=strchr(path, '\\');
|
||||
|
||||
*ptr = '/';
|
||||
ptr2 = ptr;
|
||||
ptr = strchr(ptr2 + 1, '/');
|
||||
if (!ptr)
|
||||
ptr = strchr(ptr2 + 1, '\\');
|
||||
}
|
||||
|
||||
if (stat(path, &sb) != 0) {
|
||||
XplMakeDir(path);
|
||||
}
|
||||
while (ptr) {
|
||||
*ptr = '\0';
|
||||
if (stat(path, &sb) != 0) {
|
||||
XplMakeDir(path);
|
||||
if ((uid != -1) && (gid != -1)) {
|
||||
// TODO: this assumes success. Usually we
|
||||
// ought to be root when calling this, so...
|
||||
chown(path, uid, gid);
|
||||
}
|
||||
}
|
||||
|
||||
*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 *
|
||||
|
||||
@@ -180,7 +180,7 @@ MsgSQLBeginTransaction(MsgSQLHandle *handle)
|
||||
case SQLITE_BUSY:
|
||||
return -2;
|
||||
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);
|
||||
return -1;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ MsgSQLCommitTransaction(MsgSQLHandle *handle)
|
||||
|
||||
if (SQLITE_DONE != result) {
|
||||
// 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 0;
|
||||
@@ -440,10 +440,8 @@ MsgSQLResultInt64(MsgSQLStatement *_stmt, int column)
|
||||
int
|
||||
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)
|
||||
out = sqlite3_column_text(_stmt->stmt, column);
|
||||
if (out != NULL)
|
||||
strncpy(result, out, result_size);
|
||||
|
||||
@@ -453,6 +451,10 @@ MsgSQLResultText(MsgSQLStatement *_stmt, int column, char *result, size_t result
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ ReadBongoConfiguration(BongoConfigItem *config, char *filename) {
|
||||
*/
|
||||
|
||||
BOOL
|
||||
ProcessBongoConfiguration(BongoConfigItem *config, const BongoJsonNode *node)
|
||||
ProcessBongoConfiguration(BongoConfigItem *config, BongoJsonNode *node)
|
||||
{
|
||||
while (config->type != BONGO_JSON_NULL) {
|
||||
BongoJsonNode *result = BongoJsonJPath(node, config->source);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <msgapi.h>
|
||||
#include <nmap.h>
|
||||
#include <bongostore.h>
|
||||
#include <logger.h>
|
||||
|
||||
struct {
|
||||
RegistrationStates state;
|
||||
@@ -1264,18 +1265,18 @@ NMAPReadConfigFile(const char *file, char **output)
|
||||
XplDelay(1000);
|
||||
}
|
||||
if (!conn) {
|
||||
printf("could not connect to store\n");
|
||||
Log(LOG_WARN, "could not connect to store\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!NMAPAuthenticate(conn, buffer, sizeof(buffer))) {
|
||||
printf("could not authenticate to the store\n");
|
||||
Log(LOG_WARN, "could not authenticate to the store\n");
|
||||
goto nmapfinish;
|
||||
}
|
||||
|
||||
NMAPSendCommandF(conn, "STORE _system\r\n");
|
||||
ccode = NMAPReadAnswer(conn, buffer, sizeof(buffer), TRUE);
|
||||
if (ccode != 1000) {
|
||||
printf("cannot access _system collection\n");
|
||||
Log(LOG_WARN, "cannot access _system collection\n");
|
||||
goto nmapfinish;
|
||||
}
|
||||
|
||||
@@ -1284,7 +1285,7 @@ NMAPReadConfigFile(const char *file, char **output)
|
||||
|
||||
ccode = NMAPReadPropertyValueLength(conn, "nmap.document", &count);
|
||||
if (ccode != 2001) {
|
||||
printf("couldn't load config from store\n");
|
||||
Log(LOG_INFO, "couldn't load config from store: /config/%s\n", file);
|
||||
goto nmapfinish;
|
||||
}
|
||||
|
||||
@@ -1292,7 +1293,7 @@ NMAPReadConfigFile(const char *file, char **output)
|
||||
written = NMAPReadCount(conn, *output, count);
|
||||
NMAPReadCrLf(conn);
|
||||
if (written != count) {
|
||||
printf("couldn't read config from store\n");
|
||||
Log(LOG_INFO, "couldn't read config from store: /config/%s\n", file);
|
||||
goto nmapfinish;
|
||||
}
|
||||
if (count == 0) {
|
||||
|
||||
@@ -20,9 +20,8 @@ GArrayFindUnsorted(GArray *array, void *needle, ArrayCompareFunc compare)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: the old function had a char *. should this be more generic somehow? */
|
||||
int
|
||||
GArrayFindSorted(GArray *array, void *needle, ArrayCompareFunc compare)
|
||||
GArrayFindSorted(GArray *array, void *needle, ssize_t type_size, ArrayCompareFunc compare)
|
||||
{
|
||||
void *data;
|
||||
|
||||
@@ -30,10 +29,10 @@ GArrayFindSorted(GArray *array, void *needle, ArrayCompareFunc compare)
|
||||
return -1;
|
||||
}
|
||||
|
||||
data = bsearch(needle, array->data, array->len, sizeof(char *), compare);
|
||||
data = bsearch(needle, array->data, array->len, type_size, compare);
|
||||
|
||||
if (data) {
|
||||
return ((char*)data - (char*)array->data) / sizeof(char *);
|
||||
return ((void *)data - (void *)array->data) / type_size;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user