mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 06:35:08 -04:00
added pgp passphrase temporary caching in order to avoid re-asking for password at location creation time
This commit is contained in:
parent
f3824f2348
commit
ccacba797f
5 changed files with 45 additions and 1 deletions
|
@ -245,8 +245,37 @@ void p3Notify::notifyDownloadComplete (const std::string& fileHash )
|
||||||
void p3Notify::notifyDownloadCompleteCount (uint32_t count ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDownloadCompleteCount (count) ; }
|
void p3Notify::notifyDownloadCompleteCount (uint32_t count ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDownloadCompleteCount (count) ; }
|
||||||
void p3Notify::notifyHistoryChanged (uint32_t msgId , int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyHistoryChanged (msgId,type) ; }
|
void p3Notify::notifyHistoryChanged (uint32_t msgId , int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyHistoryChanged (msgId,type) ; }
|
||||||
|
|
||||||
|
bool p3Notify::cachePgpPassphrase(const std::string& s)
|
||||||
|
{
|
||||||
|
clearPgpPassphrase() ;
|
||||||
|
cached_pgp_passphrase = s ;
|
||||||
|
|
||||||
|
std::cerr << "(WW) Caching PGP passphrase." << std::endl;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
bool p3Notify::clearPgpPassphrase()
|
||||||
|
{
|
||||||
|
std::cerr << "(WW) Clearing PGP passphrase." << std::endl;
|
||||||
|
|
||||||
|
// Just whipe out the memory instead of just releasing it.
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<cached_pgp_passphrase.length();++i)
|
||||||
|
cached_pgp_passphrase[i] = 0 ;
|
||||||
|
|
||||||
|
cached_pgp_passphrase.clear();
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3Notify::askForPassword (const std::string& title , const std::string& key_details , bool prev_is_bad , std::string& password,bool *cancelled)
|
bool p3Notify::askForPassword (const std::string& title , const std::string& key_details , bool prev_is_bad , std::string& password,bool *cancelled)
|
||||||
{
|
{
|
||||||
|
if(!prev_is_bad && !cached_pgp_passphrase.empty())
|
||||||
|
{
|
||||||
|
password = cached_pgp_passphrase ;
|
||||||
|
if(cancelled)
|
||||||
|
*cancelled = false ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
FOR_ALL_NOTIFY_CLIENTS
|
FOR_ALL_NOTIFY_CLIENTS
|
||||||
if( (*it)->askForPassword(title,key_details,prev_is_bad,password,*cancelled))
|
if( (*it)->askForPassword(title,key_details,prev_is_bad,password,*cancelled))
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -124,6 +124,9 @@ class p3Notify: public RsNotify
|
||||||
bool askForPassword (const std::string& title, const std::string& /* key_details */, bool /* prev_is_bad */, std::string&, bool *cancelled /* password */ ) ;
|
bool askForPassword (const std::string& title, const std::string& /* key_details */, bool /* prev_is_bad */, std::string&, bool *cancelled /* password */ ) ;
|
||||||
bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) ;
|
bool askForPluginConfirmation (const std::string& /* plugin_filename */, const std::string& /* plugin_file_hash */) ;
|
||||||
|
|
||||||
|
virtual bool cachePgpPassphrase (const std::string& /* pgp_passphrase */) ;
|
||||||
|
virtual bool clearPgpPassphrase () ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
RsMutex noteMtx;
|
RsMutex noteMtx;
|
||||||
|
@ -134,6 +137,8 @@ class p3Notify: public RsNotify
|
||||||
std::list<RsFeedItem> pendingNewsFeed;
|
std::list<RsFeedItem> pendingNewsFeed;
|
||||||
|
|
||||||
std::list<NotifyClient*> notifyClients ;
|
std::list<NotifyClient*> notifyClients ;
|
||||||
|
|
||||||
|
std::string cached_pgp_passphrase ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,9 @@ class RsNotify
|
||||||
virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg) = 0;
|
virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg) = 0;
|
||||||
|
|
||||||
virtual bool GetFeedItem(RsFeedItem &item) = 0;
|
virtual bool GetFeedItem(RsFeedItem &item) = 0;
|
||||||
|
|
||||||
|
virtual bool cachePgpPassphrase (const std::string& /* pgp_passphrase */) { return false ; }
|
||||||
|
virtual bool clearPgpPassphrase () { return false ; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class NotifyClient
|
class NotifyClient
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
#include <retroshare/rsinit.h>
|
#include <retroshare/rsinit.h>
|
||||||
|
#include <retroshare/rsnotify.h>
|
||||||
#include <rsserver/rsaccounts.h>
|
#include <rsserver/rsaccounts.h>
|
||||||
#include <util/rsrandom.h>
|
#include <util/rsrandom.h>
|
||||||
|
|
||||||
|
@ -469,6 +470,10 @@ void GenCertDialog::genPerson()
|
||||||
err_string);
|
err_string);
|
||||||
|
|
||||||
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
|
||||||
|
@ -484,6 +489,8 @@ void GenCertDialog::genPerson()
|
||||||
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
std::cout << "RsAccounts::GenerateSSLCertificate" << std::endl;
|
||||||
bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
|
bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
|
||||||
|
|
||||||
|
rsNotify->clearPgpPassphrase() ;
|
||||||
|
|
||||||
if (okGen)
|
if (okGen)
|
||||||
{
|
{
|
||||||
/* complete the process */
|
/* complete the process */
|
||||||
|
|
|
@ -278,7 +278,7 @@ bool NotifyQt::askForPassword(const std::string& title, const std::string& key_d
|
||||||
dialog.setWindowTitle(QString::fromStdString(title));
|
dialog.setWindowTitle(QString::fromStdString(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n %2").arg(tr("Please enter your PGP password for key"), QString::fromUtf8(key_details.c_str())));
|
dialog.setLabelText((prev_is_bad ? QString("%1\n\n").arg(tr("Wrong password !")) : QString()) + QString("%1:\n\n (%2)\n\n").arg(tr("Please enter your Retroshare password"), QString::fromUtf8(key_details.c_str())));
|
||||||
dialog.setTextEchoMode(QLineEdit::Password);
|
dialog.setTextEchoMode(QLineEdit::Password);
|
||||||
dialog.setModal(true);
|
dialog.setModal(true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue