De-MDB-ify NMAPInitialize and NMAPRegister, latter now renamed QueueRegister
This commit is contained in:
+2
-2
@@ -128,7 +128,7 @@ typedef struct {
|
||||
|
||||
/*
|
||||
*/
|
||||
BOOL NMAPInitialize(MDBHandle directoryHandle);
|
||||
BOOL NMAPInitialize();
|
||||
void NMAPSetEncryption(bongo_ssl_context *context);
|
||||
bongo_ssl_context *NMAPSSLContextAlloc(void);
|
||||
|
||||
@@ -186,6 +186,6 @@ int NMAPAuthenticateWithCookie(Connection *conn, const char *user, const char *c
|
||||
|
||||
void NMAPQuit(Connection *conn);
|
||||
|
||||
RegistrationStates NMAPRegister(const unsigned char *dn, unsigned long queue, unsigned short port);
|
||||
RegistrationStates QueueRegister(const unsigned char *dn, unsigned long queue, unsigned short port);
|
||||
|
||||
#endif /* _BONGO_NMAP_LIBRARY_H */
|
||||
|
||||
@@ -12,9 +12,8 @@ my %libraries = ('connmgr' => 7, 'management' => 14, 'mdb' => 212, 'mdb-file' =>
|
||||
'python' => 329);
|
||||
|
||||
my @msgapi = ('MsgGetSystemDirectoryHandle', 'MsgReadConfiguration', 'MsgLibraryInit',
|
||||
'MsgDirectoryHandle', 'MsgInit', 'MsgGetServerCredential', 'MsgNmapChallenge',
|
||||
'MsgDirectoryHandle', 'MsgInit', 'MsgNmapChallenge',
|
||||
'MsgFindObject', 'MsgMdbWriteAny', 'MsgMdbAddAny', 'MsgLibraryStart');
|
||||
my @nmap = ( 'NMAPRegister', 'NMAPInitialize' );
|
||||
|
||||
my %function_addicts;
|
||||
|
||||
@@ -26,7 +25,7 @@ my $search = sub {
|
||||
$current -= 3 if ($thing eq 'store'); # ALARMDB false positives
|
||||
my $percent = (100.0 / $original) * ($original - $current);
|
||||
if ($print_addicts && $thing !~ /mdb|msgapi|python/) {
|
||||
foreach my $func (@msgapi, @nmap) {
|
||||
foreach my $func (@msgapi) {
|
||||
my $count = `grep -r "$func" src/$dir/* 2>/dev/null | $filter`;
|
||||
push (@{$function_addicts{$thing}}, $func) if ($count > 0);
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ QueueSocketInit(void)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (NMAPRegister(MSGSRV_AGENT_ANTISPAM, ASpam.nmap.queue, ASpam.nmap.conn->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
if (QueueRegister(MSGSRV_AGENT_ANTISPAM, ASpam.nmap.queue, ASpam.nmap.conn->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
XplConsolePrintf("bongoantispam: Could not register with bongonmap\r\n");
|
||||
ConnFree(ASpam.nmap.conn);
|
||||
ASpam.nmap.conn = NULL;
|
||||
@@ -884,7 +884,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
return(-1);
|
||||
}
|
||||
|
||||
NMAPInitialize(ASpam.handle.directory);
|
||||
NMAPInitialize();
|
||||
|
||||
SetCurrentNameSpace(NWOS2_NAME_SPACE);
|
||||
SetTargetNameSpace(NWOS2_NAME_SPACE);
|
||||
|
||||
@@ -1316,7 +1316,7 @@ QueueSocketInit(void)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (NMAPRegister(MSGSRV_AGENT_ANTIVIRUS, AVirus.nmap.queue, AVirus.nmap.conn->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
if (QueueRegister(MSGSRV_AGENT_ANTIVIRUS, AVirus.nmap.queue, AVirus.nmap.conn->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
XplConsolePrintf("antivirus: Could not register with bongonmap\r\n");
|
||||
ConnFree(AVirus.nmap.conn);
|
||||
AVirus.nmap.conn = NULL;
|
||||
@@ -1411,7 +1411,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
}
|
||||
|
||||
StreamioInit();
|
||||
NMAPInitialize(AVirus.handle.directory);
|
||||
NMAPInitialize();
|
||||
|
||||
XplRWLockInit(&AVirus.lock.pattern);
|
||||
|
||||
|
||||
@@ -1592,8 +1592,8 @@ QueueSocketInit(void)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ((NMAPRegister(PLUSPACK_AGENT, Q_FIVE, PlusPack.nmap.conn.queue5->socketAddress.sin_port) != REGISTRATION_COMPLETED)
|
||||
|| (NMAPRegister(PLUSPACK_AGENT, Q_DELIVER, PlusPack.nmap.conn.queue6->socketAddress.sin_port) != REGISTRATION_COMPLETED)) {
|
||||
if ((QueueRegister(PLUSPACK_AGENT, Q_FIVE, PlusPack.nmap.conn.queue5->socketAddress.sin_port) != REGISTRATION_COMPLETED)
|
||||
|| (QueueRegister(PLUSPACK_AGENT, Q_DELIVER, PlusPack.nmap.conn.queue6->socketAddress.sin_port) != REGISTRATION_COMPLETED)) {
|
||||
XplConsolePrintf("bongopluspack: Could not register with bongonmap\r\n");
|
||||
if (PlusPack.nmap.conn.queue5) {
|
||||
ConnFree(PlusPack.nmap.conn.queue5);
|
||||
@@ -1700,7 +1700,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
XplDelay(20 * 1000);
|
||||
#endif
|
||||
|
||||
NMAPInitialize(PlusPack.handle.directory);
|
||||
NMAPInitialize();
|
||||
|
||||
SetCurrentNameSpace(NWOS2_NAME_SPACE);
|
||||
SetTargetNameSpace(NWOS2_NAME_SPACE);
|
||||
|
||||
@@ -2193,7 +2193,7 @@ QueueSocketInit(void)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (NMAPRegister(MSGSRV_AGENT_ANTISPAM, Rules.nmap.queue, Rules.nmap.conn->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
if (QueueRegister(MSGSRV_AGENT_ANTISPAM, Rules.nmap.queue, Rules.nmap.conn->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
XplConsolePrintf("bongorules: Could not register with bongonmap\r\n");
|
||||
ConnFree(Rules.nmap.conn);
|
||||
Rules.nmap.conn = NULL;
|
||||
@@ -2285,7 +2285,7 @@ XplServiceMain(int argc, char *argv[])
|
||||
}
|
||||
|
||||
StreamioInit();
|
||||
NMAPInitialize(Rules.handle.directory);
|
||||
NMAPInitialize();
|
||||
|
||||
SetCurrentNameSpace(NWOS2_NAME_SPACE);
|
||||
SetTargetNameSpace(NWOS2_NAME_SPACE);
|
||||
|
||||
@@ -3801,8 +3801,8 @@ QueueServerStartup (void *ignored)
|
||||
}
|
||||
|
||||
/* register on the two queues we need to be on */
|
||||
if (NMAPRegister(MSGSRV_AGENT_SMTP, Q_DELIVER, SMTPQServerConnection->socketAddress.sin_port) != REGISTRATION_COMPLETED ||
|
||||
NMAPRegister(MSGSRV_AGENT_SMTP, Q_OUTGOING, SMTPQServerConnection->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
if (QueueRegister(MSGSRV_AGENT_SMTP, Q_DELIVER, SMTPQServerConnection->socketAddress.sin_port) != REGISTRATION_COMPLETED ||
|
||||
QueueRegister(MSGSRV_AGENT_SMTP, Q_OUTGOING, SMTPQServerConnection->socketAddress.sin_port) != REGISTRATION_COMPLETED) {
|
||||
XplConsolePrintf("bongosmtp: Could not register with bongonmap\r\n");
|
||||
ConnFree(SMTPQServerConnection);
|
||||
raise(SIGTERM);
|
||||
@@ -5081,7 +5081,7 @@ int XplServiceMain (int argc, char *argv[])
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
NMAPInitialize(SMTPDirectoryHandle);
|
||||
NMAPInitialize();
|
||||
|
||||
XplRWLockInit (&ConfigLock);
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ BongoAgentInit(BongoAgent *agent,
|
||||
}
|
||||
}
|
||||
|
||||
if ((startupResources & BA_STARTUP_NMAP) && !NMAPInitialize(agent->directoryHandle)) {
|
||||
if ((startupResources & BA_STARTUP_NMAP) && !NMAPInitialize()) {
|
||||
XplConsolePrintf("%s: Could not initialize nmap library\r\n", agentName);
|
||||
return -1;
|
||||
} else {
|
||||
@@ -615,7 +615,7 @@ BongoQueueConnectionInit(BongoAgent *agent,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
reg = NMAPRegister(agent->dn,
|
||||
reg = QueueRegister(agent->dn,
|
||||
queue,
|
||||
conn->socketAddress.sin_port);
|
||||
|
||||
|
||||
+5
-79
@@ -39,8 +39,6 @@ struct {
|
||||
|
||||
unsigned char access[NMAP_HASH_SIZE];
|
||||
|
||||
MDBHandle directoryHandle;
|
||||
|
||||
bongo_ssl_context *context;
|
||||
|
||||
BOOL debug;
|
||||
@@ -1656,14 +1654,8 @@ RegisterWithQueueServer(char *queueServerIpAddress, unsigned short queueServerPo
|
||||
}
|
||||
|
||||
RegistrationStates
|
||||
NMAPRegister(const unsigned char *queueAgentCn, unsigned long queueNumber, unsigned short queueAgentPort)
|
||||
QueueRegister(const unsigned char *queueAgentCn, unsigned long queueNumber, unsigned short queueAgentPort)
|
||||
{
|
||||
unsigned long i;
|
||||
MDBValueStruct *queueServerDns = NULL;
|
||||
MDBValueStruct *details = NULL;
|
||||
unsigned short queueServerPort;
|
||||
char *ptr;
|
||||
|
||||
if (!queueAgentCn) {
|
||||
NMAPLibrary.state = REGISTRATION_FAILED;
|
||||
return(NMAPLibrary.state);
|
||||
@@ -1671,59 +1663,10 @@ NMAPRegister(const unsigned char *queueAgentCn, unsigned long queueNumber, unsig
|
||||
|
||||
NMAPLibrary.state = REGISTRATION_ALLOCATING;
|
||||
|
||||
queueServerDns = MDBCreateValueStruct(NMAPLibrary.directoryHandle, MsgGetServerDN(NULL));
|
||||
if (queueServerDns == NULL) {
|
||||
NMAPLibrary.state = REGISTRATION_FAILED;
|
||||
return(NMAPLibrary.state);
|
||||
}
|
||||
|
||||
MDBReadDN(queueAgentCn, MSGSRV_A_MONITORED_QUEUE, queueServerDns);
|
||||
if ((queueServerDns->Used == 0) || (details = MDBCreateValueStruct(NMAPLibrary.directoryHandle, NULL)) == NULL) {
|
||||
/* Failed to find a configuration object, use default connection information */
|
||||
MDBDestroyValueStruct(queueServerDns);
|
||||
XplConsolePrintf("Couldn't find configuration object for %s, attempting to connect to NMAP on 127.0.0.1\n", queueAgentCn);
|
||||
RegisterWithQueueServer("127.0.0.1", BONGO_QUEUE_PORT, queueNumber, MsgGetServerDN(NULL), queueAgentCn, queueAgentPort);
|
||||
if (NMAPLibrary.state != REGISTRATION_COMPLETED) {
|
||||
NMAPLibrary.state = REGISTRATION_FAILED;
|
||||
}
|
||||
return(NMAPLibrary.state);
|
||||
}
|
||||
|
||||
NMAPLibrary.state = REGISTRATION_CONNECTING;
|
||||
|
||||
for (i = 0; (i < queueServerDns->Used) && (NMAPLibrary.state == REGISTRATION_CONNECTING); i++) {
|
||||
/* check for a non-standard port */
|
||||
MDBRead(queueServerDns->Value[i], MSGSRV_A_PORT, details);
|
||||
if (details->Used == 0) {
|
||||
queueServerPort = BONGO_QUEUE_PORT;
|
||||
} else {
|
||||
queueServerPort = (unsigned short)atol(details->Value[0]);
|
||||
MDBFreeValues(details);
|
||||
}
|
||||
|
||||
/* find the ip address on the host server object */
|
||||
if ((ptr = strrchr(queueServerDns->Value[i], '\\')) != NULL) {
|
||||
*ptr = '\0';
|
||||
MDBRead(queueServerDns->Value[i], MSGSRV_A_IP_ADDRESS, details);
|
||||
*ptr = '\\';
|
||||
} else {
|
||||
MDBRead(queueServerDns->Value[i], MSGSRV_A_IP_ADDRESS, details);
|
||||
}
|
||||
|
||||
if (details->Used > 0) {
|
||||
RegisterWithQueueServer(details->Value[0], queueServerPort, queueNumber, MsgGetServerDN(NULL), queueAgentCn, queueAgentPort);
|
||||
MDBFreeValues(details);
|
||||
} else {
|
||||
RegisterWithQueueServer("127.0.0.1", queueServerPort, queueNumber, MsgGetServerDN(NULL), queueAgentCn, queueAgentPort);
|
||||
}
|
||||
}
|
||||
|
||||
RegisterWithQueueServer("127.0.0.1", BONGO_QUEUE_PORT, queueNumber, MsgGetServerDN(NULL), queueAgentCn, queueAgentPort);
|
||||
if (NMAPLibrary.state != REGISTRATION_COMPLETED) {
|
||||
NMAPLibrary.state = REGISTRATION_FAILED;
|
||||
}
|
||||
|
||||
MDBDestroyValueStruct(queueServerDns);
|
||||
MDBDestroyValueStruct(details);
|
||||
return(NMAPLibrary.state);
|
||||
}
|
||||
|
||||
@@ -1748,25 +1691,8 @@ NMAPSSLContextAlloc(void)
|
||||
}
|
||||
|
||||
BOOL
|
||||
NMAPInitialize(MDBHandle directoryHandle)
|
||||
NMAPInitialize(void)
|
||||
{
|
||||
BOOL result = FALSE;
|
||||
MDBValueStruct *v;
|
||||
|
||||
if (directoryHandle) {
|
||||
NMAPLibrary.directoryHandle = directoryHandle;
|
||||
|
||||
v = MDBCreateValueStruct(NMAPLibrary.directoryHandle, NULL);
|
||||
if (v) {
|
||||
MDBRead(MSGSRV_ROOT, MSGSRV_A_ACL, v);
|
||||
if (v->Used) {
|
||||
result = HashCredential(MsgGetServerDN(NULL), v->Value[0], NMAPLibrary.access);
|
||||
}
|
||||
|
||||
MDBDestroyValueStruct(v);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
// single cred for both store and queue atm...
|
||||
return MsgGetServerCredential(NMAPLibrary.access);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user