mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 02:44:20 -05:00
add persistence of accepted gpg key to connect with
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2019 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e50dc4e3b9
commit
3742d3bd8b
@ -30,6 +30,7 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
|
||||
// initialisation du pointeur de singleton à zéro
|
||||
@ -114,7 +115,7 @@ static char *PgpPassword = NULL;
|
||||
|
||||
|
||||
AuthGPG::AuthGPG()
|
||||
:gpgmeInit(false)
|
||||
:gpgmeInit(false) , p3Config(CONFIG_TYPE_AUTHGPG)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
@ -1244,6 +1245,8 @@ bool AuthGPG::setAcceptToConnectGPGCertificate(std::string gpg_id, bool acceptan
|
||||
it->second.accept_connection = acceptance;
|
||||
mAcceptToConnectMap[gpg_id] = acceptance;
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1978,3 +1981,70 @@ static gpgme_error_t trustCallback(void *opaque, gpgme_status_code_t status, \
|
||||
|
||||
return params->err;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
// -------------------------------- Config functions ------------------------------ //
|
||||
// -----------------------------------------------------------------------------------//
|
||||
//
|
||||
RsSerialiser *AuthGPG::setupSerialiser()
|
||||
{
|
||||
RsSerialiser *rss = new RsSerialiser ;
|
||||
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||
return rss ;
|
||||
}
|
||||
|
||||
std::list<RsItem*> AuthGPG::saveList(bool& cleanup)
|
||||
{
|
||||
std::cerr << "AuthGPG::saveList() called" << std::endl ;
|
||||
cleanup = true ;
|
||||
std::list<RsItem*> lst ;
|
||||
|
||||
// Now save config for network digging strategies
|
||||
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||
std::map<std::string, bool>::iterator mapIt;
|
||||
for (mapIt = mAcceptToConnectMap.begin(); mapIt != mAcceptToConnectMap.end(); mapIt++) {
|
||||
RsTlvKeyValue kv;
|
||||
kv.key = mapIt->first;
|
||||
std::cerr << "AuthGPG::saveList() called (mapIt->second) : " << (mapIt->second) << std::endl ;
|
||||
kv.value = (mapIt->second)?"TRUE":"FALSE" ;
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
}
|
||||
lst.push_back(vitem);
|
||||
|
||||
return lst ;
|
||||
}
|
||||
|
||||
bool AuthGPG::loadList(std::list<RsItem*> load)
|
||||
{
|
||||
std::cerr << "AuthGPG::loadList() Item Count: " << load.size() << std::endl;
|
||||
|
||||
RsStackMutex stack(pgpMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
storeAllKeys_locked();
|
||||
|
||||
/* load the list of accepted gpg keys */
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = load.begin(); it != load.end(); it++) {
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it);
|
||||
|
||||
if(vitem) {
|
||||
std::cerr << "AuthGPG::loadList() General Variable Config Item:" << std::endl;
|
||||
vitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<RsTlvKeyValue>::iterator kit;
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); kit++) {
|
||||
mAcceptToConnectMap[kit->key] = (kit->value == "TRUE");
|
||||
//set the gpg key
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(kit->key))) {
|
||||
std::cerr << "AuthGPG::loadList() setting accept to : " << (kit->value == "TRUE");
|
||||
std::cerr << " for gpg key id : " << kit->key << std::endl;
|
||||
it->second.accept_connection = (kit->value == "TRUE");
|
||||
}
|
||||
}
|
||||
}
|
||||
delete (*it);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#define GPG_id std::string
|
||||
|
||||
@ -83,7 +84,7 @@ class gpgcert
|
||||
*/
|
||||
typedef std::map<std::string, gpgcert> certmap;
|
||||
|
||||
class AuthGPG
|
||||
class AuthGPG : public p3Config
|
||||
{
|
||||
private:
|
||||
|
||||
@ -215,6 +216,15 @@ class AuthGPG
|
||||
static AuthGPG *getAuthGPG() throw() // pour obtenir l'instance
|
||||
{ return instance_gpg; }
|
||||
|
||||
protected:
|
||||
/*****************************************************************/
|
||||
/*********************** p3config ******************************/
|
||||
/* Key Functions to be overloaded for Full Configuration */
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual std::list<RsItem *> saveList(bool &cleanup);
|
||||
virtual bool loadList(std::list<RsItem *> load);
|
||||
/*****************************************************************/
|
||||
|
||||
private:
|
||||
|
||||
static AuthGPG *instance_gpg; // pointeur vers le singleton
|
||||
|
@ -63,6 +63,8 @@ const uint32_t CONFIG_TYPE_PEERS = 0x0002;
|
||||
const uint32_t CONFIG_TYPE_FSERVER = 0x0003;
|
||||
const uint32_t CONFIG_TYPE_MSGS = 0x0004;
|
||||
const uint32_t CONFIG_TYPE_CACHE_OLDID = 0x0005;
|
||||
const uint32_t CONFIG_TYPE_AUTHGPG = 0x006;
|
||||
|
||||
|
||||
/* new FileTransfer */
|
||||
const uint32_t CONFIG_TYPE_FT_SHARED = 0x0007;
|
||||
|
@ -590,7 +590,7 @@ bool p3Peers::addFriend(std::string id, std::string gpg_id)
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
if (id == gpg_id) {
|
||||
if (id == gpg_id || id == "") {
|
||||
return addDummyFriend(gpg_id);
|
||||
} else {
|
||||
return mConnMgr->addFriend(id, gpg_id);
|
||||
|
@ -2019,7 +2019,10 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
//mConfigMgr->addConfiguration("ftserver.cfg", ftserver);
|
||||
//
|
||||
mConfigMgr->addConfiguration("peers.cfg", mConnMgr);
|
||||
mConfigMgr->addConfiguration("gpg_prefs.cfg", AuthGPG::getAuthGPG());
|
||||
mConfigMgr->loadConfiguration();
|
||||
|
||||
mConfigMgr->addConfiguration("peers.cfg", mConnMgr);
|
||||
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
|
||||
mConfigMgr->addConfiguration("msgs.cfg", msgSrv);
|
||||
mConfigMgr->addConfiguration("chat.cfg", chatSrv);
|
||||
|
Loading…
Reference in New Issue
Block a user