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

View File

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

View File

@ -48,7 +48,7 @@
#DisableSecureConnections false #DisableSecureConnections false
# #
# AllowInvalidCerts setting. # AllowUntrustedCerts setting.
# #
# Description: Used to specify that the client should ignore # Description: Used to specify that the client should ignore
# invalid certificates presented by ATSs when # invalid certificates presented by ATSs when
@ -63,7 +63,7 @@
# process to impersonate an ATS and obtain information that # process to impersonate an ATS and obtain information that
# is confidential such as username and passwords. # is confidential such as username and passwords.
# #
AllowInvalidCerts true AllowUntrustedCerts true
# #
# UsersCannotAllowInvalidCerts setting. # UsersCannotAllowInvalidCerts setting.
@ -96,8 +96,23 @@ AllowInvalidCerts true
# If this parameter is not set, the client defaults # If this parameter is not set, the client defaults
# to use a debug level of zero. # to use a debug level of zero.
# #
# Note: Debug statements can be viewed under Windows by using # Note: Under Linux, debug output is placed in the /ver/log/messages
# tools such as DbgView. Under Linux, debug statements are logged # file. Under Windoes, debug output is dumped to the debugger console
# to /var/log/messages. # 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 #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: // Returns:
// Pointer to NULL terminated string with value being requested or NULL. // 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: // Description:
// Gets value associated with a key for the configuration object. // 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 CasaStatus
@ -516,6 +552,7 @@ GetConfigInterface(
pConfigIfInstance->configIf.addReference = ConfigIf_AddReference; pConfigIfInstance->configIf.addReference = ConfigIf_AddReference;
pConfigIfInstance->configIf.releaseReference = ConfigIf_ReleaseReference; pConfigIfInstance->configIf.releaseReference = ConfigIf_ReleaseReference;
pConfigIfInstance->configIf.getEntryValue = ConfigIf_GetEntryValue; pConfigIfInstance->configIf.getEntryValue = ConfigIf_GetEntryValue;
pConfigIfInstance->configIf.freeValueString = ConfigIf_FreeValueString;
// Save the ConfigFolder and ConfigName information within the instance data // Save the ConfigFolder and ConfigName information within the instance data
pConfigIfInstance->pConfigFolder = (char*) malloc(configFolderLen + 1); pConfigIfInstance->pConfigFolder = (char*) malloc(configFolderLen + 1);

View File

@ -47,7 +47,7 @@
//++======================================================================= //++=======================================================================
typedef typedef
int int
(SSCS_CALL *PFNConfiglIf_AddReference)( (SSCS_CALL *PFNConfigIf_AddReference)(
IN const void *pIfInstance); IN const void *pIfInstance);
// //
// Arguments: // Arguments:
@ -65,7 +65,7 @@ int
//++======================================================================= //++=======================================================================
typedef typedef
void void
(SSCS_CALL *PFNConfiglIf_ReleaseReference)( (SSCS_CALL *PFNConfigIf_ReleaseReference)(
IN const void *pIfInstance); IN const void *pIfInstance);
// //
// Arguments: // Arguments:
@ -84,7 +84,7 @@ void
//++======================================================================= //++=======================================================================
typedef typedef
char* char*
(SSCS_CALL *PFNConfiglIf_GetEntryValue)( (SSCS_CALL *PFNConfigIf_GetEntryValue)(
IN const void *pIfInstance, IN const void *pIfInstance,
IN const char *pKeyName); IN const char *pKeyName);
// //
@ -98,20 +98,47 @@ char*
// //
// Returns: // Returns:
// Pointer to NULL terminated string with value being requested or NULL. // 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: // Description:
// Gets value associated with a key for the configuration object. // 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 // Config Interface Object
// //
typedef struct _ConfigIf typedef struct _ConfigIf
{ {
PFNConfiglIf_AddReference addReference; PFNConfigIf_AddReference addReference;
PFNConfiglIf_ReleaseReference releaseReference; PFNConfigIf_ReleaseReference releaseReference;
PFNConfiglIf_GetEntryValue getEntryValue; PFNConfigIf_GetEntryValue getEntryValue;
PFNConfigIf_FreeValueString freeValueString;
} ConfigIf, *PConfigIf; } ConfigIf, *PConfigIf;

View File

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

View File

@ -124,12 +124,13 @@ typedef struct _AuthCacheEntry
//===[ Global externals ]================================================== //===[ Global externals ]==================================================
extern int DebugLevel; 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 ]=============================================== //===[ External prototypes ]===============================================

View File

@ -159,12 +159,20 @@ typedef
CasaStatus CasaStatus
(SSCS_CALL *PFN_GetAuthTokenIfRtn)( (SSCS_CALL *PFN_GetAuthTokenIfRtn)(
IN const ConfigIf *pModuleConfigIf, IN const ConfigIf *pModuleConfigIf,
IN const int debugLevel,
IN const char *pDebugFilePath,
INOUT AuthTokenIf **ppAuthTokenIf); INOUT AuthTokenIf **ppAuthTokenIf);
// //
// Arguments: // Arguments:
// pModuleConfigIf - // pModuleConfigIf -
// Pointer to configuration interface instance for the module. // 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 - // ppAuthTokenIf -
// Pointer to variable that will receive pointer to AuthTokenIf // Pointer to variable that will receive pointer to AuthTokenIf
// instance. // instance.

View File

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

View File

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

View File

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

View File

@ -14,20 +14,3 @@
# implementing the authentication mechanism. # implementing the authentication mechanism.
# #
LibraryName \Program Files\novell\casa\lib\krb5mech.dll 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); \ // printf("Krb5Mech %s", printBuff); \
// } \ // } \
//} //}
#define DbgTrace(LEVEL, X, Y) { \ extern char *pKrbMechDebugLogFilePath;
char formatBuff[128]; \ #define DbgTrace(LEVEL, X, Y) { \
char printBuff[256]; \ char formatBuff[128]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \ char printBuff[256]; \
{ \ FILE *pDebugFile; \
strcpy(formatBuff, "Krb5Mech "); \ if (LEVEL == 0 || KrbMechDebugLevel >= LEVEL) \
strncat(formatBuff, X, sizeof(formatBuff) - 9); \ { \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ strcpy(formatBuff, "Krb5Mech "); \
OutputDebugString(printBuff); \ 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) #define INT32_MAX (2147483647)

View File

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

View File

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

View File

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

View File

@ -14,19 +14,3 @@
# implementing the authentication mechanism. # implementing the authentication mechanism.
# #
LibraryName \Program Files\novell\casa\lib\pwmech.dll 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); \ // printf("PwdMech %s", printBuff); \
// } \ // } \
//} //}
#define DbgTrace(LEVEL, X, Y) { \ extern char *pPwdMechDebugLogFilePath;
char formatBuff[128]; \ #define DbgTrace(LEVEL, X, Y) { \
char printBuff[256]; \ char formatBuff[128]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \ char printBuff[256]; \
{ \ FILE *pDebugFile; \
strcpy(formatBuff, "CASA_PwdMech "); \ if (LEVEL == 0 || PwdMechDebugLevel >= LEVEL) \
strncat(formatBuff, X, sizeof(formatBuff) - 8); \ { \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ strcpy(formatBuff, "CASA_PwdMech "); \
OutputDebugString(printBuff); \ 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) #define INT32_MAX (2147483647)

View File

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

View File

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

View File

@ -49,19 +49,30 @@
// if (LEVEL == 0 || DebugLevel >= LEVEL) \ // if (LEVEL == 0 || DebugLevel >= LEVEL) \
// { \ // { \
// _snprintf(printBuff, sizeof(printBuff), X, Y); \ // _snprintf(printBuff, sizeof(printBuff), X, Y); \
// printf("CASA_AuthToken %s", printBuff); \ // printf("CASA_AuthToken %s", printBuff); \
// } \ // } \
//} //}
#define DbgTrace(LEVEL, X, Y) { \ #define DbgTrace(LEVEL, X, Y) { \
char formatBuff[128]; \ char formatBuff[128]; \
char printBuff[256]; \ char printBuff[256]; \
if (LEVEL == 0 || DebugLevel >= LEVEL) \ FILE *pDebugFile; \
{ \ if (LEVEL == 0 || DebugLevel >= LEVEL) \
strcpy(formatBuff, "CASA_AuthToken "); \ { \
strncat(formatBuff, X, sizeof(formatBuff) - 10); \ strcpy(formatBuff, "CASA_AuthToken "); \
_snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ strncat(formatBuff, X, sizeof(formatBuff) - 10); \
OutputDebugString(printBuff); \ _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; bool success = false;
DbgTrace(1, "-OpenRpcSession- Start\n", 0); 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 // Allocate space for the session
pSession = (RpcSession*) malloc(sizeof(*pSession)); pSession = (RpcSession*) malloc(sizeof(*pSession));
@ -358,10 +360,6 @@ InternalRpc(
{ {
#define RPC_TARGET_FMT_STRING "CasaAuthTokenSvc/Rpc?method=%s" #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; CasaStatus retStatus = CASA_STATUS_SUCCESS;
char *pRpcTarget; char *pRpcTarget;
LPWSTR pWideRpcTarget; LPWSTR pWideRpcTarget;