Remove some cruft from msgapi
This commit is contained in:
+1
-14
@@ -455,9 +455,6 @@ typedef struct _MSGCacheInitStruct {
|
||||
typedef BOOL (*FindObjectCacheInitType)(MSGCacheInitStruct *initData, unsigned char *description);
|
||||
typedef BOOL (*FindObjectCacheShutdownType)(void);
|
||||
|
||||
/* fixme - this api belongs in the dmc */
|
||||
EXPORT void MsgSendTrap(int type, unsigned char *message);
|
||||
|
||||
EXPORT MDBHandle MsgInit(void);
|
||||
EXPORT BOOL MsgShutdown(void);
|
||||
EXPORT MDBHandle MsgGetSystemDirectoryHandle(void);
|
||||
@@ -480,10 +477,8 @@ EXPORT const unsigned char *MsgGetLibDir(char *directory);
|
||||
EXPORT const unsigned char *MsgGetBinDir(char *directory);
|
||||
EXPORT const unsigned char *MsgGetTLSCertPath(char *path);
|
||||
EXPORT const unsigned char *MsgGetTLSKeyPath(char *path);
|
||||
EXPORT int MsgGetParentAttribute(const unsigned char *userDn, unsigned char *attribute, MDBValueStruct *v);
|
||||
EXPORT unsigned char *MsgGetUserEmailAddress(const unsigned char *userDn, MDBValueStruct *userData, unsigned char *buffer, unsigned long bufLen);
|
||||
EXPORT unsigned char *MsgGetUserDisplayName(const unsigned char *userDn, MDBValueStruct *userData);
|
||||
EXPORT BOOL MsgGetUserSettingsContainerDN(const unsigned char *userDn, unsigned char *containerDn, MDBValueStruct *v, BOOL create);
|
||||
EXPORT BOOL MsgGetUserSettingsDN(const unsigned char *userDn, unsigned char *configDn, MDBValueStruct *v, BOOL create);
|
||||
EXPORT long MsgGetUserSetting(const unsigned char *userDn, unsigned char *attribute, MDBValueStruct *vOut);
|
||||
EXPORT BOOL MsgSetUserSetting(const unsigned char *userDn, unsigned char *attribute, MDBValueStruct *vIn);
|
||||
@@ -493,27 +488,19 @@ EXPORT unsigned long MsgGetAgentBindIPAddress(void);
|
||||
|
||||
EXPORT const char *MsgGetUnprivilegedUser(void);
|
||||
|
||||
// TODO: Deprecate these functions in favour of nmlib
|
||||
EXPORT void MsgNmapChallenge(const unsigned char *response, unsigned char *reply, size_t length);
|
||||
EXPORT Connection *MsgNmapConnect(const char *authUser, const char *store, MDBValueStruct *optVs);
|
||||
EXPORT Connection *MsgNmapConnectEx(const char *authUser, const char *store, MDBValueStruct *optVs, TraceDestination *dest);
|
||||
|
||||
|
||||
EXPORT void MsgMakePath(unsigned char *path);
|
||||
EXPORT BOOL MsgCleanPath(unsigned char *path);
|
||||
|
||||
EXPORT BOOL MsgRegisterAddress(unsigned long address, unsigned char *name);
|
||||
// EXPORT BOOL MsgIsKnownAddress(unsigned long address, unsigned char *name);
|
||||
|
||||
EXPORT BOOL MsgResolveStart();
|
||||
EXPORT BOOL MsgResolveStop();
|
||||
|
||||
EXPORT void MsgGetUid(char *buffer, int buflen);
|
||||
|
||||
/* fixme - deprecated interfaces? */
|
||||
EXPORT BOOL MsgFindServer(const unsigned char *user, unsigned char *dn);
|
||||
|
||||
EXPORT BOOL MsgSetServerState(const unsigned char *server, const unsigned char *setState);
|
||||
|
||||
/* from msgcollector.c */
|
||||
|
||||
enum {
|
||||
|
||||
@@ -175,25 +175,6 @@ MsgGetServerDN(unsigned char *buffer)
|
||||
return(MsgGlobal.server.dn);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgSetServerState(const unsigned char *server, const unsigned char *setState)
|
||||
{
|
||||
MDBValueStruct *state;
|
||||
|
||||
state = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
MDBAddValue(setState, state);
|
||||
|
||||
if (server) {
|
||||
MDBWrite(server, MSGSRV_A_SERVER_STATUS, state);
|
||||
} else {
|
||||
MDBWrite(MsgGlobal.server.dn, MSGSRV_A_SERVER_STATUS, state);
|
||||
}
|
||||
|
||||
MDBDestroyValueStruct(state);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgFindUserNmap(const unsigned char *user, unsigned char *nmap, int nmap_len, unsigned short *port)
|
||||
{
|
||||
@@ -528,42 +509,6 @@ MsgFindUserStore(const unsigned char *user, const unsigned char *defaultPath)
|
||||
return MsgGlobal.cache.store(user, defaultPath);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgFindServer(const unsigned char *user, unsigned char *dn)
|
||||
{
|
||||
MDBValueStruct *userCtx;
|
||||
unsigned long i;
|
||||
BOOL retVal = FALSE;
|
||||
|
||||
userCtx = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
|
||||
XplRWReadLockAcquire(&MsgGlobal.configLock);
|
||||
for (i = 0; i < MsgGlobal.vs.server.contexts->Used; i++) {
|
||||
MDBSetValueStructContext(MsgGlobal.vs.server.contexts->Value[i], userCtx);
|
||||
if (MDBGetObjectDetails(user, NULL, NULL, NULL, userCtx)) {
|
||||
if (MsgGetUserSetting(user, MSGSRV_A_MESSAGING_DISABLED,
|
||||
userCtx) > 0) {
|
||||
if (userCtx->Value[userCtx->Used-1][0]=='1') {
|
||||
break;
|
||||
} else {
|
||||
MDBFreeValues(userCtx);
|
||||
}
|
||||
}
|
||||
|
||||
/* The user exists, and is enabled */
|
||||
if (dn) {
|
||||
strcpy(dn, MsgGlobal.vs.storeDNs->Value[i]);
|
||||
}
|
||||
|
||||
retVal=TRUE;
|
||||
}
|
||||
}
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
|
||||
MDBDestroyValueStruct(userCtx);
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgReadIP(const unsigned char *object, unsigned char *type, MDBValueStruct *v)
|
||||
{
|
||||
@@ -1349,156 +1294,8 @@ MsgGetUserFeature(const unsigned char *userDN, unsigned char featureRow, unsigne
|
||||
}
|
||||
|
||||
return MsgGetUserSetting(configDN, attribute, vOut);
|
||||
|
||||
/*
|
||||
i = MDBRead(objectDN, attribute, vOut);
|
||||
if (i > 0) {
|
||||
return(i);
|
||||
}
|
||||
|
||||
// We didn't find what we were looking for, let's try the opposite DN (if
|
||||
// possible)
|
||||
if (parentDN[0] != '\0') {
|
||||
// If we checked User, let's check parent, and vice versa
|
||||
if (objectDN == configDN) {
|
||||
i = MDBRead(parentDN, attribute, vOut);
|
||||
} else {
|
||||
i = MDBRead(configDN, attribute, vOut);
|
||||
}
|
||||
|
||||
return(i);
|
||||
} else {
|
||||
// No parent DN, don't bother; we return success, but without data
|
||||
return(0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
EXPORT BOOL
|
||||
MsgRegisterAddress(unsigned long address, unsigned char *name)
|
||||
{
|
||||
struct sockaddr_in fromSin;
|
||||
struct sockaddr_in toSin;
|
||||
int sock;
|
||||
unsigned char commandBuffer[CONNMGR_STRUCT_SIZE];
|
||||
ConnectionManagerCommand *command=(ConnectionManagerCommand *)commandBuffer;
|
||||
|
||||
XplRWReadLockAcquire(&MsgGlobal.configLock);
|
||||
if (!(MsgGlobal.flags & MSGAPI_FLAG_SUPPORT_CONNMGR)) {
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
return(FALSE);
|
||||
}
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
|
||||
memset(&fromSin, 0, sizeof(struct sockaddr_in));
|
||||
memset(&toSin, 0, sizeof(struct sockaddr_in));
|
||||
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sock >= 0) {
|
||||
toSin.sin_family = AF_INET;
|
||||
|
||||
XplRWReadLockAcquire(&MsgGlobal.configLock);
|
||||
toSin.sin_addr.s_addr = MsgGlobal.connManager;
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
|
||||
toSin.sin_port = htons(NMAP_PORT);
|
||||
|
||||
fromSin.sin_family = AF_INET;
|
||||
fromSin.sin_addr.s_addr = 0;
|
||||
fromSin.sin_port = 0;
|
||||
|
||||
if (bind(sock, (struct sockaddr *)&fromSin, sizeof(fromSin)) == 0) {
|
||||
command->address = address;
|
||||
|
||||
/* The split may make it harder to read, but it gives a few cycles more performace, and in this code path it's important! */
|
||||
if (name) {
|
||||
command->nameLen = strlen(name);
|
||||
memcpy(command->name, name, command->nameLen);
|
||||
command->request = CONNMGR_REQ_STORE_NAME;
|
||||
sendto(sock, (unsigned char *)command, sizeof(ConnectionManagerCommand) + command->nameLen, 0, (struct sockaddr*)&toSin, sizeof(toSin));
|
||||
} else {
|
||||
command->request = CONNMGR_REQ_STORE;
|
||||
sendto(sock, (unsigned char *)command, sizeof(ConnectionManagerCommand), 0, (struct sockaddr*)&toSin, sizeof(toSin));
|
||||
}
|
||||
}
|
||||
IPclose(sock);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
// REMOVE: CONNIO DEPRECATE
|
||||
EXPORT BOOL
|
||||
MsgIsKnownAddress(unsigned long address, unsigned char *name)
|
||||
{
|
||||
struct sockaddr_in fromSin;
|
||||
struct sockaddr_in toSin;
|
||||
int sock;
|
||||
int size;
|
||||
unsigned char commandBuffer[CONNMGR_STRUCT_SIZE];
|
||||
ConnectionManagerCommand *command=(ConnectionManagerCommand *)commandBuffer;
|
||||
|
||||
XplRWReadLockAcquire(&MsgGlobal.configLock);
|
||||
if (!(MsgGlobal.flags & MSGAPI_FLAG_SUPPORT_CONNMGR)) {
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
if (name) {
|
||||
name[0]='\0';
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
|
||||
memset(&fromSin, 0, sizeof(struct sockaddr_in));
|
||||
memset(&toSin, 0, sizeof(struct sockaddr_in));
|
||||
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sock >= 0) {
|
||||
toSin.sin_family = AF_INET;
|
||||
XplRWReadLockAcquire(&MsgGlobal.configLock);
|
||||
toSin.sin_addr.s_addr = MsgGlobal.connManager;
|
||||
XplRWReadLockRelease(&MsgGlobal.configLock);
|
||||
toSin.sin_port = htons(NMAP_PORT);
|
||||
|
||||
fromSin.sin_family = AF_INET;
|
||||
fromSin.sin_addr.s_addr = 0;
|
||||
fromSin.sin_port = 0;
|
||||
|
||||
if (bind(sock, (struct sockaddr *)&fromSin, sizeof(fromSin)) == 0) {
|
||||
command->address = address;
|
||||
|
||||
if (name) {
|
||||
command->request = CONNMGR_REQ_CHECK_NAME;
|
||||
} else {
|
||||
command->request = CONNMGR_REQ_CHECK;
|
||||
}
|
||||
sendto(sock, (unsigned char *)command, CONNMGR_STRUCT_SIZE, 0, (struct sockaddr*)&toSin, sizeof(toSin));
|
||||
|
||||
size = XplIPRead(XPL_INT_TO_PTR(sock), (unsigned char *)command, CONNMGR_STRUCT_SIZE, 19);
|
||||
|
||||
IPclose(sock);
|
||||
|
||||
if (size <= 0 || command->request == CONNMGR_REPLY_NOT_FOUND) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
if (name) {
|
||||
if (command->request == CONNMGR_REPLY_FOUND_NAME) {
|
||||
memcpy(name, command->name, command->nameLen);
|
||||
name[command->nameLen]='\0';
|
||||
} else {
|
||||
name[0]='\0';
|
||||
}
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
IPclose(sock);
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
*/
|
||||
|
||||
EXPORT BOOL
|
||||
MsgCleanPath(unsigned char *path)
|
||||
{
|
||||
@@ -2539,99 +2336,3 @@ MsgInit(void)
|
||||
|
||||
return((MSGAPIState == LIBRARY_RUNNING) ? MsgGlobal.directoryHandle : NULL);
|
||||
}
|
||||
|
||||
/* fixme - platform service implementation! */
|
||||
#if 0
|
||||
#if defined(NETWARE) || defined(LIBC)
|
||||
XplThreadrID TGid;
|
||||
|
||||
void MSGAPIShutdownSigHandler(int sigtype)
|
||||
{
|
||||
static BOOL signaled = FALSE;
|
||||
XplThreadID oldTGID;
|
||||
|
||||
if (!signaled) {
|
||||
oldTGID = XplSetThreadGroupID(TGid);
|
||||
|
||||
/* Wake up the main thread to let him know we are shutting down.
|
||||
Then perform a context (thread) switch to let him get out.
|
||||
Finally, wait for him to signal the fact that he is gone. */
|
||||
XplSignalLocalSemaphore(MsgGlobal.sem.shutdown);
|
||||
XplWaitOnLocalSemaphore(MsgGlobal.sem.shutdown);
|
||||
|
||||
XplCloseLocalSemaphore(MsgGlobal.sem.shutdown);
|
||||
|
||||
XplSetThreadGroupID(oldTGID);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int _NonAppCheckUnload(void)
|
||||
{
|
||||
if (XplSafeRead(MsgGlobal.useCount) == 1) {
|
||||
MSGAPIShutdownSigHandler(SIGTERM);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
XplConsolePrintf("MSGAPI: %d library users outstanding; cannot unload.\r\n", XplSafeRead(MsgGlobal.useCount));
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
#if !defined(NETWARE)
|
||||
int ccode;
|
||||
XplThreadID id;
|
||||
#endif
|
||||
|
||||
MSGAPIState = LIBRARY_INITIALIZING;
|
||||
|
||||
TGid = XplGetThreadGroupID();
|
||||
|
||||
XplOpenLocalSemaphore(MsgGlobal.sem.version, 1);
|
||||
|
||||
#if !defined(NETWARE)
|
||||
XplSignalHandler(MSGAPIShutdownSigHandler);
|
||||
#endif
|
||||
|
||||
MsgLibraryInit();
|
||||
|
||||
XplWaitOnLocalSemaphore(MsgGlobal.sem.shutdown);
|
||||
|
||||
/* Make sure the library users are gone before beginning to
|
||||
shutdown. */
|
||||
while (XplSafeRead(MsgGlobal.useCount) > 1) {
|
||||
XplDelay(333);
|
||||
}
|
||||
|
||||
MsgShutdown();
|
||||
|
||||
XplCloseLocalSemaphore(MsgGlobal.sem.version);
|
||||
|
||||
XplSignalLocalSemaphore(MsgGlobal.sem.shutdown);
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
HANDLE StatsMap;
|
||||
HANDLE SpamMap;
|
||||
#define MSGAPI_MEMORYMAP_STATS "MSGAPIStats"
|
||||
#define MSGAPI_MEMORYMAP_SPAM "MSGAPISpamStats"
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain(HINSTANCE hInst, DWORD Reason, LPVOID Reserved)
|
||||
{
|
||||
if (Reason == DLL_PROCESS_ATTACH) {
|
||||
DisableThreadLibraryCalls(hInst);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <msgapi.h>
|
||||
|
||||
/* msgapi.c */
|
||||
int MsgGetParentAttribute(const unsigned char *userDn, unsigned char *attribute, MDBValueStruct *v);
|
||||
BOOL MsgGetUserSettingsContainerDN(const unsigned char *userDn, unsigned char *containerDn, MDBValueStruct *v, BOOL create);
|
||||
MDBHandle MsgDirectoryHandle(void);
|
||||
BOOL MsgExiting(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user