added warning for unsupported keys. It is triggered when no valid keypairs are found at start, and when unsupported keys pairs are found when copying the keyring

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5317 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-07-20 19:00:10 +00:00
parent bd1f0cc71b
commit ee77ec8c6c
3 changed files with 53 additions and 9 deletions

View File

@ -42,6 +42,8 @@
#define RS_USE_PGPSSL 1
#include <list>
#include <map>
#include <vector>
/*!
* Initialisation Class (not publicly disclosed to RsIFace)
@ -137,6 +139,7 @@ class RsInit
/* used for static install data */
static std::string getRetroshareDataDirectory();
static std::map<std::string,std::vector<std::string> > unsupported_keys ;
private:
/* PreLogin */

View File

@ -74,6 +74,7 @@ class accountId
std::string location;
};
std::map<std::string,std::vector<std::string> > RsInit::unsupported_keys ;
class RsInitConfig
{
@ -189,8 +190,8 @@ bool RsInitConfig::udpListenerOnly;
/* Uses private class - so must be hidden */
static bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts);
static bool checkAccount(std::string accountdir, accountId &id);
static bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys);
static bool checkAccount(std::string accountdir, accountId &id,std::map<std::string,std::vector<std::string> >& unsupported_keys);
static std::string toUpperCase(const std::string& s)
{
@ -630,7 +631,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
std::list<accountId>::iterator it;
int failing_accounts ;
getAvailableAccounts(RsInitConfig::accountIds,failing_accounts);
getAvailableAccounts(RsInitConfig::accountIds,failing_accounts,unsupported_keys);
if(failing_accounts > 0 && RsInitConfig::accountIds.empty())
return RS_INIT_NO_KEYRING ;
@ -1014,7 +1015,7 @@ std::string RsInit::getRetroshareDataDirectory()
/* directories with valid certificates in the expected location */
bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts)
bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts,std::map<std::string,std::vector<std::string> >& unsupported_keys)
{
failing_accounts = 0 ;
/* get the directories */
@ -1092,7 +1093,7 @@ bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts)
#endif
accountId tmpId;
if (checkAccount(accountdir, tmpId))
if (checkAccount(accountdir, tmpId,unsupported_keys))
{
#ifdef GPG_DEBUG
std::cerr << "getAvailableAccounts() Accepted: " << *it << std::endl;
@ -1107,7 +1108,7 @@ bool getAvailableAccounts(std::list<accountId> &ids,int& failing_accounts)
static bool checkAccount(std::string accountdir, accountId &id)
static bool checkAccount(std::string accountdir, accountId &id,std::map<std::string,std::vector<std::string> >& unsupported_keys)
{
/* check if the cert/key file exists */
@ -1140,12 +1141,16 @@ static bool checkAccount(std::string accountdir, accountId &id)
if(! RsInit::GetPGPLoginDetails(id.pgpId, id.pgpName, id.pgpEmail))
return false ;
if(!AuthGPG::getAuthGPG()->isKeySupported(id.pgpId))
return false ;
if(!AuthGPG::getAuthGPG()->haveSecretKey(id.pgpId))
return false ;
if(!AuthGPG::getAuthGPG()->isKeySupported(id.pgpId))
{
std::string keystring = id.pgpId + " " + id.pgpName + "&#60;" + id.pgpEmail ;
unsupported_keys[keystring].push_back("Location: " + id.location + "&nbsp;&nbsp;(" + id.sslId + ")") ;
return false ;
}
#ifdef GPG_DEBUG
std::cerr << "PGPLoginDetails: " << id.pgpId << " name: " << id.pgpName;
std::cerr << " email: " << id.pgpEmail << std::endl;

View File

@ -55,6 +55,37 @@
#include "gui/notifyqt.h"
#include <unistd.h>
static void displayWarningAboutDSAKeys()
{
if(RsInit::unsupported_keys.empty())
return ;
QMessageBox msgBox;
QString txt = QObject::tr("You appear to have locations associated to DSA keys:");
txt += "<UL>" ;
for(std::map<std::string,std::vector<std::string> >::const_iterator it(RsInit::unsupported_keys.begin());it!=RsInit::unsupported_keys.end();++it)
{
txt += "<LI>" + QString::fromStdString(it->first) ;
txt += "<UL>" ;
for(uint32_t i=0;i<it->second.size();++i)
txt += "<li>" + QString::fromStdString(it->second[i]) + "</li>" ;
txt += "</UL>" ;
txt += "</li>" ;
}
txt += "</UL>" ;
msgBox.setText(txt) ;
msgBox.setInformativeText(QObject::tr("DSA keys are not yet supported by this version of RetroShare. All these locations will be unusable. We're very sorry for that."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setWindowIcon(QIcon(":/images/rstray3.png"));
msgBox.exec();
}
int main(int argc, char *argv[])
{
#ifdef WINDOWS_SYS
@ -103,6 +134,9 @@ int main(int argc, char *argv[])
return 0 ;
initResult = RsInit::InitRetroShare(argc, argv);
displayWarningAboutDSAKeys() ;
}
else
initResult = RS_INIT_OK ;
@ -114,6 +148,8 @@ int main(int argc, char *argv[])
/* Translate into the desired language */
LanguageSupport::translate(LanguageSupport::defaultLanguageCode());
displayWarningAboutDSAKeys();
QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));