Small patch to remove mdb from the build
This commit is contained in:
+7
-6
@@ -90,6 +90,10 @@ clean: clean-recursive
|
||||
# src/agents/mailprox
|
||||
# src/agents/rules
|
||||
|
||||
# src/libs/mdb
|
||||
# src/libs/mdb-file
|
||||
# src/libs/mdb-xldap
|
||||
|
||||
include_subdirs := \
|
||||
include \
|
||||
src/libs/xpl \
|
||||
@@ -100,9 +104,6 @@ include_subdirs := \
|
||||
src/libs/connio \
|
||||
src/libs/connio/tests \
|
||||
src/libs/json \
|
||||
src/libs/mdb \
|
||||
src/libs/mdb-file \
|
||||
src/libs/mdb-xldap \
|
||||
src/libs/logger \
|
||||
src/libs/streamio \
|
||||
src/libs/streamio/codec \
|
||||
@@ -156,9 +157,9 @@ include src/libs/bongoutil/tests/Bongo.rules
|
||||
include src/libs/connio/Bongo.rules
|
||||
include src/libs/connio/tests/Bongo.rules
|
||||
include src/libs/json/Bongo.rules
|
||||
include src/libs/mdb/Bongo.rules
|
||||
include src/libs/mdb-file/Bongo.rules
|
||||
include src/libs/mdb-xldap/Bongo.rules
|
||||
#include src/libs/mdb/Bongo.rules
|
||||
#include src/libs/mdb-file/Bongo.rules
|
||||
#include src/libs/mdb-xldap/Bongo.rules
|
||||
include src/libs/logger/Bongo.rules
|
||||
include src/libs/streamio/Bongo.rules
|
||||
include src/libs/streamio/codec/Bongo.rules
|
||||
|
||||
+4
-3
@@ -629,6 +629,10 @@ ac_configure_args="$ac_configure_args --enable-threadsafe --enable-cross-thread-
|
||||
# src/agents/mailprox/Makefile
|
||||
# src/agents/rules/Makefile
|
||||
|
||||
#src/libs/mdb/Makefile
|
||||
#src/libs/mdb-file/Makefile
|
||||
#src/libs/mdb-xldap/Makefile
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
bongo.pc
|
||||
@@ -677,9 +681,6 @@ src/libs/json/Makefile
|
||||
src/libs/streamio/Makefile
|
||||
src/libs/streamio/codec/Makefile
|
||||
src/libs/logger/Makefile
|
||||
src/libs/mdb/Makefile
|
||||
src/libs/mdb-file/Makefile
|
||||
src/libs/mdb-xldap/Makefile
|
||||
src/libs/memmgr/Makefile
|
||||
src/libs/msgapi/Makefile
|
||||
src/libs/nmap/Makefile
|
||||
|
||||
+1
-1
@@ -517,7 +517,7 @@ typedef struct _MSGCacheInitStruct {
|
||||
typedef BOOL (*FindObjectCacheInitType)(MSGCacheInitStruct *initData, unsigned char *description);
|
||||
typedef BOOL (*FindObjectCacheShutdownType)(void);
|
||||
|
||||
EXPORT MDBHandle MsgInit(void);
|
||||
EXPORT void MsgInit(void);
|
||||
EXPORT BOOL MsgShutdown(void);
|
||||
EXPORT MDBHandle MsgGetSystemDirectoryHandle(void);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ bongoalarm_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongocal.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -9,7 +9,6 @@ bongoantispam_SOURCES := \
|
||||
bongoantispam_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -871,13 +871,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
|
||||
ConnStartup(CONNECTION_TIMEOUT, TRUE);
|
||||
|
||||
if (MsgInit() == NULL) {
|
||||
XplConsolePrintf("bongoantispam: Invalid directory credentials; exiting!\r\n");
|
||||
|
||||
MemoryManagerClose(MSGSRV_AGENT_ANTISPAM);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
MsgInit();
|
||||
NMAPInitialize();
|
||||
|
||||
SetCurrentNameSpace(NWOS2_NAME_SPACE);
|
||||
|
||||
@@ -11,7 +11,6 @@ bongoavirus_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongostreamio.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <logger.h>
|
||||
#include <bongoagent.h>
|
||||
#include <bongoutil.h>
|
||||
#include <mdb.h>
|
||||
#include <nmap.h>
|
||||
#include <nmlib.h>
|
||||
#include <msgapi.h>
|
||||
@@ -799,6 +798,7 @@ ProcessConnection(AVClient *client)
|
||||
}
|
||||
|
||||
#if 0
|
||||
// REMOVE-MDB
|
||||
// FIXME! What is this code actually doing?
|
||||
if (!MsgFindObject(cur + 1, client->dn, NULL, NULL, client->uservs)) {
|
||||
MDBFreeValues(client->uservs);
|
||||
@@ -1398,14 +1398,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
|
||||
ConnStartup(CONNECTION_TIMEOUT, TRUE);
|
||||
|
||||
if (MsgInit() == NULL) {
|
||||
XplConsolePrintf("antivirus: Invalid directory credentials; exiting!\r\n");
|
||||
|
||||
MemoryManagerClose(MSGSRV_AGENT_ANTIVIRUS);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
MsgInit();
|
||||
StreamioInit();
|
||||
NMAPInitialize();
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ bongocalcmd_SOURCES := \
|
||||
bongocalcmd_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -12,7 +12,6 @@ bongocollector_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongocal.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -8,7 +8,6 @@ bongogeneric_SOURCES := \
|
||||
bongogeneric_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -21,7 +21,6 @@ bongoimap_SOURCES := \
|
||||
bongoimap_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -3795,14 +3795,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
|
||||
ConnStartup(IMAP_CONNECTION_TIMEOUT, TRUE);
|
||||
|
||||
if (MsgInit() == NULL) {
|
||||
XplConsolePrintf("\rIMAPD: Invalid directory credentials; exiting!\n");
|
||||
|
||||
MemoryManagerClose(MSGSRV_AGENT_IMAP);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
MsgInit();
|
||||
NMAPInitialize();
|
||||
|
||||
Imap.logHandle = LoggerOpen("bongoimap");
|
||||
|
||||
@@ -8,7 +8,6 @@ bongoitip_SOURCES := \
|
||||
bongoitip_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -10,7 +10,6 @@ bongomailprox_SOURCES := \
|
||||
bongomailprox_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -8,7 +8,6 @@ bongopluspack_SOURCES := \
|
||||
bongopluspack_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -8,7 +8,6 @@ bongopop3_SOURCES := \
|
||||
bongopop3_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -2128,13 +2128,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
|
||||
ConnStartup(CONNECTION_TIMEOUT, TRUE);
|
||||
|
||||
if (MsgInit() == NULL) {
|
||||
XplConsolePrintf("\rPOP3D: Invalid directory credentials; exiting!\n");
|
||||
|
||||
MemoryManagerClose(MSGSRV_AGENT_POP);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
MsgInit();
|
||||
NMAPInitialize();
|
||||
|
||||
POP3.loggingHandle = LoggerOpen("bongopop3");
|
||||
|
||||
+29
-21
@@ -661,7 +661,7 @@ ProcessQueueEntry(unsigned char *entryIn)
|
||||
FILE *data = NULL;
|
||||
FILE *newFH = NULL;
|
||||
MIMEReportStruct *report = NULL;
|
||||
MDBValueStruct *vs;
|
||||
// REMOVE-MDB MDBValueStruct *vs;
|
||||
QueueClient *client;
|
||||
void *handle;
|
||||
|
||||
@@ -860,7 +860,7 @@ StartOver:
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
vs = MDBCreateValueStruct(Agent.agent.directoryHandle, NULL);
|
||||
// REMOVE-MDB vs = MDBCreateValueStruct(Agent.agent.directoryHandle, NULL);
|
||||
|
||||
count = 0;
|
||||
cur = qEnvelope;
|
||||
@@ -891,6 +891,8 @@ StartOver:
|
||||
*ptr2 = '\0';
|
||||
}
|
||||
|
||||
// REMOVE-MDB
|
||||
#if 0
|
||||
/* this adds lines to the envelope for each user -- expanding a group if needed */
|
||||
if (MsgFindObject(cur + 1, NULL, NULL, NULL, vs)) {
|
||||
if (ptr2) {
|
||||
@@ -908,6 +910,7 @@ StartOver:
|
||||
MDBFreeValues(vs);
|
||||
/* end of envelope rewrite section */
|
||||
} else {
|
||||
#endif
|
||||
Log(LOG_INFO, "Entry %ld queue %d, can't find %s", entryID, queue, cur + 1);
|
||||
|
||||
if (ptr2) {
|
||||
@@ -919,7 +922,7 @@ StartOver:
|
||||
}
|
||||
|
||||
fwrite(cur, sizeof(unsigned char), next - cur, newFH);
|
||||
}
|
||||
// REMOVE-MDB }
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -961,7 +964,7 @@ StartOver:
|
||||
cur = next;
|
||||
}
|
||||
|
||||
MDBDestroyValueStruct(vs);
|
||||
// REMOVE-MDB MDBDestroyValueStruct(vs);
|
||||
|
||||
MemFree(qEnvelope);
|
||||
|
||||
@@ -1154,18 +1157,21 @@ StartOver:
|
||||
*ptr = ' ';
|
||||
}
|
||||
|
||||
// REMOVE-MDB
|
||||
#if 0
|
||||
vs = MDBCreateValueStruct(Agent.agent.directoryHandle, NULL);
|
||||
if (!MsgFindObject(recipient, NULL, NULL, &siaddr, vs)) {
|
||||
Log(LOG_WARNING, "User %s unknown, entry %ld", recipient, entryID);
|
||||
status = DELIVER_USER_UNKNOWN;
|
||||
} else {
|
||||
#endif
|
||||
Log(LOG_DEBUG, "Delivering %s on queue %d to %s", entry, queue, line+1);
|
||||
status = DeliverToStore(&list, &siaddr, NMAP_DOCTYPE_CAL, sender, authenticatedSender, dataFilename, data, dSize, recipient, mailbox, flags);
|
||||
if (Agent.agent.state == BONGO_AGENT_STATE_STOPPING) {
|
||||
status = DELIVER_TRY_LATER;
|
||||
}
|
||||
}
|
||||
MDBDestroyValueStruct(vs);
|
||||
// REMOVE-MDB }
|
||||
// MDBDestroyValueStruct(vs);
|
||||
|
||||
/* Restore our buffer */
|
||||
if (ptr2) {
|
||||
@@ -1260,6 +1266,8 @@ StartOver:
|
||||
}
|
||||
|
||||
/* Attempt delivery, check if local or remote */
|
||||
// REMOVE-MDB
|
||||
#if 0
|
||||
vs = MDBCreateValueStruct(Agent.agent.directoryHandle, NULL);
|
||||
if (MsgFindObject(recipient, NULL, NULL, &siaddr, vs)) {
|
||||
Log(LOG_DEBUG, "Deliver to store entry %s in queue %d for host %s", entry, queue, LOGIP(siaddr));
|
||||
@@ -1269,6 +1277,7 @@ StartOver:
|
||||
status = DELIVER_TRY_LATER;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
status = DELIVER_USER_UNKNOWN;
|
||||
|
||||
/* This will forward the message to a remote domain */
|
||||
@@ -1298,9 +1307,9 @@ StartOver:
|
||||
|
||||
XplRWReadLockRelease(&Conf.lock);
|
||||
}
|
||||
}
|
||||
// REMOVE-MDB }
|
||||
|
||||
MDBDestroyValueStruct(vs);
|
||||
// REMOVE-MDB MDBDestroyValueStruct(vs);
|
||||
|
||||
if (status < DELIVER_SUCCESS) {
|
||||
Log(LOG_WARNING, "Couldn't deliver entry %s on queue %d, status %d", entry, queue, status);
|
||||
@@ -2003,7 +2012,6 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO
|
||||
unsigned char *transcript;
|
||||
unsigned char timeLine[80];
|
||||
unsigned char line[CONN_BUFSIZE + 1];
|
||||
unsigned char dn[MDB_MAX_OBJECT_CHARS + 1];
|
||||
unsigned char postmaster[MAXEMAILNAMESIZE + 1];
|
||||
unsigned char sender[MAXEMAILNAMESIZE + 1];
|
||||
unsigned char aSender[MAXEMAILNAMESIZE + 1] = "";
|
||||
@@ -2013,7 +2021,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO
|
||||
BOOL mBounce=FALSE;
|
||||
BOOL header;
|
||||
time_t now;
|
||||
MDBValueStruct *vs;
|
||||
// REMOVE-MDB MDBValueStruct *vs;
|
||||
|
||||
/* Step 0, check if we want to bounce at all */
|
||||
now = time(NULL);
|
||||
@@ -2090,6 +2098,9 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO
|
||||
handling = Conf.bounceHandling;
|
||||
|
||||
/* We're guaranteed to have a recipient */
|
||||
|
||||
// REMOVE-MDB
|
||||
#if 0
|
||||
ptr = strchr(recipient, '@');
|
||||
if (ptr) {
|
||||
if (MsgDomainExists(ptr + 1, dn)) {
|
||||
@@ -2122,6 +2133,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO
|
||||
MDBDestroyValueStruct(vs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Step 2, create the bounce; we've got all information */
|
||||
MsgGetRFC822Date(-1, 0, timeLine);
|
||||
@@ -2951,6 +2963,8 @@ CommandQaddm(void *param)
|
||||
if ((stat(client->path, &sb) == 0) && ((data = fopen(client->path, "rb")) != NULL)) {
|
||||
NMAPConnections list = { 0, };
|
||||
struct sockaddr_in saddr;
|
||||
// REMOVE-MDB
|
||||
#if 0
|
||||
MDBValueStruct *vs;
|
||||
|
||||
vs = MDBCreateValueStruct(Agent.agent.directoryHandle, NULL);
|
||||
@@ -2960,7 +2974,7 @@ CommandQaddm(void *param)
|
||||
EndStoreDelivery(&list);
|
||||
}
|
||||
MDBDestroyValueStruct(vs);
|
||||
|
||||
#endif
|
||||
} else {
|
||||
return(ConnWrite(client->conn, MSG4224CANTREAD, sizeof(MSG4224CANTREAD) - 1));
|
||||
}
|
||||
@@ -4233,20 +4247,18 @@ CommandQsrchDomain(void *param)
|
||||
unsigned long used;
|
||||
unsigned char *ptr;
|
||||
void *handle = NULL;
|
||||
MDBValueStruct *vs = NULL;
|
||||
QueueClient *client = (QueueClient *)param;
|
||||
|
||||
ptr = client->buffer + 12;
|
||||
|
||||
/* QSRCH DOMAIN <domain> */
|
||||
if ((*ptr++ == ' ') && (!isspace(*ptr))) {
|
||||
if (((vs = MDBCreateValueStruct(Agent.agent.directoryHandle, NULL)) != NULL)
|
||||
&& ((handle = QDBHandleAlloc()) != NULL)) {
|
||||
if ((handle = QDBHandleAlloc()) != NULL) {
|
||||
ccode = QDBSearchDomain(handle, ptr);
|
||||
if (!ccode) {
|
||||
for (used = 0; (ccode != -1) && (used < vs->Used); used++) {
|
||||
ccode = ConnWriteF(client->conn, "2001-007-%s\r\n", vs->Value[used]);
|
||||
}
|
||||
// REMOVE-MDB for (used = 0; (ccode != -1) && (used < vs->Used); used++) {
|
||||
// ccode = ConnWriteF(client->conn, "2001-007-%s\r\n", vs->Value[used]);
|
||||
//}
|
||||
|
||||
if (ccode != -1) {
|
||||
ccode = ConnWrite(client->conn, MSG1000OK, sizeof(MSG1000OK) - 1);
|
||||
@@ -4260,10 +4272,6 @@ CommandQsrchDomain(void *param)
|
||||
ccode = ConnWrite(client->conn, MSG5230NOMEMORYERR, sizeof(MSG5230NOMEMORYERR) - 1);
|
||||
}
|
||||
|
||||
if (vs) {
|
||||
MDBDestroyValueStruct(vs);
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
QDBHandleRelease(handle);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ bongorules_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongostreamio.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -8,7 +8,6 @@ bongosmtp_SOURCES := \
|
||||
bongosmtp_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
+4
-14
@@ -39,7 +39,6 @@
|
||||
|
||||
#include <logger.h>
|
||||
|
||||
#include <mdb.h>
|
||||
#include <nmap.h>
|
||||
|
||||
#include <bongoagent.h>
|
||||
@@ -214,8 +213,6 @@ typedef struct
|
||||
|
||||
void *SMTPConnectionPool = NULL;
|
||||
|
||||
MDBHandle SMTPDirectoryHandle = NULL;
|
||||
|
||||
/* Prototypes */
|
||||
long ReadConnection(Connection *conn, char **buffer, unsigned long *buflen);
|
||||
void ProcessRemoteEntry (ConnectionStruct * Client,
|
||||
@@ -840,6 +837,8 @@ HandleConnection (void *param)
|
||||
}
|
||||
else {
|
||||
XplRWReadLockRelease (&ConfigLock);
|
||||
#if 0
|
||||
// REMOVE-MDB
|
||||
if (MsgFindObject
|
||||
(To, NULL, NULL, NULL, NULL)) {
|
||||
snprintf (Answer, sizeof (Answer),
|
||||
@@ -851,11 +850,12 @@ HandleConnection (void *param)
|
||||
DSN_FLAGS));
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
ConnWrite (Client->client.conn,
|
||||
MSG550NOTFOUND,
|
||||
MSG550NOTFOUND_LEN);
|
||||
goto QuitRcpt;
|
||||
}
|
||||
// REMOVE-MDB }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4452,20 +4452,10 @@ int XplServiceMain (int argc, char *argv[])
|
||||
|
||||
ConnStartup (SMTP.socket_timeout, TRUE);
|
||||
|
||||
MDBInit ();
|
||||
if ((SMTPDirectoryHandle = (MDBHandle) MsgInit ()) == NULL) {
|
||||
Log(LOG_ERROR, "Invalid directory credentials, shutting down");
|
||||
|
||||
MemoryManagerClose (MSGSRV_AGENT_SMTP);
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
NMAPInitialize();
|
||||
|
||||
XplRWLockInit (&ConfigLock);
|
||||
|
||||
|
||||
for (ccode = 1; argc && (ccode < argc); ccode++) {
|
||||
if (XplStrNCaseCmp (argv[ccode], "--forwarder=", 12) == 0) {
|
||||
SMTP.use_relay = TRUE;
|
||||
|
||||
@@ -54,7 +54,6 @@ bongostore_LDADD = \
|
||||
libbongocal.la \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongostreamio.la \
|
||||
|
||||
@@ -240,12 +240,7 @@ _XplServiceMain(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (! StoreAgent.installMode) {
|
||||
if (MsgInit() == NULL) {
|
||||
XplConsolePrintf("NMAPD: Invalid directory credentials; exiting!\r\n");
|
||||
MemoryManagerClose(MSGSRV_AGENT_STORE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
MsgInit();
|
||||
cal_success = BongoCalInit(MsgGetDBFDir(NULL));
|
||||
} else {
|
||||
cal_success = BongoCalInit(XPL_DEFAULT_DBF_DIR);
|
||||
|
||||
@@ -10,7 +10,6 @@ checktest_store_CPPFLAGS := $(AM_CPPFLAGS) \
|
||||
checktest_store_LDADD := $(CHECK_LIBS) \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
@@ -32,7 +31,6 @@ mkauthhash_store_CPPFLAGS := $(AM_CPPFLAGS) \
|
||||
mkauthhash_LDADD = \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -11,7 +11,6 @@ bongo_backup_CPPFLAGS := $(AM_CPPFLAGS) \
|
||||
bongo_backup_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -11,8 +11,9 @@ conf_defaults = \
|
||||
|
||||
bongo_config_SOURCES := \
|
||||
$(conf_defaults) \
|
||||
src/apps/config/config.c \
|
||||
src/apps/config/config.h \
|
||||
src/apps/config/config.c
|
||||
src/apps/config/store.c
|
||||
|
||||
bongo_config_CPPFLAGS := $(AM_CPPFLAGS) \
|
||||
$(GNUTLS_CFLAGS)
|
||||
|
||||
+34
-158
@@ -14,7 +14,6 @@
|
||||
#include <gnutls/x509.h>
|
||||
#include <gcrypt.h>
|
||||
#include <time.h>
|
||||
#include <tar.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include "config.h"
|
||||
@@ -45,165 +44,27 @@ usage(void) {
|
||||
}
|
||||
|
||||
void
|
||||
RunAsBongoUser() {
|
||||
if (XplSetRealUser(MsgGetUnprivilegedUser()) < 0) {
|
||||
printf(_("bongo-config: Could not drop to unpriviliged user '%s'\n"), MsgGetUnprivilegedUser());
|
||||
RunAsBongoUser()
|
||||
{
|
||||
if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) {
|
||||
printf(_("bongo-config: Could not drop to unprivileged user '%s'\n"), MsgGetUnprivilegedUser());
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
NMAPSimpleCommand(StoreClient *client, char *command) {
|
||||
CCode ccode;
|
||||
|
||||
NMAPSendCommandF(client->conn, command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
if (1000 == ccode)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
SetAdminRights(StoreClient *client, char *document) {
|
||||
CCode ccode;
|
||||
char *rights = "grant user:admin all;";
|
||||
|
||||
ccode = NMAPRunCommandF(client->conn, client->buffer, sizeof(client->buffer),
|
||||
"PROPSET %s nmap.access-control %d\r\n", document, strlen(rights));
|
||||
if (ccode == 2002) {
|
||||
NMAPSendCommandF(client->conn, rights);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer,
|
||||
sizeof(client->buffer), TRUE);
|
||||
if (ccode == 1000)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *content, long len) {
|
||||
CCode ccode;
|
||||
char command[1024];
|
||||
|
||||
snprintf(command, 1000, "INFO %s/%s\r\n", collection, filename);
|
||||
ccode = NMAPSendCommandF(client->conn, command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
while (ccode == 2001)
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
|
||||
if (ccode == 1000) {
|
||||
// INFO returned OK, document already exists
|
||||
snprintf(command, 1000, "REPLACE %s/%s %ld\r\n",
|
||||
collection, filename, len);
|
||||
} else {
|
||||
// INFO errored, so document doesn't exist
|
||||
snprintf(command, 1000, "WRITE %s %d %ld \"F%s\"\r\n",
|
||||
collection, STORE_DOCTYPE_CONFIG, len, filename);
|
||||
}
|
||||
|
||||
NMAPSendCommandF(client->conn, command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
|
||||
if (ccode == 2002) {
|
||||
ConnWrite(client->conn, content, len);
|
||||
ConnFlush(client->conn);
|
||||
if (NMAPReadAnswer(client->conn, client->buffer,
|
||||
sizeof(client->buffer), TRUE) == 1000) {
|
||||
return TRUE;
|
||||
}
|
||||
XplConsolePrintf(_("ERROR: Couldn't write data\n"));
|
||||
} else {
|
||||
XplConsolePrintf(_("ERROR: Wouldn't accept data\n"));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
ImportSystemBackupFile(StoreClient *client, const char *path)
|
||||
void
|
||||
RunAsRoot()
|
||||
{
|
||||
FILE *config;
|
||||
char header[513];
|
||||
CCode result;
|
||||
|
||||
config = fopen(path, "r");
|
||||
if (config == NULL) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't load default config set\n"));
|
||||
return FALSE;
|
||||
if (XplSetEffectiveUserId(0) < 0) {
|
||||
XplConsolePrintf(_("bongo-config: Couldn't get back root privs.\n"));
|
||||
}
|
||||
while(512 == fread(&header, sizeof(char), 512, config)) {
|
||||
long filesize, blocksize, read;
|
||||
size_t len;
|
||||
char str_filesize[13], filename[101];
|
||||
char *file;
|
||||
header[512] = 0;
|
||||
|
||||
memcpy(&filename, &header, 100);
|
||||
filename[100] = 0;
|
||||
memcpy(&str_filesize, &header[124], 12);
|
||||
str_filesize[12] = 0;
|
||||
filesize = strtol(str_filesize, NULL, 8);
|
||||
len = strlen(filename);
|
||||
|
||||
if (! strncmp(filename, "", 100)) {
|
||||
// end of tar is _two_ empty blocks... ah well :o>
|
||||
break;
|
||||
}
|
||||
|
||||
blocksize = filesize / 512;
|
||||
if (filesize % 512) blocksize++;
|
||||
blocksize *= 512;
|
||||
}
|
||||
|
||||
/* if this is a directory we need to create a new collection */
|
||||
if (filename[len-1] == '/') {
|
||||
char currentpath[110];
|
||||
char fullpath[110];
|
||||
|
||||
filename[len-1] = 0;
|
||||
|
||||
snprintf(currentpath, 100, "/%s", filename);
|
||||
snprintf(fullpath, 108, "CREATE %s\r\n", currentpath);
|
||||
result = NMAPSimpleCommand(client, fullpath);
|
||||
|
||||
if ((result==1000) || (result==4226)) {
|
||||
// collection can't be created and doesn't exist
|
||||
XplConsolePrintf(_("ERROR: Couldn't create collection: %s\n"), currentpath);
|
||||
return FALSE;
|
||||
}
|
||||
if (! SetAdminRights(client, currentpath)) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't set acls on %s\n"), currentpath);
|
||||
return FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blocksize > 0 && !strncmp(filename, "config/", 7)) {
|
||||
char fullpath[110];
|
||||
char *delim;
|
||||
|
||||
file = MemMalloc((size_t) blocksize);
|
||||
read = fread(file, sizeof(char), blocksize, config);
|
||||
if (read != blocksize) {
|
||||
XplConsolePrintf(" Read error!");
|
||||
}
|
||||
|
||||
delim = strrchr(filename, '/');
|
||||
*delim = 0;
|
||||
snprintf(fullpath, 108, "/%s", filename);
|
||||
if (!PutOrReplaceConfig(client, fullpath,
|
||||
delim+1, file, filesize)) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't write\n"));
|
||||
} else {
|
||||
if (! SetAdminRights(client, fullpath)) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't set rights on store file\n"));
|
||||
}
|
||||
}
|
||||
MemFree(file);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(config);
|
||||
return TRUE;
|
||||
void
|
||||
CreateSystemDir(const char *path)
|
||||
{
|
||||
XplMakeDir(path);
|
||||
// TODO: chown(path,
|
||||
}
|
||||
|
||||
void
|
||||
@@ -214,13 +75,15 @@ InitializeDataArea(void)
|
||||
XplConsolePrintf(_("ERROR: Couldn't create user database\n"));
|
||||
exit(1);
|
||||
}
|
||||
CreateSystemDir(XPL_DEFAULT_CONF_DIR);
|
||||
CreateSystemDir(XPL_DEFAULT_STATE_DIR);
|
||||
CreateSystemDir(XPL_DEFAULT_CACHE_DIR);
|
||||
CreateSystemDir(XPL_DEFAULT_DBF_DIR);
|
||||
CreateSystemDir(XPL_DEFAULT_WORK_DIR);
|
||||
}
|
||||
|
||||
void
|
||||
InitialStoreConfiguration(void) {
|
||||
char path[XPL_MAX_PATH];
|
||||
int store_pid;
|
||||
char *args[3];
|
||||
BOOL cal_success;
|
||||
|
||||
// attempt to initialise cal lib. This creates cached data, and can be time
|
||||
@@ -232,7 +95,17 @@ InitialStoreConfiguration(void) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XplConsolePrintf(_("Initializing store...\n"));
|
||||
XplConsolePrintf(_("Loading initial store configuration...\n"));
|
||||
LoadDefaultStoreConfiguration();
|
||||
}
|
||||
|
||||
void
|
||||
LoadDefaultStoreConfiguration(void)
|
||||
{
|
||||
char path[XPL_MAX_PATH];
|
||||
int store_pid;
|
||||
char *args[3];
|
||||
|
||||
store_pid = fork();
|
||||
if (store_pid == 0) { // child
|
||||
static char *install = "--install";
|
||||
@@ -584,7 +457,7 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// unusual libgcrypt options must occur before XplInit()
|
||||
if (command == 2) {
|
||||
if ((command == 2) || (command == 1)) {
|
||||
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
|
||||
}
|
||||
XplInit();
|
||||
@@ -601,7 +474,10 @@ main(int argc, char *argv[]) {
|
||||
next_arg++;
|
||||
switch(command) {
|
||||
case 1:
|
||||
RunAsBongoUser();
|
||||
GenerateCryptoData();
|
||||
InitializeDataArea();
|
||||
RunAsRoot();
|
||||
InitialStoreConfiguration();
|
||||
break;
|
||||
case 2:
|
||||
|
||||
@@ -24,13 +24,11 @@ typedef struct {
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
BOOL ImportSystemBackupFile(StoreClient *client, const char *path);
|
||||
// config.c
|
||||
void LoadDefaultStoreConfiguration(void);
|
||||
void InitializeDataArea(void);
|
||||
void usage(void);
|
||||
void RunAsBongoUser(void);
|
||||
BOOL NMAPSimpleCommand(StoreClient *client, char *command);
|
||||
BOOL SetAdminRights(StoreClient *client, char *document);
|
||||
BOOL PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *content, long len);
|
||||
void InitialStoreConfiguration(void);
|
||||
void GetInteractiveData(char *description, char **data, char *def);
|
||||
BOOL GenerateCryptoData(void);
|
||||
@@ -38,6 +36,12 @@ void CheckVersion(void);
|
||||
void AddUser(const char *username);
|
||||
void TzCache(void);
|
||||
|
||||
// store.c
|
||||
BOOL ImportSystemBackupFile(StoreClient *client, const char *path);
|
||||
BOOL NMAPSimpleCommand(StoreClient *client, char *command);
|
||||
BOOL SetAdminRights(StoreClient *client, char *document);
|
||||
BOOL PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *content, long len);
|
||||
|
||||
/* compat with older gnutls */
|
||||
#ifndef GNUTLS_DIG_SHA1
|
||||
// older GNUTLS
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
{ "name": "bongoantispam", "pri": 5, "enabled": true },
|
||||
{ "name": "bongoavirus", "pri": 5, "enabled": true },
|
||||
{ "name": "bongocollector", "pri": 7, "enabled": true },
|
||||
{ "name": "bongomailprox", "pri": 7, "enabled": true },
|
||||
{ "name": "bongopluspack", "pri": 5, "enabled": true },
|
||||
{ "name": "bongorules", "pri": 2, "enabled": true },
|
||||
{ "name": "bongomailprox", "pri": 7, "enabled": false },
|
||||
{ "name": "bongopluspack", "pri": 5, "enabled": false },
|
||||
{ "name": "bongorules", "pri": 2, "enabled": false },
|
||||
{ "name": "bongoimap", "pri": 10, "enabled": true },
|
||||
{ "name": "bongopop3", "pri": 10, "enabled": true },
|
||||
{ "name": "bongocalcmd", "pri": 7, "enabled": true }
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
// Load / save backup sets from the Store
|
||||
|
||||
#include <xpl.h>
|
||||
#include <stdio.h>
|
||||
#include <nmlib.h>
|
||||
#include <msgapi.h>
|
||||
#include <bongostore.h>
|
||||
#include "config.h"
|
||||
|
||||
#include <libintl.h>
|
||||
#define _(x) gettext(x)
|
||||
|
||||
BOOL
|
||||
ImportSystemBackupFile(StoreClient *client, const char *path)
|
||||
{
|
||||
FILE *config;
|
||||
char header[513];
|
||||
CCode result;
|
||||
|
||||
config = fopen(path, "r");
|
||||
if (config == NULL) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't load default config set\n"));
|
||||
return FALSE;
|
||||
}
|
||||
while(512 == fread(&header, sizeof(char), 512, config)) {
|
||||
long filesize, blocksize, read;
|
||||
size_t len;
|
||||
char str_filesize[13], filename[101];
|
||||
char *file;
|
||||
header[512] = 0;
|
||||
|
||||
memcpy(&filename, &header, 100);
|
||||
filename[100] = 0;
|
||||
memcpy(&str_filesize, &header[124], 12);
|
||||
str_filesize[12] = 0;
|
||||
filesize = strtol(str_filesize, NULL, 8);
|
||||
len = strlen(filename);
|
||||
|
||||
if (! strncmp(filename, "", 100)) {
|
||||
// end of tar is _two_ empty blocks... ah well :o>
|
||||
break;
|
||||
}
|
||||
|
||||
blocksize = filesize / 512;
|
||||
if (filesize % 512) blocksize++;
|
||||
blocksize *= 512;
|
||||
|
||||
/* if this is a directory we need to create a new collection */
|
||||
if (filename[len-1] == '/') {
|
||||
char currentpath[110];
|
||||
char fullpath[110];
|
||||
|
||||
filename[len-1] = 0;
|
||||
|
||||
snprintf(currentpath, 100, "/%s", filename);
|
||||
snprintf(fullpath, 108, "CREATE %s\r\n", currentpath);
|
||||
result = NMAPSimpleCommand(client, fullpath);
|
||||
|
||||
if ((result==1000) || (result==4226)) {
|
||||
// collection can't be created and doesn't exist
|
||||
XplConsolePrintf(_("ERROR: Couldn't create collection: %s\n"), currentpath);
|
||||
return FALSE;
|
||||
}
|
||||
if (! SetAdminRights(client, currentpath)) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't set acls on %s\n"), currentpath);
|
||||
return FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (blocksize > 0 && !strncmp(filename, "config/", 7)) {
|
||||
char fullpath[110];
|
||||
char *delim;
|
||||
|
||||
file = MemMalloc((size_t) blocksize);
|
||||
read = fread(file, sizeof(char), blocksize, config);
|
||||
if (read != blocksize) {
|
||||
XplConsolePrintf(" Read error!");
|
||||
}
|
||||
|
||||
delim = strrchr(filename, '/');
|
||||
*delim = 0;
|
||||
snprintf(fullpath, 108, "/%s", filename);
|
||||
if (!PutOrReplaceConfig(client, fullpath,
|
||||
delim+1, file, filesize)) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't write %s to store\n"), fullpath);
|
||||
} else {
|
||||
if (! SetAdminRights(client, fullpath)) {
|
||||
XplConsolePrintf(_("ERROR: Couldn't set rights on store file %s\n"), fullpath);
|
||||
}
|
||||
}
|
||||
MemFree(file);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(config);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
SetAdminRights(StoreClient *client, char *document) {
|
||||
CCode ccode;
|
||||
char *rights = "grant user:admin all;";
|
||||
|
||||
ccode = NMAPRunCommandF(client->conn, client->buffer, sizeof(client->buffer),
|
||||
"PROPSET %s nmap.access-control %d\r\n", document, strlen(rights));
|
||||
if (ccode == 2002) {
|
||||
NMAPSendCommandF(client->conn, rights);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer,
|
||||
sizeof(client->buffer), TRUE);
|
||||
if (ccode == 1000)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
PutOrReplaceConfig(StoreClient *client, char *collection, char *filename, char *content, long len) {
|
||||
CCode ccode;
|
||||
char command[1024];
|
||||
|
||||
snprintf(command, 1000, "INFO %s/%s\r\n", collection, filename);
|
||||
ccode = NMAPSendCommandF(client->conn, command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
while (ccode == 2001)
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
|
||||
if (ccode == 1000) {
|
||||
// INFO returned OK, document already exists
|
||||
snprintf(command, 1000, "REPLACE %s/%s %ld\r\n",
|
||||
collection, filename, len);
|
||||
} else {
|
||||
// INFO errored, so document doesn't exist
|
||||
snprintf(command, 1000, "WRITE %s %d %ld \"F%s\"\r\n",
|
||||
collection, STORE_DOCTYPE_CONFIG, len, filename);
|
||||
}
|
||||
|
||||
NMAPSendCommandF(client->conn, command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
|
||||
if (ccode == 2002) {
|
||||
ConnWrite(client->conn, content, len);
|
||||
ConnFlush(client->conn);
|
||||
if (NMAPReadAnswer(client->conn, client->buffer,
|
||||
sizeof(client->buffer), TRUE) == 1000) {
|
||||
return TRUE;
|
||||
}
|
||||
XplConsolePrintf(_("ERROR: Couldn't write data\n"));
|
||||
} else {
|
||||
XplConsolePrintf(_("ERROR: Wouldn't accept data\n"));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
NMAPSimpleCommand(StoreClient *client, char *command) {
|
||||
CCode ccode;
|
||||
|
||||
NMAPSendCommandF(client->conn, command);
|
||||
ccode = NMAPReadAnswer(client->conn, client->buffer, sizeof(client->buffer), TRUE);
|
||||
if (1000 == ccode)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ bongo_manager_SOURCES := \
|
||||
bongo_manager_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
libbongo-json.la \
|
||||
|
||||
@@ -879,15 +879,8 @@ get_lock:
|
||||
}
|
||||
ConnStartup(DEFAULT_CONNECTION_TIMEOUT, TRUE);
|
||||
|
||||
if (!MsgGetConfigProperty(ServerDN, MSGSRV_CONFIG_PROP_MESSAGING_SERVER)) {
|
||||
fprintf(stderr, _("bongo-manager: Couldn't read the server DN from bongo.conf.\n"));
|
||||
goto err_handler;
|
||||
}
|
||||
|
||||
if (MsgGetConfigProperty((unsigned char *) buf,
|
||||
(unsigned char *) MSGSRV_CONFIG_PROP_MANAGED_SLAPD)) {
|
||||
startLdap = atoi(buf);
|
||||
}
|
||||
// set startLdap here if we want to start a managed slapd instance
|
||||
// startLdap = atoi(buf);
|
||||
|
||||
if (startLdap) {
|
||||
int err;
|
||||
@@ -904,22 +897,8 @@ get_lock:
|
||||
}
|
||||
|
||||
if (!slapdOnly) {
|
||||
if (!MDBInit()) {
|
||||
fprintf(stderr, _("bongo-manager: unable to intialize directory access.\n"));
|
||||
goto err_handler;
|
||||
}
|
||||
|
||||
if (!MsgInit()) {
|
||||
fprintf(stderr, _("bongo-manager: unable to MsgInit()\n"));
|
||||
goto err_handler;
|
||||
}
|
||||
MsgInit();
|
||||
NMAPInitialize();
|
||||
|
||||
DirectoryHandle = MsgGetSystemDirectoryHandle();
|
||||
if (DirectoryHandle == NULL) {
|
||||
fprintf(stderr, _("bongo-manager: unable to initialize messaging library.\n"));
|
||||
goto err_handler;
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGTERM, SignalHandler);
|
||||
|
||||
@@ -8,7 +8,6 @@ bongo_sendmail_SOURCES := \
|
||||
bongo_sendmail_LDADD := \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -83,12 +83,7 @@ main (int argc, char *argv[])
|
||||
|
||||
ConnStartup((15*60), TRUE);
|
||||
|
||||
if (! MDBInit()) {
|
||||
FatalError(1, "couldn't access MDB.");
|
||||
}
|
||||
if (! MsgInit()) {
|
||||
FatalError(1, "invalid directory credentials.");
|
||||
}
|
||||
MsgInit();
|
||||
NMAPInitialize();
|
||||
CONN_TRACE_INIT((char *)MsgGetWorkDir(NULL), "sendmail");
|
||||
// CONN_TRACE_SET_FLAGS(CONN_TRACE_ALL); /* uncomment this line and pass '--enable-conntrace' to autogen to get the agent to trace all connections */
|
||||
|
||||
@@ -16,7 +16,6 @@ parsecmd_SOURCES := src/libs/calcmd/test.c
|
||||
|
||||
parsecmd_LDADD := \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongoconnio.la \
|
||||
libbongomemmgr.la \
|
||||
|
||||
@@ -9,7 +9,6 @@ checktest_connio_LDADD := $(CHECK_LIBS) \
|
||||
libbongoconnio.la \
|
||||
libbongonmap.la \
|
||||
libbongomsgapi.la \
|
||||
libbongomdb.la \
|
||||
libbongologger.la \
|
||||
libbongomemmgr.la \
|
||||
libbongoutil.la \
|
||||
|
||||
@@ -22,7 +22,6 @@ libbongomsgapi_la_LIBADD := \
|
||||
libbongoutil.la \
|
||||
libbongo-json.la \
|
||||
libbongomemmgr.la \
|
||||
libbongomdb.la \
|
||||
libbongonmap.la \
|
||||
libbongoxpl.la \
|
||||
$(LIBCURL_LIBS) \
|
||||
|
||||
+5
-495
@@ -79,8 +79,6 @@ enum LibraryStates {
|
||||
struct {
|
||||
unsigned long flags;
|
||||
|
||||
MDBHandle directoryHandle;
|
||||
|
||||
XplThreadID groupID;
|
||||
|
||||
struct {
|
||||
@@ -89,29 +87,6 @@ struct {
|
||||
XplMutex uid;
|
||||
} sem;
|
||||
|
||||
struct {
|
||||
unsigned char dn[MDB_MAX_OBJECT_CHARS + 1];
|
||||
} server;
|
||||
|
||||
struct {
|
||||
MDBValueStruct *storePaths;
|
||||
MDBValueStruct *storeDNs;
|
||||
|
||||
struct {
|
||||
MDBValueStruct *names;
|
||||
MDBValueStruct *contexts;
|
||||
struct sockaddr_in *addr;
|
||||
} server;
|
||||
|
||||
#ifdef PARENTOBJECT_STORE
|
||||
struct {
|
||||
MDBValueStruct *objects;
|
||||
MDBValueStruct *stores;
|
||||
MDBValueSTruct *indices;
|
||||
} parent;
|
||||
#endif
|
||||
} vs;
|
||||
|
||||
unsigned long connManager;
|
||||
|
||||
XplRWLock configLock;
|
||||
@@ -187,172 +162,18 @@ MsgNmapChallenge(const unsigned char *response, unsigned char *reply, size_t len
|
||||
EXPORT const unsigned char *
|
||||
MsgGetServerDN(unsigned char *buffer)
|
||||
{
|
||||
if (buffer) {
|
||||
return(strcpy(buffer, MsgGlobal.server.dn));
|
||||
}
|
||||
return(MsgGlobal.server.dn);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgFindObject(const unsigned char *user, unsigned char *dn, unsigned char *userType, struct sockaddr_in *nmap, MDBValueStruct *v)
|
||||
{
|
||||
BOOL retVal = FALSE;
|
||||
|
||||
MDBValueStruct *userCtx;
|
||||
MDBValueStruct *types;
|
||||
unsigned long i, j;
|
||||
unsigned char rdn[MDB_MAX_OBJECT_CHARS + 1];
|
||||
|
||||
BOOL isUser = FALSE;
|
||||
BOOL isGroup = FALSE;
|
||||
BOOL isResource = FALSE;
|
||||
BOOL isOrgRole = FALSE;
|
||||
BOOL isDynGroup = FALSE;
|
||||
|
||||
/* FIXME: handle failure to create ValueStructs */
|
||||
userCtx = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
types = MDBShareContext(userCtx);
|
||||
|
||||
XplRWReadLockAcquire(&MsgGlobal.configLock);
|
||||
for (i = 0; i < MsgGlobal.vs.server.contexts->Used; i++) {
|
||||
MDBSetValueStructContext(MsgGlobal.vs.server.contexts->Value[i], userCtx);
|
||||
if (MDBGetObjectDetailsEx(user, types, rdn, dn, userCtx)) {
|
||||
|
||||
/* determine relevant types now so we don't have to loop
|
||||
throught the list everytime. */
|
||||
for (j = 0; j < types->Used; j++) {
|
||||
if (strcmp(types->Value[j], C_USER) == 0) {
|
||||
isUser = TRUE;
|
||||
} else if (strcmp(types->Value[j],
|
||||
MSGSRV_C_RESOURCE) == 0) {
|
||||
isResource = TRUE;
|
||||
} else if (strcmp(types->Value[j], MSGSRV_C_GROUP) == 0 ||
|
||||
strcmp(types->Value[j], C_GROUP) == 0) {
|
||||
isGroup = TRUE;
|
||||
} else if (strcmp(types->Value[j],
|
||||
MSGSRV_C_ORGANIZATIONAL_ROLE) == 0 ||
|
||||
strcmp(types->Value[j],
|
||||
C_ORGANIZATIONAL_ROLE) == 0) {
|
||||
isOrgRole = TRUE;
|
||||
} else if (strcmp(types->Value[j], "dynamicGroup") == 0) {
|
||||
isDynGroup = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (isUser || isResource) {
|
||||
if (v) {
|
||||
MDBAddValue(rdn, v);
|
||||
}
|
||||
if (nmap) {
|
||||
memcpy(nmap, &MsgGlobal.vs.server.addr[i], sizeof(struct sockaddr_in));
|
||||
}
|
||||
if (userType) {
|
||||
if (isUser) {
|
||||
strcpy(userType, C_USER);
|
||||
} else if (isResource) {
|
||||
strcpy(userType, MSGSRV_C_RESOURCE);
|
||||
}
|
||||
}
|
||||
retVal = TRUE;
|
||||
} else if (isGroup) {
|
||||
if (v) {
|
||||
MDBSetValueStructContext(MsgGlobal.vs.server.contexts->Value[i], v);
|
||||
MDBRead(user, A_MEMBER, v);
|
||||
|
||||
/* This removes any context from a group member's name */
|
||||
for (j = 0; j < v->Used; j++) {
|
||||
unsigned char *ptr;
|
||||
ptr = strrchr(v->Value[j], '\\');
|
||||
if (ptr) {
|
||||
memmove(v->Value[j], ptr + 1, strlen(ptr + 1) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (userType) {
|
||||
strcpy(userType, C_GROUP);
|
||||
}
|
||||
retVal = TRUE;
|
||||
} else if (isOrgRole) {
|
||||
if (v) {
|
||||
MDBSetValueStructContext(MsgGlobal.vs.server.contexts->Value[i], v);
|
||||
MDBRead(user, A_ROLE_OCCUPANT, v);
|
||||
|
||||
/* This removes any context from a the roles name */
|
||||
for (j = 0; j < v->Used; j++) {
|
||||
unsigned char *ptr;
|
||||
ptr = strrchr(v->Value[j], '\\');
|
||||
if (ptr) {
|
||||
memmove(v->Value[j], ptr + 1, strlen(ptr + 1) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (userType) {
|
||||
strcpy(userType, C_ORGANIZATIONAL_ROLE);
|
||||
}
|
||||
retVal = TRUE;
|
||||
} else if (isDynGroup) {
|
||||
if (v) {
|
||||
MDBSetValueStructContext(MsgGlobal.vs.server.contexts->Value[i], v);
|
||||
MDBRead(user, A_MEMBER, v);
|
||||
|
||||
/* This removes any context from a group member's name */
|
||||
for (j = 0; j < v->Used; j++) {
|
||||
unsigned char *ptr;
|
||||
ptr=strrchr(v->Value[j], '\\');
|
||||
if (ptr) {
|
||||
memmove(v->Value[j], ptr + 1, strlen(ptr + 1) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (userType) {
|
||||
strcpy(userType, "dynamicGroup");
|
||||
}
|
||||
retVal = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
|
||||
MDBDestroyValueStruct(userCtx);
|
||||
MDBDestroyValueStruct(types);
|
||||
|
||||
return(retVal);
|
||||
// DEPRECATED
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgDomainExists(const unsigned char *domain, unsigned char *domainObjectDN)
|
||||
{
|
||||
// DEPRECATED ?
|
||||
/* FIXME later; when we handle parent objects */
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use these functions to ensure that the correct MDB function is used
|
||||
* for strings or DNs.
|
||||
*/
|
||||
static BOOL
|
||||
MsgMdbWriteAny(const unsigned char *dn, const unsigned char *attribute,
|
||||
MDBValueStruct *v)
|
||||
{
|
||||
if (v->Used > 0 && strchr(v->Value[0], '\\')) {
|
||||
return MDBWriteDN(dn, attribute, v);
|
||||
}
|
||||
|
||||
return MDBWrite(dn, attribute, v);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
MsgMdbAddAny(const unsigned char *dn, const unsigned char *attribute,
|
||||
const unsigned char *value, MDBValueStruct *v)
|
||||
{
|
||||
if (v->Used > 0 && strchr(v->Value[0], '\\')) {
|
||||
return MDBAddDN(dn, attribute, value, v);
|
||||
}
|
||||
|
||||
return MDBAdd(dn, attribute, value, v);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgCleanPath(unsigned char *path)
|
||||
{
|
||||
@@ -515,178 +336,6 @@ MsgGetUnprivilegedUser(void)
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL
|
||||
LoadContextList(MDBValueStruct *config)
|
||||
{
|
||||
unsigned char emptyString[] = " ";
|
||||
unsigned char storeObjectDn[MDB_MAX_OBJECT_CHARS + 1];
|
||||
MDBValueStruct *ports;
|
||||
MDBValueStruct *addresses;
|
||||
char storePortText[6];
|
||||
unsigned long i;
|
||||
unsigned long j;
|
||||
unsigned long count;
|
||||
unsigned long realUsed;
|
||||
|
||||
ports = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
if (!ports) {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
addresses = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
if (!addresses) {
|
||||
MDBDestroyValueStruct(ports);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
MDBFreeValues(MsgGlobal.vs.server.names);
|
||||
MDBFreeValues(MsgGlobal.vs.server.contexts);
|
||||
MDBFreeValues(MsgGlobal.vs.storePaths);
|
||||
MDBFreeValues(MsgGlobal.vs.storeDNs);
|
||||
if (MsgGlobal.vs.server.addr) {
|
||||
MemFree(MsgGlobal.vs.server.addr);
|
||||
MsgGlobal.vs.server.addr = NULL;
|
||||
}
|
||||
|
||||
/* This puts the local context always first */
|
||||
sprintf(storeObjectDn, "%s\\%s", MsgGlobal.server.dn, MSGSRV_AGENT_STORE);
|
||||
if(MDBIsObject(storeObjectDn, MsgGlobal.vs.server.contexts)) {
|
||||
MDBReadDN(MsgGlobal.server.dn, MSGSRV_A_CONTEXT, MsgGlobal.vs.server.contexts);
|
||||
if (MDBRead(storeObjectDn, MSGSRV_A_PORT, config)) {
|
||||
strcpy(storePortText, config->Value[0]);
|
||||
MDBFreeValues(config);
|
||||
} else {
|
||||
sprintf(storePortText, "%d", (BONGO_STORE_DEFAULT_PORT));
|
||||
}
|
||||
for (i = 0; i < MsgGlobal.vs.server.contexts->Used; i++) {
|
||||
MDBRead(MsgGlobal.server.dn, MSGSRV_A_IP_ADDRESS, addresses);
|
||||
MDBAddValue(storePortText, ports);
|
||||
MDBAddValue(MsgGlobal.server.dn, MsgGlobal.vs.storeDNs);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PARENTOBJECT_STORE
|
||||
/* Read the parent object store configuration */
|
||||
if (MDBEnumerateObjects(MSGSRV_ROOT"\\"MSGSRV_PARENT_ROOT, MSGSRV_C_PARENTOBJECT, &MsgGlobal.vs.parent.objects)) {
|
||||
for (i=0; i<MsgGlobal.vs.parent.objects.Used; i++) {
|
||||
if (MDBRead(MsgGlobal.vs.parent.objects.Value[i], MSGSRV_A_MESSAGE_STORE, &MsgGlobal.vs.parent.stores)==0) {
|
||||
MDBAddValue(EmptyString, &MsgGlobal.vs.parent.stores);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FIXME: This code turns off distributed automatically if the server is not in internet services */
|
||||
/* We might not always want this? */
|
||||
#if 0
|
||||
if (strstr(storeObjectDn, MSGSRV_ROOT)==NULL) {
|
||||
MsgGlobal.flags |= MSGAPI_FLAG_STANDALONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(MsgGlobal.flags & MSGAPI_FLAG_STANDALONE)) {
|
||||
/* First time around we check all "real" classes */
|
||||
if (MDBEnumerateObjects(MSGSRV_ROOT, MSGSRV_C_SERVER, NULL, MsgGlobal.vs.server.names)) {
|
||||
/* Put the local context(s) first */
|
||||
for (i = 0; i < MsgGlobal.vs.server.names->Used; i++) {
|
||||
/* MsgGlobal.server.dn is absolute, MsgGlobal.vs.server.names->Value isn't */
|
||||
if (XplStrCaseCmp(MsgGlobal.server.dn + strlen(MsgGlobal.server.dn) - strlen(MsgGlobal.vs.server.names->Value[i]), MsgGlobal.vs.server.names->Value[i]) != 0) {
|
||||
count = MsgGlobal.vs.server.contexts->Used;
|
||||
if ((MDBRead(MsgGlobal.vs.server.names->Value[i], MSGSRV_A_IP_ADDRESS, addresses) > 0) &&
|
||||
(MDBReadDN(MsgGlobal.vs.server.names->Value[i], MSGSRV_A_CONTEXT, MsgGlobal.vs.server.contexts) > 0)) {
|
||||
sprintf(storeObjectDn, "%s\\%s", MsgGlobal.vs.server.names->Value[i], MSGSRV_AGENT_STORE);
|
||||
if (MDBRead(storeObjectDn, MSGSRV_A_PORT, config)) {
|
||||
strcpy(storePortText, config->Value[0]);
|
||||
MDBFreeValues(config);
|
||||
} else {
|
||||
sprintf(storePortText, "%d", (BONGO_STORE_DEFAULT_PORT));
|
||||
}
|
||||
MDBAddValue(MsgGlobal.vs.server.names->Value[i], MsgGlobal.vs.storeDNs);
|
||||
for (j = count + 1; j < MsgGlobal.vs.server.contexts->Used; j++) {
|
||||
MDBAddValue(addresses->Value[count], addresses);
|
||||
MDBAddValue(storePortText, ports);
|
||||
MDBAddValue(MsgGlobal.vs.server.names->Value[i], MsgGlobal.vs.storeDNs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now check any aliases that might be in the Internet Services container */
|
||||
realUsed = MsgGlobal.vs.server.names->Used;
|
||||
if (MDBEnumerateObjects(MSGSRV_ROOT, C_ALIAS, NULL, MsgGlobal.vs.server.names)) {
|
||||
unsigned char realDn[MDB_MAX_OBJECT_CHARS + 1];
|
||||
unsigned char realType[MDB_MAX_ATTRIBUTE_CHARS + 1];
|
||||
|
||||
/* Put the local context(s) first */
|
||||
for (i = realUsed; i < MsgGlobal.vs.server.names->Used; i++) {
|
||||
MDBGetObjectDetails(MsgGlobal.vs.server.names->Value[i], realType, NULL, realDn, MsgGlobal.vs.server.names);
|
||||
|
||||
/* MsgGlobal.server.dn is absolute, MsgGlobal.vs.server.names->Value isn't */
|
||||
if ((XplStrCaseCmp(realType, MSGSRV_C_SERVER) == 0) && (XplStrCaseCmp(MsgGlobal.server.dn + strlen(MsgGlobal.server.dn) - strlen(realDn), realDn) != 0)) {
|
||||
count = MsgGlobal.vs.server.contexts->Used;
|
||||
if ((MDBRead(MsgGlobal.vs.server.names->Value[i], MSGSRV_A_IP_ADDRESS, addresses) > 0) &&
|
||||
(MDBReadDN(MsgGlobal.vs.server.names->Value[i], MSGSRV_A_CONTEXT, MsgGlobal.vs.server.contexts) > 0)) {
|
||||
sprintf(storeObjectDn, "%s\\%s", MsgGlobal.vs.server.names->Value[i], MSGSRV_AGENT_STORE);
|
||||
if (MDBRead(storeObjectDn, MSGSRV_A_PORT, config)) {
|
||||
strcpy(storePortText, config->Value[0]);
|
||||
MDBFreeValues(config);
|
||||
} else {
|
||||
sprintf(storePortText, "%d", BONGO_STORE_DEFAULT_PORT);
|
||||
}
|
||||
MDBAddValue(MsgGlobal.vs.server.names->Value[i], MsgGlobal.vs.storeDNs);
|
||||
for (j = count + 1; j < MsgGlobal.vs.server.contexts->Used; j++) {
|
||||
MDBAddValue(addresses->Value[count], addresses);
|
||||
MDBAddValue(storePortText, ports);
|
||||
MDBAddValue(MsgGlobal.vs.server.names->Value[i], MsgGlobal.vs.storeDNs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MDBAddValue doesn't add empty values, so fake it */
|
||||
/* with a ^A in the string */
|
||||
emptyString[0]=EMPTY_CHAR;
|
||||
/* Now read all the store path values */
|
||||
|
||||
for (i = 0; i < MsgGlobal.vs.server.contexts->Used; i++) {
|
||||
if (MDBRead(MsgGlobal.vs.server.contexts->Value[i], MSGSRV_A_MESSAGE_STORE, MsgGlobal.vs.storePaths) == 0) {
|
||||
/* Add an empty string, no context store specified */
|
||||
MDBAddValue(emptyString, MsgGlobal.vs.storePaths);
|
||||
} else {
|
||||
MsgCleanPath(MsgGlobal.vs.storePaths->Value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize addr structure for each context */
|
||||
MsgGlobal.vs.server.addr = MemMalloc0(MsgGlobal.vs.server.contexts->Used * sizeof(struct sockaddr_in));
|
||||
if (!MsgGlobal.vs.server.addr) {
|
||||
MDBDestroyValueStruct(ports);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
for (i = 0; i < MsgGlobal.vs.server.contexts->Used; i++) {
|
||||
MsgGlobal.vs.server.addr[i].sin_addr.s_addr = inet_addr(addresses->Value[i]);
|
||||
MsgGlobal.vs.server.addr[i].sin_port = htons(atol(ports->Value[i]));
|
||||
MsgGlobal.vs.server.addr[i].sin_family = AF_INET;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < MsgGlobal.vs.server.contexts->Used; i++) {
|
||||
XplConsolePrintf("\rCtx:%-35s IP:%-15s Path:%s\n", MsgGlobal.vs.server.contexts->Value[i], addresses->Value[i], MsgGlobal.vs.storePaths->Value[i]);
|
||||
XplConsolePrintf("\rDN :%-35s\n\n", MsgGlobal.vs.storeDNs->Value[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
MDBDestroyValueStruct(addresses);
|
||||
MDBDestroyValueStruct(ports);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
MsgLibraryStop(void)
|
||||
{
|
||||
@@ -694,21 +343,6 @@ MsgLibraryStop(void)
|
||||
XplDelay(1000);
|
||||
}
|
||||
|
||||
MDBDestroyValueStruct(MsgGlobal.vs.storeDNs);
|
||||
MDBDestroyValueStruct(MsgGlobal.vs.storePaths);
|
||||
MDBDestroyValueStruct(MsgGlobal.vs.server.contexts);
|
||||
MDBDestroyValueStruct(MsgGlobal.vs.server.names);
|
||||
if (MsgGlobal.vs.server.addr) {
|
||||
MemFree(MsgGlobal.vs.server.addr);
|
||||
MsgGlobal.vs.server.addr = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef PARENTOBJECT_STORE
|
||||
MDBDestroyValueStruct(MsgGlobal.vs.parent.stores);
|
||||
MDBDestroyValueStruct(MsgGlobal.vs.parent.objects);
|
||||
#endif
|
||||
|
||||
XplRWLockDestroy(&MsgGlobal.configLock);
|
||||
|
||||
return(TRUE);
|
||||
@@ -794,7 +428,6 @@ MsgLibraryStart(void)
|
||||
unsigned long i;
|
||||
struct sockaddr_in server_sockaddr;
|
||||
unsigned char path[XPL_MAX_PATH + 1];
|
||||
MDBValueStruct *config;
|
||||
XplThreadID ID;
|
||||
|
||||
/* Prepare later config updates */
|
||||
@@ -809,85 +442,9 @@ MsgLibraryStart(void)
|
||||
strcpy(MsgGlobal.paths.certificate, XPL_DEFAULT_CERT_PATH);
|
||||
strcpy(MsgGlobal.paths.key, XPL_DEFAULT_KEY_PATH);
|
||||
|
||||
/* Read "context" related stuff */
|
||||
|
||||
MsgGlobal.vs.server.names = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
MsgGlobal.vs.server.contexts = MDBShareContext(MsgGlobal.vs.server.names);
|
||||
MsgGlobal.vs.storePaths = MDBShareContext(MsgGlobal.vs.server.names);
|
||||
MsgGlobal.vs.storeDNs = MDBShareContext(MsgGlobal.vs.server.names);
|
||||
MsgGlobal.vs.server.addr = NULL;
|
||||
|
||||
#ifdef PARENTOBJECT_STORE
|
||||
MsgGlobal.vs.parent.objects = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
MsgGlobal.vs.parent.stores = MDBShareContext(MsgGlobal.vs.parent.objects);
|
||||
#endif
|
||||
|
||||
server_sockaddr.sin_addr.s_addr=XplGetHostIPAddress();
|
||||
sprintf(MsgGlobal.address.string,"%d.%d.%d.%d",
|
||||
server_sockaddr.sin_addr.s_net,
|
||||
server_sockaddr.sin_addr.s_host,
|
||||
server_sockaddr.sin_addr.s_lh,
|
||||
server_sockaddr.sin_addr.s_impno);
|
||||
|
||||
MDBAddValue(MsgGlobal.address.string, MsgGlobal.vs.server.names);
|
||||
if (!(MsgGlobal.flags & MSGAPI_FLAG_CLUSTERED)) {
|
||||
MDBWrite(MsgGlobal.server.dn, MSGSRV_A_IP_ADDRESS, MsgGlobal.vs.server.names);
|
||||
} else {
|
||||
MDBFreeValues(MsgGlobal.vs.server.names);
|
||||
if (MDBRead(MsgGlobal.server.dn, MSGSRV_A_IP_ADDRESS, MsgGlobal.vs.server.names)>0) {
|
||||
strcpy(MsgGlobal.address.string, MsgGlobal.vs.server.names->Value[0]);
|
||||
}
|
||||
}
|
||||
|
||||
MDBFreeValues(MsgGlobal.vs.server.names);
|
||||
MsgGlobal.address.local = inet_addr(MsgGlobal.address.string);
|
||||
|
||||
// MDBFreeValues(config);
|
||||
|
||||
//LoadContextList(config);
|
||||
|
||||
// MDBDestroyValueStruct(config);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
MDBHandle
|
||||
MsgGetSystemDirectoryHandle(void)
|
||||
{
|
||||
MDBHandle systemHandle;
|
||||
unsigned char buffer[XPL_MAX_PATH + 1];
|
||||
unsigned char credential[128];
|
||||
FILE *eclients;
|
||||
|
||||
memset(credential, 0, sizeof(credential));
|
||||
|
||||
sprintf(buffer, "%s/eclients.dat", XPL_DEFAULT_DBF_DIR);
|
||||
eclients = fopen(buffer, "rb");
|
||||
if (eclients) {
|
||||
fread(credential, sizeof(unsigned char), sizeof(credential), eclients);
|
||||
|
||||
fclose(eclients);
|
||||
eclients = NULL;
|
||||
} else {
|
||||
XplConsolePrintf("Insufficient privileges; shutting down.\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (!MsgGetConfigProperty(MsgGlobal.server.dn,
|
||||
MSGSRV_CONFIG_PROP_MESSAGING_SERVER)) {
|
||||
XplConsolePrintf("Messaging server not configured. Shutdown.\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
systemHandle = MDBAuthenticate("Bongo", MsgGlobal.server.dn, credential);
|
||||
if (systemHandle == NULL) {
|
||||
XplConsolePrintf("Messaging server credentials are invalid; shutting down.\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
return(systemHandle);
|
||||
}
|
||||
|
||||
BOOL
|
||||
MsgGetBuildVersion(int *version, BOOL *custom)
|
||||
{
|
||||
@@ -952,7 +509,6 @@ MsgGetUpdateStatus(char *record, int record_length)
|
||||
static BOOL
|
||||
MsgReadConfiguration(void)
|
||||
{
|
||||
MDBValueStruct *config;
|
||||
unsigned long i;
|
||||
struct tm *timeStruct;
|
||||
time_t utcTime;
|
||||
@@ -976,15 +532,6 @@ MsgReadConfiguration(void)
|
||||
* automatically detect pre2.5 installs and change the DS attribute...
|
||||
*/
|
||||
|
||||
config = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
|
||||
if (!config) {
|
||||
XplConsolePrintf("Messaging server out of memory; shutting down.\n");
|
||||
MDBRelease(MsgGlobal.directoryHandle);
|
||||
MsgGlobal.directoryHandle = NULL;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
strcpy(MsgGlobal.paths.dbf, XPL_DEFAULT_DBF_DIR);
|
||||
MsgMakePath(MsgGlobal.paths.dbf);
|
||||
strcpy(MsgGlobal.paths.bin, XPL_DEFAULT_BIN_DIR);
|
||||
@@ -998,20 +545,6 @@ MsgReadConfiguration(void)
|
||||
strcpy(MsgGlobal.paths.work, XPL_DEFAULT_WORK_DIR);
|
||||
MsgMakePath(MsgGlobal.paths.work);
|
||||
|
||||
/* Official Name */
|
||||
if (MDBRead(MsgGlobal.server.dn, MSGSRV_A_OFFICIAL_NAME, config)) {
|
||||
strcpy(MsgGlobal.official.domain, config->Value[0]);
|
||||
MsgGlobal.official.domainLength = strlen(MsgGlobal.official.domain);
|
||||
}
|
||||
MDBFreeValues(config);
|
||||
|
||||
if (MDBRead(MsgGlobal.server.dn, MSGSRV_A_SERVER_STANDALONE, config)) {
|
||||
if (config->Value[0][0]=='1') {
|
||||
MsgGlobal.flags |= MSGAPI_FLAG_STANDALONE;
|
||||
}
|
||||
}
|
||||
MDBDestroyValueStruct(config);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@@ -1024,8 +557,6 @@ MsgLibraryInit(void)
|
||||
|
||||
MsgGlobal.groupID = XplGetThreadGroupID();
|
||||
|
||||
MsgGlobal.directoryHandle = NULL;
|
||||
|
||||
MsgGlobal.connManager = 0x0100007F;
|
||||
|
||||
MsgGlobal.official.domain[0] = '\0';
|
||||
@@ -1036,17 +567,6 @@ MsgLibraryInit(void)
|
||||
|
||||
MemoryManagerOpen(NULL);
|
||||
|
||||
if (!MDBInit()) {
|
||||
MemoryManagerClose(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MsgGlobal.directoryHandle = MsgGetSystemDirectoryHandle();
|
||||
if (!(MsgGlobal.directoryHandle)) {
|
||||
MemoryManagerClose(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!MsgReadConfiguration()) {
|
||||
XplConsolePrintf("Cannot read configuration. Shutting down.\n");
|
||||
|
||||
@@ -1092,12 +612,6 @@ MsgLibraryShutdown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
MDBHandle
|
||||
MsgDirectoryHandle(void)
|
||||
{
|
||||
return(MsgGlobal.directoryHandle);
|
||||
}
|
||||
|
||||
BOOL
|
||||
MsgExiting(void)
|
||||
{
|
||||
@@ -1122,15 +636,13 @@ MsgShutdown(void)
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
EXPORT MDBHandle
|
||||
EXPORT void
|
||||
MsgInit(void)
|
||||
{
|
||||
if (MSGAPIState == LIBRARY_LOADED) {
|
||||
MSGAPIState = LIBRARY_INITIALIZING;
|
||||
|
||||
if (!MsgLibraryInit()) {
|
||||
return NULL;
|
||||
}
|
||||
if (!MsgLibraryInit()) return;
|
||||
}
|
||||
|
||||
while (MSGAPIState < LIBRARY_RUNNING) {
|
||||
@@ -1140,8 +652,6 @@ MsgInit(void)
|
||||
if (MSGAPIState == LIBRARY_RUNNING) {
|
||||
XplSafeIncrement(MsgGlobal.useCount);
|
||||
}
|
||||
|
||||
return((MSGAPIState == LIBRARY_RUNNING) ? MsgGlobal.directoryHandle : NULL);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
|
||||
@@ -265,14 +265,7 @@ BongoAgentInit(BongoAgent *agent,
|
||||
ConnStartup(timeOut, TRUE);
|
||||
|
||||
if (startupResources & BA_STARTUP_MDB) {
|
||||
MDBInit();
|
||||
|
||||
agent->directoryHandle = (MDBHandle)MsgInit();
|
||||
if (agent->directoryHandle == NULL) {
|
||||
XplConsolePrintf("%s: Invalid directory credentials; exiting!\r\n", agentName);
|
||||
MemoryManagerClose(agentDn);
|
||||
return -1;
|
||||
}
|
||||
MsgInit();
|
||||
}
|
||||
|
||||
if ((startupResources & BA_STARTUP_NMAP) && !NMAPInitialize()) {
|
||||
|
||||
@@ -8,12 +8,12 @@ pkgpyexec_LTLIBRARIES := \
|
||||
libs.la \
|
||||
bootstrap.la
|
||||
|
||||
# src/libs/python/libbongo/mdb.c
|
||||
libs_la_SOURCES := \
|
||||
src/libs/python/libbongo/cal.c \
|
||||
src/libs/python/libbongo/calcmd.c \
|
||||
src/libs/python/libbongo/libs.c \
|
||||
src/libs/python/libbongo/libs.h \
|
||||
src/libs/python/libbongo/mdb.c \
|
||||
src/libs/python/libbongo/msgapi.c \
|
||||
src/libs/python/libbongo/msgapi-defs.c \
|
||||
src/libs/python/libbongo/msgapi-defs.h \
|
||||
@@ -35,14 +35,13 @@ libs_la_LIBADD := \
|
||||
libbongocalcmd.la \
|
||||
libbongoutil.la \
|
||||
libbongo-json.la \
|
||||
libbongomdb.la \
|
||||
libbongomsgapi.la \
|
||||
libbongostreamio.la
|
||||
|
||||
# src/libs/python/libbongo/mdb.c
|
||||
bootstrap_la_SOURCES := \
|
||||
src/libs/python/libbongo/bootstrap.c \
|
||||
src/libs/python/libbongo/bootstrap.h \
|
||||
src/libs/python/libbongo/mdb.c \
|
||||
src/libs/python/libbongo/msgapi-defs.c \
|
||||
src/libs/python/libbongo/msgapi-defs.h \
|
||||
src/libs/python/libbongo/pybongo.c \
|
||||
@@ -55,7 +54,6 @@ bootstrap_la_CPPFLAGS := $(AM_CPPFLAGS) \
|
||||
bootstrap_la_LDFLAGS := -avoid-version -module
|
||||
bootstrap_la_LIBADD := \
|
||||
$(PYTHON_LIBS) \
|
||||
libbongomdb.la \
|
||||
libbongomsgapi.la
|
||||
|
||||
src/libs/python/libbongo/libs.so: libs.la
|
||||
|
||||
@@ -70,11 +70,7 @@ initlibs()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MsgInit()) {
|
||||
PyErr_SetString(PyExc_ImportError,
|
||||
"bongo.libs error: MsgInit() failed");
|
||||
return;
|
||||
}
|
||||
MsgInit();
|
||||
|
||||
MsgGetDBFDir(dbfdir);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user