From d06acaef1438df40b3c8d221c12d93b4a249a9be Mon Sep 17 00:00:00 2001 From: alexhudson Date: Fri, 31 Aug 2007 16:37:21 +0000 Subject: [PATCH] Small patch to remove mdb from the build --- Makefile.am | 13 +- configure.ac | 7 +- include/msgapi.h | 2 +- src/agents/alarm/Bongo.rules | 1 - src/agents/antispam/Bongo.rules | 1 - src/agents/antispam/antispam.c | 8 +- src/agents/avirus/Bongo.rules | 1 - src/agents/avirus/avirus.c | 11 +- src/agents/calcmd/Bongo.rules | 1 - src/agents/collector/Bongo.rules | 1 - src/agents/generic/Bongo.rules | 1 - src/agents/imap/Bongo.rules | 1 - src/agents/imap/imapd.c | 9 +- src/agents/itip/Bongo.rules | 1 - src/agents/mailprox/Bongo.rules | 1 - src/agents/pluspack/Bongo.rules | 1 - src/agents/pop/Bongo.rules | 1 - src/agents/pop/pop3.c | 8 +- src/agents/queue/queue.c | 50 +-- src/agents/rules/Bongo.rules | 1 - src/agents/smtp/Bongo.rules | 1 - src/agents/smtp/smtpd.c | 18 +- src/agents/store/Bongo.rules | 1 - src/agents/store/stored.c | 7 +- src/agents/store/tests/Bongo.rules | 2 - src/apps/backup/Bongo.rules | 1 - src/apps/config/Bongo.rules | 3 +- src/apps/config/config.c | 192 ++-------- src/apps/config/config.h | 12 +- src/apps/config/config/manager | 6 +- src/apps/config/store.c | 165 +++++++++ src/apps/manager/Bongo.rules | 1 - src/apps/manager/manager.c | 27 +- src/apps/sendmail/Bongo.rules | 1 - src/apps/sendmail/sendmail.c | 7 +- src/libs/calcmd/Bongo.rules | 1 - src/libs/connio/tests/Bongo.rules | 1 - src/libs/msgapi/Bongo.rules | 1 - src/libs/msgapi/msgapi.c | 500 +-------------------------- src/libs/nmap/bongoagent.c | 9 +- src/libs/python/libbongo/Bongo.rules | 6 +- src/libs/python/libbongo/libs.c | 6 +- 42 files changed, 276 insertions(+), 812 deletions(-) create mode 100644 src/apps/config/store.c diff --git a/Makefile.am b/Makefile.am index 5691e3e..2d9d503 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index d670625..0859544 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/include/msgapi.h b/include/msgapi.h index f6e58a8..25fea80 100644 --- a/include/msgapi.h +++ b/include/msgapi.h @@ -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); diff --git a/src/agents/alarm/Bongo.rules b/src/agents/alarm/Bongo.rules index d017dec..20a560f 100644 --- a/src/agents/alarm/Bongo.rules +++ b/src/agents/alarm/Bongo.rules @@ -9,7 +9,6 @@ bongoalarm_LDADD := \ libbongonmap.la \ libbongocal.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/antispam/Bongo.rules b/src/agents/antispam/Bongo.rules index 7c6dcef..d60b8e2 100644 --- a/src/agents/antispam/Bongo.rules +++ b/src/agents/antispam/Bongo.rules @@ -9,7 +9,6 @@ bongoantispam_SOURCES := \ bongoantispam_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/antispam/antispam.c b/src/agents/antispam/antispam.c index c316d2b..c45f163 100644 --- a/src/agents/antispam/antispam.c +++ b/src/agents/antispam/antispam.c @@ -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); diff --git a/src/agents/avirus/Bongo.rules b/src/agents/avirus/Bongo.rules index a2f8b8f..b7a10ec 100644 --- a/src/agents/avirus/Bongo.rules +++ b/src/agents/avirus/Bongo.rules @@ -11,7 +11,6 @@ bongoavirus_LDADD := \ libbongonmap.la \ libbongostreamio.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/avirus/avirus.c b/src/agents/avirus/avirus.c index 7995d4a..ad48e43 100755 --- a/src/agents/avirus/avirus.c +++ b/src/agents/avirus/avirus.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -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(); diff --git a/src/agents/calcmd/Bongo.rules b/src/agents/calcmd/Bongo.rules index 91095b1..b3d85fd 100644 --- a/src/agents/calcmd/Bongo.rules +++ b/src/agents/calcmd/Bongo.rules @@ -8,7 +8,6 @@ bongocalcmd_SOURCES := \ bongocalcmd_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/collector/Bongo.rules b/src/agents/collector/Bongo.rules index 95b4663..89597fb 100644 --- a/src/agents/collector/Bongo.rules +++ b/src/agents/collector/Bongo.rules @@ -12,7 +12,6 @@ bongocollector_LDADD := \ libbongonmap.la \ libbongocal.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/generic/Bongo.rules b/src/agents/generic/Bongo.rules index d2595a9..3920b49 100644 --- a/src/agents/generic/Bongo.rules +++ b/src/agents/generic/Bongo.rules @@ -8,7 +8,6 @@ bongogeneric_SOURCES := \ bongogeneric_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/imap/Bongo.rules b/src/agents/imap/Bongo.rules index 918bfc8..a88f74f 100644 --- a/src/agents/imap/Bongo.rules +++ b/src/agents/imap/Bongo.rules @@ -21,7 +21,6 @@ bongoimap_SOURCES := \ bongoimap_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/imap/imapd.c b/src/agents/imap/imapd.c index 56856e0..5edaeb9 100644 --- a/src/agents/imap/imapd.c +++ b/src/agents/imap/imapd.c @@ -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"); diff --git a/src/agents/itip/Bongo.rules b/src/agents/itip/Bongo.rules index 7243597..a272392 100644 --- a/src/agents/itip/Bongo.rules +++ b/src/agents/itip/Bongo.rules @@ -8,7 +8,6 @@ bongoitip_SOURCES := \ bongoitip_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/mailprox/Bongo.rules b/src/agents/mailprox/Bongo.rules index f17a327..fd9d217 100644 --- a/src/agents/mailprox/Bongo.rules +++ b/src/agents/mailprox/Bongo.rules @@ -10,7 +10,6 @@ bongomailprox_SOURCES := \ bongomailprox_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/pluspack/Bongo.rules b/src/agents/pluspack/Bongo.rules index dfe528b..6b5cf98 100644 --- a/src/agents/pluspack/Bongo.rules +++ b/src/agents/pluspack/Bongo.rules @@ -8,7 +8,6 @@ bongopluspack_SOURCES := \ bongopluspack_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/pop/Bongo.rules b/src/agents/pop/Bongo.rules index 9e06a65..c6cc6b7 100644 --- a/src/agents/pop/Bongo.rules +++ b/src/agents/pop/Bongo.rules @@ -8,7 +8,6 @@ bongopop3_SOURCES := \ bongopop3_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/pop/pop3.c b/src/agents/pop/pop3.c index 0398c69..eba735c 100644 --- a/src/agents/pop/pop3.c +++ b/src/agents/pop/pop3.c @@ -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"); diff --git a/src/agents/queue/queue.c b/src/agents/queue/queue.c index f4fdf0f..a954c87 100644 --- a/src/agents/queue/queue.c +++ b/src/agents/queue/queue.c @@ -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 */ 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); } diff --git a/src/agents/rules/Bongo.rules b/src/agents/rules/Bongo.rules index c532d55..e50fdc4 100644 --- a/src/agents/rules/Bongo.rules +++ b/src/agents/rules/Bongo.rules @@ -10,7 +10,6 @@ bongorules_LDADD := \ libbongonmap.la \ libbongostreamio.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/smtp/Bongo.rules b/src/agents/smtp/Bongo.rules index a695e52..6ca90c1 100644 --- a/src/agents/smtp/Bongo.rules +++ b/src/agents/smtp/Bongo.rules @@ -8,7 +8,6 @@ bongosmtp_SOURCES := \ bongosmtp_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/agents/smtp/smtpd.c b/src/agents/smtp/smtpd.c index b69f2f5..4cbd27e 100644 --- a/src/agents/smtp/smtpd.c +++ b/src/agents/smtp/smtpd.c @@ -39,7 +39,6 @@ #include -#include #include #include @@ -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; diff --git a/src/agents/store/Bongo.rules b/src/agents/store/Bongo.rules index fae1973..b9ce0cc 100644 --- a/src/agents/store/Bongo.rules +++ b/src/agents/store/Bongo.rules @@ -54,7 +54,6 @@ bongostore_LDADD = \ libbongocal.la \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongostreamio.la \ diff --git a/src/agents/store/stored.c b/src/agents/store/stored.c index 45630f7..b77caab 100644 --- a/src/agents/store/stored.c +++ b/src/agents/store/stored.c @@ -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); diff --git a/src/agents/store/tests/Bongo.rules b/src/agents/store/tests/Bongo.rules index 2caf945..f21bd3a 100644 --- a/src/agents/store/tests/Bongo.rules +++ b/src/agents/store/tests/Bongo.rules @@ -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 \ diff --git a/src/apps/backup/Bongo.rules b/src/apps/backup/Bongo.rules index 218f2e6..f8d1292 100644 --- a/src/apps/backup/Bongo.rules +++ b/src/apps/backup/Bongo.rules @@ -11,7 +11,6 @@ bongo_backup_CPPFLAGS := $(AM_CPPFLAGS) \ bongo_backup_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/apps/config/Bongo.rules b/src/apps/config/Bongo.rules index c9aa5fb..0140beb 100644 --- a/src/apps/config/Bongo.rules +++ b/src/apps/config/Bongo.rules @@ -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) diff --git a/src/apps/config/config.c b/src/apps/config/config.c index 6f05520..e1482b3 100644 --- a/src/apps/config/config.c +++ b/src/apps/config/config.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #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: diff --git a/src/apps/config/config.h b/src/apps/config/config.h index 27732c0..1b21c2f 100644 --- a/src/apps/config/config.h +++ b/src/apps/config/config.h @@ -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 diff --git a/src/apps/config/config/manager b/src/apps/config/config/manager index 153730d..ef5ed95 100644 --- a/src/apps/config/config/manager +++ b/src/apps/config/config/manager @@ -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 } diff --git a/src/apps/config/store.c b/src/apps/config/store.c new file mode 100644 index 0000000..db379a2 --- /dev/null +++ b/src/apps/config/store.c @@ -0,0 +1,165 @@ +// Load / save backup sets from the Store + +#include +#include +#include +#include +#include +#include "config.h" + +#include +#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; +} diff --git a/src/apps/manager/Bongo.rules b/src/apps/manager/Bongo.rules index 261c6b7..2167588 100644 --- a/src/apps/manager/Bongo.rules +++ b/src/apps/manager/Bongo.rules @@ -7,7 +7,6 @@ bongo_manager_SOURCES := \ bongo_manager_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongoconnio.la \ libbongomemmgr.la \ libbongo-json.la \ diff --git a/src/apps/manager/manager.c b/src/apps/manager/manager.c index 50a96e8..033c056 100644 --- a/src/apps/manager/manager.c +++ b/src/apps/manager/manager.c @@ -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); diff --git a/src/apps/sendmail/Bongo.rules b/src/apps/sendmail/Bongo.rules index 98b1288..a503e7e 100644 --- a/src/apps/sendmail/Bongo.rules +++ b/src/apps/sendmail/Bongo.rules @@ -8,7 +8,6 @@ bongo_sendmail_SOURCES := \ bongo_sendmail_LDADD := \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/apps/sendmail/sendmail.c b/src/apps/sendmail/sendmail.c index c2bb10b..8e7fbcb 100644 --- a/src/apps/sendmail/sendmail.c +++ b/src/apps/sendmail/sendmail.c @@ -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 */ diff --git a/src/libs/calcmd/Bongo.rules b/src/libs/calcmd/Bongo.rules index b9e8e46..2ac1c29 100644 --- a/src/libs/calcmd/Bongo.rules +++ b/src/libs/calcmd/Bongo.rules @@ -16,7 +16,6 @@ parsecmd_SOURCES := src/libs/calcmd/test.c parsecmd_LDADD := \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongoconnio.la \ libbongomemmgr.la \ diff --git a/src/libs/connio/tests/Bongo.rules b/src/libs/connio/tests/Bongo.rules index 4de2ee7..257f738 100644 --- a/src/libs/connio/tests/Bongo.rules +++ b/src/libs/connio/tests/Bongo.rules @@ -9,7 +9,6 @@ checktest_connio_LDADD := $(CHECK_LIBS) \ libbongoconnio.la \ libbongonmap.la \ libbongomsgapi.la \ - libbongomdb.la \ libbongologger.la \ libbongomemmgr.la \ libbongoutil.la \ diff --git a/src/libs/msgapi/Bongo.rules b/src/libs/msgapi/Bongo.rules index 90552c8..9a6a6ad 100644 --- a/src/libs/msgapi/Bongo.rules +++ b/src/libs/msgapi/Bongo.rules @@ -22,7 +22,6 @@ libbongomsgapi_la_LIBADD := \ libbongoutil.la \ libbongo-json.la \ libbongomemmgr.la \ - libbongomdb.la \ libbongonmap.la \ libbongoxpl.la \ $(LIBCURL_LIBS) \ diff --git a/src/libs/msgapi/msgapi.c b/src/libs/msgapi/msgapi.c index fe6284c..9ecb22c 100644 --- a/src/libs/msgapi/msgapi.c +++ b/src/libs/msgapi/msgapi.c @@ -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; iUsed; 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 diff --git a/src/libs/nmap/bongoagent.c b/src/libs/nmap/bongoagent.c index 9b2358f..60284a2 100644 --- a/src/libs/nmap/bongoagent.c +++ b/src/libs/nmap/bongoagent.c @@ -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()) { diff --git a/src/libs/python/libbongo/Bongo.rules b/src/libs/python/libbongo/Bongo.rules index 3004d15..d316ea8 100644 --- a/src/libs/python/libbongo/Bongo.rules +++ b/src/libs/python/libbongo/Bongo.rules @@ -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 diff --git a/src/libs/python/libbongo/libs.c b/src/libs/python/libbongo/libs.c index f07b22c..e57d64f 100644 --- a/src/libs/python/libbongo/libs.c +++ b/src/libs/python/libbongo/libs.c @@ -70,11 +70,7 @@ initlibs() return; } - if (!MsgInit()) { - PyErr_SetString(PyExc_ImportError, - "bongo.libs error: MsgInit() failed"); - return; - } + MsgInit(); MsgGetDBFDir(dbfdir);