Made the following changes:

- Use host name specified in ObtainAuthToken call instead of the
    normalized host name to connect to the ATS to avoid problems
    when the host name obtained through a reverse DNS lookup fails
    to resolve via a forward DNS lookup.

  - Added the capability log debug messages to a file.

  - Added method to the ConfigIf to free memory returned by calls to
    getEntryValue to avoid issues related to freeing memory allocated
    with a heap different than the one owned by the library freeing
    the memory.
This commit is contained in:
Juan Carlos Luciani 2007-03-05 06:48:26 +00:00
parent a1b22add5a
commit 3a4a7fec0d
22 changed files with 294 additions and 134 deletions

View File

@ -159,7 +159,10 @@ GetAuthTokenIf(
if (pGetAuthTokenIfRtn)
{
// Now, obtain the modules AuthTokenIf.
retStatus = (pGetAuthTokenIfRtn)(pModuleConfigIf, &pAuthMechMod->pAuthTokenIf);
retStatus = (pGetAuthTokenIfRtn)(pModuleConfigIf,
DebugLevel,
g_pDebugLogFilePath,
&pAuthMechMod->pAuthTokenIf);
}
else
{
@ -178,7 +181,7 @@ GetAuthTokenIf(
}
// Free the buffer holding the library name
free(pLibraryName);
pModuleConfigIf->freeValueString(pModuleConfigIf, pLibraryName);
}
else
{

View File

@ -629,7 +629,7 @@ AuthRespEndElementHandler(
{
// Convert the lifetime string to a numeric value
pAuthRespParse->pAuthenticateResp->tokenLifetime = dtoul(pAuthRespParse->pLifetimeData,
pAuthRespParse->lifetimeDataLen);
pAuthRespParse->lifetimeDataLen - 1);
// Good, advance to the next state.
pAuthRespParse->state = AWAITING_SESSION_TOKEN_DATA;

View File

@ -48,7 +48,7 @@
#DisableSecureConnections false
#
# AllowInvalidCerts setting.
# AllowUntrustedCerts setting.
#
# Description: Used to specify that the client should ignore
# invalid certificates presented by ATSs when
@ -63,7 +63,7 @@
# process to impersonate an ATS and obtain information that
# is confidential such as username and passwords.
#
AllowInvalidCerts true
AllowUntrustedCerts true
#
# UsersCannotAllowInvalidCerts setting.
@ -96,8 +96,23 @@ AllowInvalidCerts true
# If this parameter is not set, the client defaults
# to use a debug level of zero.
#
# Note: Debug statements can be viewed under Windows by using
# tools such as DbgView. Under Linux, debug statements are logged
# to /var/log/messages.
# Note: Under Linux, debug output is placed in the /ver/log/messages
# file. Under Windoes, debug output is dumped to the debugger console
# unless a folder is specified using the DebugLogFolderPath setting.
# Output sent to the debug console under windows can be viewed by using
# tools such as DbgView.
#
#DebugLevel 0
#
# DebugLogFolderPath setting.
#
# Description: Used to specify a path to a folder to be used for placing debug
# log files under Windows.
#
# If this parameter is not set on windows, the client defaults
# to dumping debug output to the debug console.
#
# Note: The folder specified must exist.
#
#DebugLogFolderPath c:\logfolder

View File

@ -353,6 +353,8 @@ ConfigIf_GetEntryValue(
//
// Returns:
// Pointer to NULL terminated string with value being requested or NULL.
// This NULL terminated string must be free by executing the interface
// object freeValueString method.
//
// Description:
// Gets value associated with a key for the configuration object.
@ -418,6 +420,40 @@ ConfigIf_GetEntryValue(
}
//++=======================================================================
void SSCS_CALL
ConfigIf_FreeValueString(
IN const void *pIfInstance,
IN char *pValueString)
//
// Arguments:
// pIfInstance -
// Pointer to interface object.
//
// pValueString -
// Pointer to NULL terminated string that contains a value
// returned from a call to the interface getEntryValue method.
//
// Returns:
// Nothing.
//
// Description:
// Frees value string returned by calling interface's getEntryValue
// method.
//
// L2
//=======================================================================--
{
ConfigIfInstance *pConfigIfInstance = CONTAINING_RECORD(pIfInstance, ConfigIfInstance, configIf);
DbgTrace(2, "-ConfigIf_FreeValueString- Start\n", 0);
// Free the buffer
free(pValueString);
DbgTrace(2, "-ConfigIf_FreeValueString- End", 0);
}
//++=======================================================================
CasaStatus
@ -516,6 +552,7 @@ GetConfigInterface(
pConfigIfInstance->configIf.addReference = ConfigIf_AddReference;
pConfigIfInstance->configIf.releaseReference = ConfigIf_ReleaseReference;
pConfigIfInstance->configIf.getEntryValue = ConfigIf_GetEntryValue;
pConfigIfInstance->configIf.freeValueString = ConfigIf_FreeValueString;
// Save the ConfigFolder and ConfigName information within the instance data
pConfigIfInstance->pConfigFolder = (char*) malloc(configFolderLen + 1);

View File

@ -47,7 +47,7 @@
//++=======================================================================
typedef
int
(SSCS_CALL *PFNConfiglIf_AddReference)(
(SSCS_CALL *PFNConfigIf_AddReference)(
IN const void *pIfInstance);
//
// Arguments:
@ -65,7 +65,7 @@ int
//++=======================================================================
typedef
void
(SSCS_CALL *PFNConfiglIf_ReleaseReference)(
(SSCS_CALL *PFNConfigIf_ReleaseReference)(
IN const void *pIfInstance);
//
// Arguments:
@ -84,7 +84,7 @@ void
//++=======================================================================
typedef
char*
(SSCS_CALL *PFNConfiglIf_GetEntryValue)(
(SSCS_CALL *PFNConfigIf_GetEntryValue)(
IN const void *pIfInstance,
IN const char *pKeyName);
//
@ -98,20 +98,47 @@ char*
//
// Returns:
// Pointer to NULL terminated string with value being requested or NULL.
// This NULL terminated string must be free by executing the interface
// object freeValueString method.
//
// Description:
// Gets value associated with a key for the configuration object.
//=======================================================================--
//++=======================================================================
typedef
void
(SSCS_CALL *PFNConfigIf_FreeValueString)(
IN const void *pIfInstance,
IN char *pValueString);
//
// Arguments:
// pIfInstance -
// Pointer to interface object.
//
// pValueString -
// Pointer to NULL terminated string that contains a value
// returned from a call to the interface getEntryValue method.
//
// Returns:
// Nothing.
//
// Description:
// Frees value string returned by calling interface's getEntryValue
// method.
//=======================================================================--
//
// Config Interface Object
//
typedef struct _ConfigIf
{
PFNConfiglIf_AddReference addReference;
PFNConfiglIf_ReleaseReference releaseReference;
PFNConfiglIf_GetEntryValue getEntryValue;
PFNConfigIf_AddReference addReference;
PFNConfigIf_ReleaseReference releaseReference;
PFNConfigIf_GetEntryValue getEntryValue;
PFNConfigIf_FreeValueString freeValueString;
} ConfigIf, *PConfigIf;

View File

@ -31,9 +31,7 @@
#define DEFAULT_RETRY_LIFETIME 5 // seconds
#ifndef CASA_STATUS_NAME_RESOLVE_ERROR
#define CASA_STATUS_NAME_RESOLVE_ERROR ((CasaStatus)0x00000024)
#endif
#define LOG_FILE_NAME "\\casaauthtoken.log"
//===[ Function prototypes ]===============================================
@ -43,9 +41,10 @@ InitializeLibrary(void);
//===[ Global variables ]==================================================
//
// Debug tracing level
//
// Debug tracing level and debug log file path.
//
int DebugLevel = 0;
char *g_pDebugLogFilePath = NULL;
//
// Operating parameter
@ -226,8 +225,8 @@ ObtainSessionToken(
CASA_STATUS_INSUFFICIENT_RESOURCES);
}
// Add the entry to the cache if successful or if the reason that we failed
// was because the server was unavailable.
// Add the entry to the cache if the reason that we failed was because
// the server was unavailable.
if (CasaStatusCode(retStatus) == CASA_STATUS_AUTH_SERVER_UNAVAILABLE)
{
pCacheEntry = CreateSessionTokenCacheEntry(pAuthContext->pContext,
@ -298,6 +297,7 @@ CasaStatus
ObtainAuthTokenFromServer(
IN const char *pServiceName,
IN const char *pHostName,
IN const char *pNormalizedHostName,
INOUT char **ppAuthToken,
INOUT int *pTokenLifetime,
IN void *pCredStoreScope)
@ -649,6 +649,7 @@ ObtainAuthTokenInt(
// Cache entry created, now try to obtain auth token from the CASA Server
pToken = NULL;
retStatus = ObtainAuthTokenFromServer(pServiceName,
pHostName,
pNormalizedHostName,
&pToken,
&cacheEntryLifetime,
@ -831,7 +832,9 @@ InitializeLibrary(void)
int getConfigStatus = -1;
ConfigIf *pClientConfigIf;
char *pDebugLevelSetting;
char *pDebugLogFolderPathSetting;
char *pATSPortSetting;
char *pATSHostNameSetting;
char *pDisableSecureConnections;
char *pAllowInvalidCerts;
char *pUsersCannotAllowInvalidCerts;
@ -855,14 +858,50 @@ InitializeLibrary(void)
DebugLevel = (int) dtoul(pDebugLevelSetting, strlen(pDebugLevelSetting));
// Free the buffer holding the debug level
free(pDebugLevelSetting);
pClientConfigIf->freeValueString(pClientConfigIf, pDebugLevelSetting);
}
// Check if a DebugLogFolderPath has been configured
pDebugLogFolderPathSetting = pClientConfigIf->getEntryValue(pClientConfigIf, "DebugLogFolderPath");
if (pDebugLogFolderPathSetting != NULL)
{
DbgTrace(0, "-InitializeLibrary- DebugLogFolderPath configured = %s\n", pDebugLogFolderPathSetting);
// Use the setting to come up with the path to the debug log file
g_pDebugLogFilePath = malloc(strlen(LOG_FILE_NAME) + strlen(pDebugLogFolderPathSetting) + 1);
if (g_pDebugLogFilePath)
{
strcpy(g_pDebugLogFilePath, pDebugLogFolderPathSetting);
strcat(g_pDebugLogFilePath, LOG_FILE_NAME);
}
else
{
DbgTrace(0, "-InitializeLibrary- Failed to allocate buffer for debug file path\n", 0);
}
// Free the buffer holding the debug folder path
pClientConfigIf->freeValueString(pClientConfigIf, pDebugLogFolderPathSetting);
}
// Check if an ATS hostname has been configured
g_pATSHostName = pClientConfigIf->getEntryValue(pClientConfigIf, "ATS-hostname");
if (g_pATSHostName != NULL)
pATSHostNameSetting = pClientConfigIf->getEntryValue(pClientConfigIf, "ATS-hostname");
if (pATSHostNameSetting != NULL)
{
DbgTrace(0, "-InitializeLibrary- ATS hostname configured = %s\n", g_pATSHostName);
DbgTrace(0, "-InitializeLibrary- ATS hostname configured = %s\n", pATSHostNameSetting);
// Remember the ATS host name
g_pATSHostName = malloc(strlen(pATSHostNameSetting) + 1);
if (g_pATSHostName)
{
strcpy(g_pATSHostName, pATSHostNameSetting);
}
else
{
DbgTrace(0, "-InitializeLibrary- Failed to allocate buffer for ATS host name\n", 0);
}
// Free the buffer holding the ats host name setting
pClientConfigIf->freeValueString(pClientConfigIf, pATSHostNameSetting);
}
// Check if the DisableSecureConnections setting has been configured
@ -882,17 +921,17 @@ InitializeLibrary(void)
}
// Free the buffer holding the DisableSecureConnections setting
free(pDisableSecureConnections);
pClientConfigIf->freeValueString(pClientConfigIf, pDisableSecureConnections);
}
// Check the AllowInvalidCerts setting if using secure connections
// Check the AllowUntrustedCerts setting if using secure connections
if (g_rpcFlags & SECURE_RPC_FLAG)
{
// Check if the AllowInvalidCerts setting has been configured
pAllowInvalidCerts = pClientConfigIf->getEntryValue(pClientConfigIf, "AllowInvalidCerts");
// Check if the AllowUntrustedCerts setting has been configured
pAllowInvalidCerts = pClientConfigIf->getEntryValue(pClientConfigIf, "AllowUntrustedCerts");
if (pAllowInvalidCerts != NULL)
{
DbgTrace(0, "-InitializeLibrary- AllowInvalidCerts setting configured = %s\n", pAllowInvalidCerts);
DbgTrace(0, "-InitializeLibrary- AllowUntrustedCerts setting configured = %s\n", pAllowInvalidCerts);
// Adjust the g_rpcFlags variable based on the setting
if (stricmp(pAllowInvalidCerts, "false") == 0)
@ -905,7 +944,7 @@ InitializeLibrary(void)
}
// Free the buffer holding the AllowInvalidCerts setting
free(pAllowInvalidCerts);
pClientConfigIf->freeValueString(pClientConfigIf, pAllowInvalidCerts);
}
// Check the UsersCannotAllowInvalidCerts setting if not allowing invalid certs.
@ -928,7 +967,7 @@ InitializeLibrary(void)
}
// Free the buffer holding the UsersCannotAllowInvalidCerts setting
free(pUsersCannotAllowInvalidCerts);
pClientConfigIf->freeValueString(pClientConfigIf, pUsersCannotAllowInvalidCerts);
}
}
}
@ -943,7 +982,7 @@ InitializeLibrary(void)
g_ATSPort = (int) dtoul(pATSPortSetting, strlen(pATSPortSetting));
// Free the buffer holding the port number
free(pATSPortSetting);
pClientConfigIf->freeValueString(pClientConfigIf, pATSPortSetting);
}
// Release config interface instance
@ -1018,6 +1057,13 @@ UnInitializeLibrary(void)
// Un-initialize the Rpc engine
UnInitializeRpc();
// Free necessary buffers
if (g_pDebugLogFilePath)
free(g_pDebugLogFilePath);
if (g_pATSHostName)
free(g_pATSHostName);
DbgTrace(1, "-UnInitializeLibrary- End\n", 0);
}

View File

@ -124,12 +124,13 @@ typedef struct _AuthCacheEntry
//===[ Global externals ]==================================================
extern int DebugLevel;
extern char *g_pDebugLogFilePath;
extern char clientConfigFolder[];
extern char clientConfigFolder[];
extern char mechConfigFolder[];
extern char mechConfigFolder[];
extern char pathCharString[];
extern char pathCharString[];
//===[ External prototypes ]===============================================

View File

@ -159,12 +159,20 @@ typedef
CasaStatus
(SSCS_CALL *PFN_GetAuthTokenIfRtn)(
IN const ConfigIf *pModuleConfigIf,
IN const int debugLevel,
IN const char *pDebugFilePath,
INOUT AuthTokenIf **ppAuthTokenIf);
//
// Arguments:
// pModuleConfigIf -
// Pointer to configuration interface instance for the module.
//
// debugLevel -
// Level to utilize for debugging, 0 being lowest.
//
// pDebugFilePath -
// Path to debug log file. Can be NULL.
//
// ppAuthTokenIf -
// Pointer to variable that will receive pointer to AuthTokenIf
// instance.

View File

@ -128,12 +128,20 @@ AuthTokenIf_ReleaseReference(
CasaStatus SSCS_CALL
GET_AUTH_TOKEN_INTERFACE_RTN(
IN const ConfigIf *pModuleConfigIf,
IN const int debugLevel,
IN const char *pDebugFilePath,
INOUT AuthTokenIf **ppAuthTokenIf)
//
// Arguments:
// pModuleConfigIf -
// Pointer to configuration interface instance for the module.
//
// debugLevel -
// Level to utilize for debugging, 0 being lowest.
//
// pDebugFilePath -
// Path to debug log file. Can be NULL.
//
// ppAuthTokenIf -
// Pointer to variable that will receive pointer to AuthTokenIf
// instance.
@ -150,6 +158,7 @@ GET_AUTH_TOKEN_INTERFACE_RTN(
CasaStatus retStatus;
AuthTokenIfInstance *pAuthTokenIfInstance;
char *pDebugLevelSetting;
char *pDebugLogFolderPathSetting;
DbgTrace(1, "-GetAuthTokenInterface- Start\n", 0);
@ -165,17 +174,20 @@ GET_AUTH_TOKEN_INTERFACE_RTN(
goto exit;
}
// Check if a DebugLevel has been configured
pDebugLevelSetting = pModuleConfigIf->getEntryValue(pModuleConfigIf, "DebugLevel");
if (pDebugLevelSetting != NULL)
// Save debug parameters
KrbMechDebugLevel = debugLevel;
if (pDebugFilePath)
{
DbgTrace(0, "-GetAuthTokenInterface- DebugLevel configured = %s\n", pDebugLevelSetting);
// Convert the number to hex
DebugLevel = (int) dtoul(pDebugLevelSetting, strlen(pDebugLevelSetting));
// Free the buffer holding the debug level
free(pDebugLevelSetting);
// Use the setting to come up with the path to the debug log file
pKrbMechDebugLogFilePath = malloc(strlen(pDebugFilePath) + 1);
if (pKrbMechDebugLogFilePath)
{
strcpy(pKrbMechDebugLogFilePath, pDebugFilePath);
}
else
{
DbgTrace(0, "-GetAuthTokenInterface- Failed to allocate buffer for debug file path\n", 0);
}
}
// Allocate space for the interface instance

View File

@ -43,7 +43,7 @@
//===[ Global externals ]==================================================
extern int DebugLevel;
extern int KrbMechDebugLevel;
//===[ External prototypes ]===============================================

View File

@ -32,8 +32,9 @@
//===[ Global variables ]==================================================
// Debug Level
int DebugLevel = 0;
// Debug Level and debug log file path.
int KrbMechDebugLevel = 0;
char *pKrbMechDebugLogFilePath = NULL;
// Tables for Base64 encoding and decoding
static const int8_t g_Base64[] =
@ -318,7 +319,6 @@ dtoul(
}
else
{
DbgTrace(0, "-dtoul- Found invalid digit\n", 0);
break;
}
}

View File

@ -14,20 +14,3 @@
# implementing the authentication mechanism.
#
LibraryName \Program Files\novell\casa\lib\krb5mech.dll
#
# DebugLevel setting.
#
# Description: Used to specify the level of logging utilized for debugging
# purposes. A level of zero being the lowest debugging level.
#
# If this parameter is not set, the client defaults
# to use a debug level of zero.
#
# Note: Debug statements can be viewed under Windows by using
# tools such as DbgView. Under Linux, debug statements are logged
# to /var/log/messages.
#
#DebugLevel 0

View File

@ -52,16 +52,28 @@
// printf("Krb5Mech %s", printBuff); \
// } \
//}
#define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \
char printBuff[256]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "Krb5Mech "); \
strncat(formatBuff, X, sizeof(formatBuff) - 9); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
OutputDebugString(printBuff); \
} \
extern char *pKrbMechDebugLogFilePath;
#define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \
char printBuff[256]; \
FILE *pDebugFile; \
if (LEVEL == 0 || KrbMechDebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "Krb5Mech "); \
strncat(formatBuff, X, sizeof(formatBuff) - 9); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
if (pKrbMechDebugLogFilePath) \
{ \
pDebugFile = fopen(pKrbMechDebugLogFilePath, "a+"); \
if (pDebugFile) \
{ \
fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \
fclose(pDebugFile); \
} \
} \
else \
OutputDebugString(printBuff); \
} \
}
#define INT32_MAX (2147483647)

View File

@ -128,11 +128,19 @@ AuthTokenIf_ReleaseReference(
CasaStatus SSCS_CALL
GET_AUTH_TOKEN_INTERFACE_RTN(
IN const ConfigIf *pModuleConfigIf,
IN const int debugLevel,
IN const char *pDebugFilePath,
INOUT AuthTokenIf **ppAuthTokenIf)
//
// Arguments:
// pModuleConfigIf -
// Pointer to configuration interface instance for the module.
//
// debugLevel -
// Level to utilize for debugging, 0 being lowest.
//
// pDebugFilePath -
// Path to debug log file. Can be NULL.
//
// ppAuthTokenIf -
// Pointer to variable that will receive pointer to AuthTokenIf
@ -150,6 +158,7 @@ GET_AUTH_TOKEN_INTERFACE_RTN(
CasaStatus retStatus;
AuthTokenIfInstance *pAuthTokenIfInstance;
char *pDebugLevelSetting;
char *pDebugLogFolderPathSetting;
DbgTrace(1, "-GetAuthTokenInterface- Start\n", 0);
@ -165,17 +174,20 @@ GET_AUTH_TOKEN_INTERFACE_RTN(
goto exit;
}
// Check if a DebugLevel has been configured
pDebugLevelSetting = pModuleConfigIf->getEntryValue(pModuleConfigIf, "DebugLevel");
if (pDebugLevelSetting != NULL)
// Save debug parameters
PwdMechDebugLevel = debugLevel;
if (pDebugFilePath)
{
DbgTrace(0, "-GetAuthTokenInterface- DebugLevel configured = %s\n", pDebugLevelSetting);
// Convert the number to hex
DebugLevel = (int) dtoul(pDebugLevelSetting, strlen(pDebugLevelSetting));
// Free the buffer holding the debug level
free(pDebugLevelSetting);
// Use the setting to come up with the path to the debug log file
pPwdMechDebugLogFilePath = malloc(strlen(pDebugFilePath) + 1);
if (pPwdMechDebugLogFilePath)
{
strcpy(pPwdMechDebugLogFilePath, pDebugFilePath);
}
else
{
DbgTrace(0, "-GetAuthTokenInterface- Failed to allocate buffer for debug file path\n", 0);
}
}
// Allocate space for the interface instance

View File

@ -45,7 +45,7 @@
//===[ Global externals ]==================================================
extern int DebugLevel;
extern int PwdMechDebugLevel;
//===[ External prototypes ]===============================================

View File

@ -32,8 +32,9 @@
//===[ Global variables ]==================================================
// Debug Level
int DebugLevel = 0;
// Debug Level and debug log file path.
int PwdMechDebugLevel = 0;
char *pPwdMechDebugLogFilePath = NULL;
// Tables for Base64 encoding and decoding
static const int8_t g_Base64[] =
@ -318,7 +319,6 @@ dtoul(
}
else
{
DbgTrace(0, "-dtoul- Found invalid digit\n", 0);
break;
}
}

View File

@ -14,19 +14,3 @@
# implementing the authentication mechanism.
#
LibraryName \Program Files\novell\casa\lib\pwmech.dll
#
# DebugLevel setting.
#
# Description: Used to specify the level of logging utilized for debugging
# purposes. A level of zero being the lowest debugging level.
#
# If this parameter is not set, the client defaults
# to use a debug level of zero.
#
# Note: Debug statements can be viewed under Windows by using
# tools such as DbgView. Under Linux, debug statements are logged
# to /var/log/messages.
#
#DebugLevel 0

View File

@ -50,16 +50,28 @@
// printf("PwdMech %s", printBuff); \
// } \
//}
#define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \
char printBuff[256]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "CASA_PwdMech "); \
strncat(formatBuff, X, sizeof(formatBuff) - 8); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
OutputDebugString(printBuff); \
} \
extern char *pPwdMechDebugLogFilePath;
#define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \
char printBuff[256]; \
FILE *pDebugFile; \
if (LEVEL == 0 || PwdMechDebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "CASA_PwdMech "); \
strncat(formatBuff, X, sizeof(formatBuff) - 8); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
if (pPwdMechDebugLogFilePath) \
{ \
pDebugFile = fopen(pPwdMechDebugLogFilePath, "a+"); \
if (pDebugFile) \
{ \
fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \
fclose(pDebugFile); \
} \
} \
else \
OutputDebugString(printBuff); \
} \
}
#define INT32_MAX (2147483647)

View File

@ -315,7 +315,6 @@ dtoul(
}
else
{
DbgTrace(0, "-dtoul- Found invalid digit\n", 0);
break;
}
}

View File

@ -705,7 +705,7 @@ UnInitializeHostNameNormalization(void)
hostNameNormalizationInitialized = FALSE;
}
DbgTrace(1, "-UnInitializeHostNameNormalization- End", 0);
DbgTrace(1, "-UnInitializeHostNameNormalization- End\n", 0);
}

View File

@ -49,19 +49,30 @@
// if (LEVEL == 0 || DebugLevel >= LEVEL) \
// { \
// _snprintf(printBuff, sizeof(printBuff), X, Y); \
// printf("CASA_AuthToken %s", printBuff); \
// printf("CASA_AuthToken %s", printBuff); \
// } \
//}
#define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \
char printBuff[256]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "CASA_AuthToken "); \
strncat(formatBuff, X, sizeof(formatBuff) - 10); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
OutputDebugString(printBuff); \
} \
#define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \
char printBuff[256]; \
FILE *pDebugFile; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \
{ \
strcpy(formatBuff, "CASA_AuthToken "); \
strncat(formatBuff, X, sizeof(formatBuff) - 10); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \
if (g_pDebugLogFilePath) \
{ \
pDebugFile = fopen(g_pDebugLogFilePath, "a+"); \
if (pDebugFile) \
{ \
fwrite(printBuff, strlen(printBuff), 1, pDebugFile); \
fclose(pDebugFile); \
} \
} \
else \
OutputDebugString(printBuff); \
} \
}
//

View File

@ -171,6 +171,8 @@ OpenRpcSession(
bool success = false;
DbgTrace(1, "-OpenRpcSession- Start\n", 0);
DbgTrace(2, "-OpenRpcSession- Host = %s\n", pHostName);
DbgTrace(2, "-OpenRpcSession- HostPort = %d\n", hostPort);
// Allocate space for the session
pSession = (RpcSession*) malloc(sizeof(*pSession));
@ -358,10 +360,6 @@ InternalRpc(
{
#define RPC_TARGET_FMT_STRING "CasaAuthTokenSvc/Rpc?method=%s"
#ifndef CASA_STATUS_INVALID_SERVER_CERTIFICATE
#define CASA_STATUS_INVALID_SERVER_CERTIFICATE ((CasaStatus)0x00000023)
#endif
CasaStatus retStatus = CASA_STATUS_SUCCESS;
char *pRpcTarget;
LPWSTR pWideRpcTarget;