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:
@@ -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
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
//===[ Global externals ]==================================================
|
||||
|
||||
extern int DebugLevel;
|
||||
extern int KrbMechDebugLevel;
|
||||
|
||||
//===[ External prototypes ]===============================================
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
//===[ Global externals ]==================================================
|
||||
|
||||
extern int DebugLevel;
|
||||
extern int PwdMechDebugLevel;
|
||||
|
||||
//===[ External prototypes ]===============================================
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user