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

View File

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

View File

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

View File

@ -381,7 +381,7 @@ HMODULE libtmp = NULL;
if( !libtmp ) 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); free(loadPath);
return 0; return 0;
} }
@ -454,7 +454,7 @@ int ProfileManager::ProfileInit(char *profileName)
if( !libnss || !libplc ) 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; return FPM_LIBRARY_LOAD_FAILED;
} }
@ -543,16 +543,40 @@ int ProfileManager::ProfileInit(char *profileName)
void ProfileManager::ProfileExit() void ProfileManager::ProfileExit()
{ {
int i;
PrintMessage(MESG_DEBUG, "\n ProfileExit : Shutting down the profile %s", profileName); PrintMessage(MESG_DEBUG, "\n ProfileExit : Shutting down the profile %s", profileName);
if( (isInitialized == FPM_TRUE) && NSSShutdown != NULL ) 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 ) if( libnss != NULL )
{
PrintMessage(MESG_DEBUG, "\n ProfileExit : Freeing library libnss.dll");
FREELIBRARY(libnss); FREELIBRARY(libnss);
}
if( libplc != NULL ) if( libplc != NULL )
{
PrintMessage(MESG_DEBUG, "\n ProfileExit : Freeing library libplc.dll");
FREELIBRARY(libplc); FREELIBRARY(libplc);
}
// clean up signon data... // clean up signon data...
signonManager.RemoveSignonData(); signonManager.RemoveSignonData();
@ -569,6 +593,7 @@ int ProfileManager::IsMasterPasswordSet()
{ {
PK11SlotInfo *slot = 0; PK11SlotInfo *slot = 0;
int retValue = 0; int retValue = 0;
SECStatus status;
slot = (*PK11GetInternalKeySlot)(); slot = (*PK11GetInternalKeySlot)();
@ -581,16 +606,23 @@ int retValue = 0;
PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ..."); PrintMessage(MESG_DEBUG, "\n PK11_GetInternalKeySlot SUCCESS ...");
// Check with empty password....If it succeeds then master password is not set // 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..."); PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is not set...");
retValue = FPM_FALSE; retValue = FPM_FALSE;
} }
else else if(status == SECWouldBlock ) // password is wrong
{ {
PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is set..."); PrintMessage(MESG_DEBUG, "\n IsMasterPasswordSet : Master password is set...");
retValue = FPM_TRUE; 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 // Free the slot
(*PK11FreeSlot) (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;
}