If the user has not set a master password and wants to use password manager, initialize the master password to an empty string. (bug 217409)

This commit is contained in:
bryner%brianryner.com 2003-08-28 05:22:23 +00:00
Родитель 65f3ecbf09
Коммит 04471c7890
2 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -59,6 +59,7 @@ REQUIRES = \
content \
widget \
autocomplete \
pipnss \
$(NULL)
XPIDLSRCS = nsIPassword.idl

Просмотреть файл

@ -69,6 +69,8 @@
#include "nsIDOMEventTarget.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIAutoCompleteResult.h"
#include "nsIPK11TokenDB.h"
#include "nsIPK11Token.h"
static const char kPMPropertiesURL[] = "chrome://passwordmgr/locale/passwordmgr.properties";
static PRBool sRememberPasswords = PR_FALSE;
@ -1519,8 +1521,25 @@ nsPasswordManager::EncryptDataUCS2(const nsAString& aPlaintext,
/* static */ void
nsPasswordManager::EnsureDecoderRing()
{
if (!sDecoderRing)
if (!sDecoderRing) {
CallGetService("@mozilla.org/security/sdr;1", &sDecoderRing);
// Ensure that the master password (internal key) has been initialized.
// If not, set a default empty master password.
nsCOMPtr<nsIPK11TokenDB> tokenDB = do_GetService(NS_PK11TOKENDB_CONTRACTID);
if (!tokenDB)
return;
nsCOMPtr<nsIPK11Token> token;
tokenDB->GetInternalKeyToken(getter_AddRefs(token));
PRBool needUserInit = PR_FALSE;
token->GetNeedsUserInit(&needUserInit);
if (needUserInit)
token->InitPassword(NS_LITERAL_STRING("").get());
}
}
nsresult