Initial changes for Linux port of the CASA-auth-token client to linux.

This commit is contained in:
Juan Carlos Luciani
2006-10-02 21:01:45 +00:00
parent ae9d0c58c5
commit fd8d57708d
27 changed files with 2094 additions and 319 deletions

View File

@@ -46,6 +46,7 @@ char mechConfigFolderPartialPath[];
UINT32 g_ulCount = 0;
UINT32 g_ulLock = 0;
HANDLE g_hModule;
HANDLE g_hModuleMutex;
//++=======================================================================
@@ -78,11 +79,12 @@ BOOL APIENTRY DllMain(
strcpy(mechConfigFolder, programFilesFolder);
PathAppend(mechConfigFolder, mechConfigFolderPartialPath);
// Initialize the library
if (Initialize() != 0)
// Allocate module mutex
g_hModuleMutex = CreateMutex(NULL, FALSE, NULL);
if (! g_hModuleMutex)
{
// Failed to initialize the library
OutputDebugString("CASAAUTH -DllMain- Library initialization failed\n");
// Module initialization failed
OutputDebugString("CASAAUTH -DllMain- Failed to create mutex\n");
retStatus = FALSE;
}
}

View File

@@ -61,10 +61,6 @@ char clientConfigFolderPartialPath[] = "Novell\\Casa\\Etc\\Auth";
char mechConfigFolder[MAX_PATH];
char mechConfigFolderPartialPath[] = "Novell\\Casa\\Etc\\Auth\\Mechanisms";
// Synchronization mutex for the dll initialization
static
HANDLE g_hInitializationMutex;
// Path separator
char pathCharString[] = "\\";
@@ -113,11 +109,11 @@ CreateUserMutex(
if (sprintf(mutexName, "Global\\CASA_Auth_Mutex_%s", pUsername) != -1)
{
*phMutex = CreateMutex(&mutexAttributes,
FALSE,
mutexName);
FALSE,
mutexName);
if (*phMutex == NULL)
{
DbgTrace(0, "-CreateUserMutex- CreteMutex failed, error = %d\n", GetLastError());
DbgTrace(0, "-CreateUserMutex- CreateMutex failed, error = %d\n", GetLastError());
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
CASA_FACILITY_AUTHTOKEN,
CASA_STATUS_UNSUCCESSFUL);
@@ -245,89 +241,6 @@ DestroyUserMutex(
}
//++=======================================================================
CasaStatus
CreateInitializationMutex(void)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
int retStatus = -1;
DbgTrace(2, "-CreateInitializationMutex- Start\n", 0);
// Create a cache mutex only applicable to the current process
g_hInitializationMutex = CreateMutex(NULL, FALSE, NULL);
if (g_hInitializationMutex != NULL)
{
retStatus = CASA_STATUS_SUCCESS;
}
DbgTrace(2, "-CreateInitializationMutex- End\n", 0);
return retStatus;
}
//++=======================================================================
void
AcquireInitializationMutex(void)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
DbgTrace(2, "-AcquireInitializationMutex- Start\n", 0);
WaitForSingleObject(g_hInitializationMutex, INFINITE);
DbgTrace(2, "-AcquireInitializationMutex- End\n", 0);
}
//++=======================================================================
void
ReleaseInitializationMutex(void)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
DbgTrace(2, "-ReleaseInitializationMutex- Start\n", 0);
if (ReleaseMutex(g_hInitializationMutex) == 0)
{
DbgTrace(0, "-ReleaseInitializationMutex- ReleaseMutex failed, error\n", 0);
}
DbgTrace(2, "-ReleaseInitializationMutex- End\n", 0);
}
//++=======================================================================
LIB_HANDLE
OpenLibrary(
@@ -346,7 +259,6 @@ OpenLibrary(
{
LIB_HANDLE libHandle;
DbgTrace(1, "-OpenLibrary- Start\n", 0);
libHandle = LoadLibrary(pFileName);
@@ -404,7 +316,6 @@ GetFunctionPtr(
{
void *pFuncPtr;
DbgTrace(1, "-GetFunctionPtr- Start\n", 0);
pFuncPtr = GetProcAddress(libHandle, pFunctionName);
@@ -439,7 +350,6 @@ NormalizeHostName(
LIST_ENTRY *pListEntry;
NormalizedHostNameCacheEntry *pEntry = NULL;
DbgTrace(1, "-NormalizeHostName- Start\n", 0);
// Obtain our synchronization mutex

View File

@@ -49,7 +49,7 @@
// if (LEVEL == 0 || DebugLevel >= LEVEL) \
// { \
// _snprintf(printBuff, sizeof(printBuff), X, Y); \
// printf("AuthToken %s", printBuff); \
// printf("CASA_AuthToken %s", printBuff); \
// } \
//}
#define DbgTrace(LEVEL, X, Y) { \
@@ -57,35 +57,13 @@ char formatBuff[128]; \
char printBuff[256]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "AuthToken "); \
strcpy(formatBuff, "CASA_AuthToken "); \
strncat(formatBuff, X, sizeof(formatBuff) - 10); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
OutputDebugString(printBuff); \
} \
}
#define bool BOOLEAN
#define true TRUE
#define false FALSE
//
// Auth Cache Entry definition
//
typedef struct _AuthCacheEntry
{
// LIST_ENTRY listEntry;
// int refCount;
int status;
DWORD creationTime;
DWORD expirationTime;
BOOL doesNotExpire;
// char *pHostName;
// char *pCacheKeyName;
char token[1];
} AuthCacheEntry, *PAuthCacheEntry;
//
// Rpc Session definition
//
@@ -96,11 +74,18 @@ typedef struct _RpcSession
} RpcSession, *PRpcSession;
//
// Other definitions
//
#define LIB_HANDLE HMODULE
#define bool BOOLEAN
#define true TRUE
#define false FALSE
#define long DWORD
#define AcquireModuleMutex WaitForSingleObjectEx(g_hModuleMutex, INFINITE, FALSE)
#define ReleaseModuleMutex ReleaseMutex(g_hModuleMutex)
//===[ Inlines functions ]===============================================
@@ -110,5 +95,9 @@ typedef struct _RpcSession
//===[ External prototypes ]===============================================
//===[ External data ]=====================================================
extern HANDLE g_hModuleMutex;
//=========================================================================