This commit is contained in:
Manohar 2006-03-06 09:54:36 +00:00
parent d01ef968e0
commit 0bc1f679e4
5 changed files with 78 additions and 83 deletions

View File

@ -331,6 +331,7 @@ int CryptManager::CryptPK11EncryptString(char *clearData, int clearDataLen, char
{
// since we have specified password callback function , we won't come here...
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11_Authenticate failed, possibly master password is wrong");
(*PK11FreeSlot) (slot);
return FPM_MASTERPASSWORD_WRONG;
}
@ -348,6 +349,7 @@ int CryptManager::CryptPK11EncryptString(char *clearData, int clearDataLen, char
if (status != SECSuccess)
{
PrintMessage(MESG_ERROR, "\n CryptPK11EncryptString : PK11SDR_Encrypt failed ...");
(*PK11FreeSlot) (slot);
return FPM_FALSE;
}
@ -355,6 +357,7 @@ int CryptManager::CryptPK11EncryptString(char *clearData, int clearDataLen, char
*cryptData = (char*)reply.data;
*cryptDataLen = reply.len;
(*PK11FreeSlot) (slot);
return FPM_TRUE;
}
@ -396,6 +399,7 @@ int CryptManager::CryptPK11DecryptString(char *decodeData, int decodeLen, char *
{
// since we have specified password callback function , we won't come here...
PrintMessage(MESG_ERROR, "\n PK11_Authenticate failed, Probably master password is wrong");
(*PK11FreeSlot) (slot);
return FPM_MASTERPASSWORD_WRONG;
}
@ -414,6 +418,7 @@ int CryptManager::CryptPK11DecryptString(char *decodeData, int decodeLen, char *
if (status != SECSuccess)
{
PrintMessage(MESG_ERROR, "\n PK11SDR_Decrypt failed ...");
(*PK11FreeSlot) (slot);
return FPM_FALSE;
}

View File

@ -187,7 +187,7 @@ extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFl
strcpy(profList[profileCount],temp);
profFlag[profileCount] = 0;
PrintMessage(MESG_ERROR, "\n GetProfileList : Found profile = [%s]", profList[profileCount]);
PrintMessage(MESG_DEBUG, "\n GetProfileList : Found profile = [%s]", profList[profileCount]);
profileCount++;
continue;
}
@ -219,52 +219,53 @@ extern "C" APIEXPORT int FPM_GetProfileList(char **profileList[], int *profileFl
extern "C" APIEXPORT int FPM_FirefoxProfileInit(char *profileName)
{
int retValue;
int profileIndex = -1;
int isObjectExist = FPM_FALSE;
// check if the profile is already initialized...
int profileIndex = -1;
// Check if the object for specified profile already present...
for(int i=0; i< profileCount; i++)
{
if( profileManager[i].profileName != NULL )
{
if( STRCMPI(profileManager[i].profileName, profileName) == 0 )
{
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Specified profile object [%s] is already present ", profileName);
profileIndex = i;
isObjectExist = FPM_TRUE;
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Object for specified profile %s exist ", profileName);
profileIndex = i;
break;
}
}
}
// This is new profile...
if( (profileIndex == -1) && ( (profileCount + 1) >= MAX_PROFILE_COUNT) )
if( profileIndex == -1)
{
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Max profile count exceeded.");
return FPM_PROFILE_LIMIT_EXCEEDED;
}
if(profileIndex == -1 )
{
profileIndex = profileCount;
profileCount++;
}
// If not already initialized then go and initialize it...
if( profileManager[profileIndex].isInitialized == FPM_FALSE )
{
if( (retValue = profileManager[profileIndex].ProfileInit(profileName)) != FPM_TRUE )
if( (profileCount + 1) >= MAX_PROFILE_COUNT)
{
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Failed to initialize the profile %s ", profileName);
return retValue;
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Max profile count exceeded.");
return FPM_PROFILE_LIMIT_EXCEEDED;
}
}
else
{
PrintMessage(MESG_DEBUG, "\n FirefoxProfileInit : Firefox profile %s is already initialized ", profileName);
return FPM_TRUE;
profileIndex = profileCount;
profileCount++;
}
// check if the profile is already initialized...
if( profileManager[profileIndex].isInitialized == FPM_TRUE )
{
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Specified profile %s is already initialized", profileName);
return FPM_TRUE;
}
if( (retValue = profileManager[profileIndex].ProfileInit(profileName)) != FPM_TRUE )
{
PrintMessage(MESG_ERROR, "\n FirefoxProfileInit : Failed to initialize the profile %s ", profileName);
return retValue;
}
PrintMessage(MESG_DEBUG, "\n FirefoxProfileInit : Firefox profile %s initialized successfully ", profileName);
return FPM_TRUE;
}

View File

@ -59,7 +59,7 @@
#define MAX_PROFILE_COUNT 5
#define DEBUG 11
//#define DEBUG 11
#define Unichar unsigned int

View File

@ -381,7 +381,7 @@ HMODULE libtmp = NULL;
if( !libtmp )
{
PrintMessage(MESG_ERROR, "\n\n LoadLibrary : Failed to load library %s ", loadPath);
PrintMessage(MESG_DEBUG, "\n\n LoadLibrary : Failed to load library %s ", loadPath);
free(loadPath);
return 0;
}
@ -454,7 +454,7 @@ int ProfileManager::ProfileInit(char *profileName)
if( !libnss || !libplc )
{
PrintMessage(MESG_ERROR, "\n ProfileInit : Failed to load the required library from directory %s", libraryPath);
PrintMessage(MESG_ERROR, "\n ProfileInit : Failed to load the required firefox library");
return FPM_LIBRARY_LOAD_FAILED;
}
@ -543,16 +543,40 @@ int ProfileManager::ProfileInit(char *profileName)
void ProfileManager::ProfileExit()
{
int i;
PrintMessage(MESG_DEBUG, "\n ProfileExit : Shutting down the profile %s", profileName);
if( (isInitialized == FPM_TRUE) && NSSShutdown != NULL )
(*NSSShutdown)();
{
PrintMessage(MESG_DEBUG, "\n ProfileExit : invoking NSSShutdown for profile", profileName);
for(i=0; (i<5) && ((*NSSShutdown)() == SECFailure); i++ )
{
PrintMessage(MESG_DEBUG, "\n ProfileExit %d: NSSShutdown : FAILURE",i);
//Sleep(500);
}
if( i != 5)
{
PrintMessage(MESG_DEBUG, "\n ProfileExit :NSSShutdown : SUCCESS");
}
else
PrintMessage(MESG_DEBUG, "\n ProfileExit : NSSShutdown : FAILURE");
}
if( libnss != NULL )
{
PrintMessage(MESG_DEBUG, "\n ProfileExit : Freeing library libnss.dll");
FREELIBRARY(libnss);
}
if( libplc != NULL )
{
PrintMessage(MESG_DEBUG, "\n ProfileExit : Freeing library libplc.dll");
FREELIBRARY(libplc);
}
// clean up signon data...
signonManager.RemoveSignonData();
@ -569,6 +593,7 @@ int ProfileManager::IsMasterPasswordSet()
{
PK11SlotInfo *slot = 0;
int retValue = 0;
SECStatus status;
slot = (*PK11GetInternalKeySlot)();
@ -581,16 +606,23 @@ int retValue = 0;
PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ...");
// Check with empty password....If it succeeds then master password is not set
if( (*PK11CheckUserPassword)(slot,"") == SECSuccess )
status = (*PK11CheckUserPassword)(slot,"");
if( status == SECSuccess )
{
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is not set...");
retValue = FPM_FALSE;
}
else
{
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is set...");
retValue = FPM_TRUE;
}
else if(status == SECWouldBlock ) // password is wrong
{
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is set...");
retValue = FPM_TRUE;
}
else // something is wrong, may be key3.db is not initialized for crypt
{
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is not set...");
retValue = FPM_FALSE;
}
// Free the slot
(*PK11FreeSlot) (slot);

View File

@ -603,48 +603,5 @@ struct Host * SignonManager::GetHostInfo()
}
int SignonManager::AddUser(char *host, char *userName, char *password)
{
char checkString[]="test123";
char *cryptData = NULL;
char *clearData = NULL;
char *newdata = NULL;
/*
// TODO : check if signon preference enabled....
if( CheckSignonPref() == FPM_FALSE )
{
PrintMessage(MESG_ERROR, "\n MCSignonManager : Signon preference is not enabled...");
return FPM_FALSE;
}
if( EncryptString ("test123", &cryptData) == FPM_FALSE )
{
PrintMessage(MESG_ERROR, "\n MCSignonManager : fAILED TO EncryptString");
return FPM_FALSE;
}
newdata = (char*) malloc(strlen(cryptData) + 1);
strcpy(newdata, cryptData);
if( DecryptString(newdata, &clearData) == FPM_FALSE )
{
PrintMessage(MESG_ERROR, "\n MCSignonManager : Failed to DecryptString");
return FPM_FALSE;
}
printf("\n final decrypted string is : %s ", clearData);
if( strcmp(checkString, clearData) == 0 )
{
printf("\n Encryption - decryption test is success ");
}
else
printf("\n Encryption - decryption test is FAILED ");
*/
return FPM_TRUE;
}