mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 12:54:26 -04:00
sorted out the mess with various calls to clear/cache PGP passphrase that resulted in the passphrase staying in memory
This commit is contained in:
parent
3ee9408c00
commit
d7fbe29a56
4 changed files with 43 additions and 26 deletions
|
@ -1927,20 +1927,26 @@ RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin(const RsPeerId& accoun
|
||||||
{
|
{
|
||||||
if(isLoggedIn()) return RsInit::ERR_ALREADY_RUNNING;
|
if(isLoggedIn()) return RsInit::ERR_ALREADY_RUNNING;
|
||||||
|
|
||||||
if(!password.empty())
|
{
|
||||||
{
|
if(!RsAccounts::SelectAccount(account))
|
||||||
if(!rsNotify->cachePgpPassphrase(password)) return RsInit::ERR_UNKNOWN;
|
return RsInit::ERR_UNKNOWN;
|
||||||
if(!rsNotify->setDisableAskPassword(true)) return RsInit::ERR_UNKNOWN;
|
|
||||||
}
|
|
||||||
if(!RsAccounts::SelectAccount(account)) return RsInit::ERR_UNKNOWN;
|
|
||||||
std::string _ignore_lockFilePath;
|
|
||||||
RsInit::LoadCertificateStatus ret = RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath);
|
|
||||||
|
|
||||||
if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKNOWN;
|
if(!password.empty())
|
||||||
if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKNOWN;
|
{
|
||||||
if(ret != RsInit::OK) return ret;
|
rsNotify->cachePgpPassphrase(password);
|
||||||
if(RsControl::instance()->StartupRetroShare() == 1) return RsInit::OK;
|
rsNotify->setDisableAskPassword(true);
|
||||||
return RsInit::ERR_UNKNOWN;
|
}
|
||||||
|
std::string _ignore_lockFilePath;
|
||||||
|
RsInit::LoadCertificateStatus ret = RsInit::LockAndLoadCertificates(false, _ignore_lockFilePath);
|
||||||
|
|
||||||
|
rsNotify->setDisableAskPassword(false) ;
|
||||||
|
rsNotify->clearPgpPassphrase() ;
|
||||||
|
|
||||||
|
if(ret == RsInit::OK && RsControl::instance()->StartupRetroShare() == 1)
|
||||||
|
return RsInit::OK;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ bool RsLoginHelper::collectEntropy(uint32_t bytes)
|
/*static*/ bool RsLoginHelper::collectEntropy(uint32_t bytes)
|
||||||
|
|
|
@ -636,9 +636,6 @@ void GenCertDialog::genPerson()
|
||||||
|
|
||||||
setCursor(Qt::ArrowCursor) ;
|
setCursor(Qt::ArrowCursor) ;
|
||||||
}
|
}
|
||||||
// now cache the PGP password so that it's not asked again for immediately signing the key
|
|
||||||
rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ;
|
|
||||||
|
|
||||||
//generate a random ssl password
|
//generate a random ssl password
|
||||||
std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ;
|
std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ;
|
||||||
|
|
||||||
|
@ -650,7 +647,11 @@ void GenCertDialog::genPerson()
|
||||||
std::string err;
|
std::string err;
|
||||||
this->hide();//To show dialog asking password PGP Key.
|
this->hide();//To show dialog asking password PGP Key.
|
||||||
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
||||||
bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err);
|
|
||||||
|
// now cache the PGP password so that it's not asked again for immediately signing the key
|
||||||
|
rsNotify->cachePgpPassphrase(ui.password_input->text().toUtf8().constData()) ;
|
||||||
|
|
||||||
|
bool okGen = RsAccounts::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, isAutoTor, sslPasswd, sslId, err);
|
||||||
|
|
||||||
if (okGen)
|
if (okGen)
|
||||||
{
|
{
|
||||||
|
@ -658,16 +659,23 @@ void GenCertDialog::genPerson()
|
||||||
RsInit::LoadPassword(sslPasswd);
|
RsInit::LoadPassword(sslPasswd);
|
||||||
if (Rshare::loadCertificate(sslId, false)) {
|
if (Rshare::loadCertificate(sslId, false)) {
|
||||||
|
|
||||||
accept();
|
// Now clear the cached passphrase
|
||||||
|
rsNotify->clearPgpPassphrase();
|
||||||
|
|
||||||
|
accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Message Dialog */
|
// Now clear the cached passphrase
|
||||||
QMessageBox::warning(this,
|
rsNotify->clearPgpPassphrase();
|
||||||
tr("Profile generation failure"),
|
|
||||||
tr("Failed to generate your new certificate, maybe PGP password is wrong!"),
|
/* Message Dialog */
|
||||||
QMessageBox::Ok);
|
QMessageBox::warning(this,
|
||||||
reject();
|
tr("Profile generation failure"),
|
||||||
}
|
tr("Failed to generate your new certificate, maybe PGP password is wrong!"),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
|
||||||
|
reject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,6 +549,8 @@ void IdEditDialog::createId()
|
||||||
std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId());
|
std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId());
|
||||||
bool cancelled;
|
bool cancelled;
|
||||||
|
|
||||||
|
rsNotify->clearPgpPassphrase(); // just in case
|
||||||
|
|
||||||
if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(),
|
if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(),
|
||||||
gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")",
|
gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")",
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -126,6 +126,7 @@ void StartDialog::loadPerson()
|
||||||
bool res = Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ;
|
bool res = Rshare::loadCertificate(accountId, ui.autologin_checkbox->isChecked()) ;
|
||||||
|
|
||||||
rsNotify->setDisableAskPassword(false);
|
rsNotify->setDisableAskPassword(false);
|
||||||
|
rsNotify->clearPgpPassphrase();
|
||||||
|
|
||||||
if(res)
|
if(res)
|
||||||
accept();
|
accept();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue