mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-01 04:14:33 -04:00
improved error handling, and ensures that keyring is always kept consistent
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6395 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4b21232beb
commit
e11f60150c
5 changed files with 32 additions and 13 deletions
|
@ -1610,6 +1610,13 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
|||
continue ;
|
||||
}
|
||||
|
||||
if(res->second._key_index >= _pubring->nkeys || PGPIdType(_pubring->keys[res->second._key_index].key_id) != *it)
|
||||
{
|
||||
std::cerr << "(EE) PGPHandler:: can't remove key " << (*it).toStdString() << ". Inconsistency found." << std::endl;
|
||||
error_code = PGP_KEYRING_REMOVAL_ERROR_DATA_INCONSISTENCY ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Move the last key to the freed place. This deletes the key in place.
|
||||
//
|
||||
ops_keyring_remove_key(_pubring,res->second._key_index) ;
|
||||
|
@ -1631,13 +1638,6 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::list<PGPIdType>& keys_to_re
|
|||
}
|
||||
}
|
||||
|
||||
if(_public_keyring_map.size() != _pubring->nkeys)
|
||||
{
|
||||
std::cerr << "Error after removing keys. Operation cancelled." << std::endl;
|
||||
|
||||
// todo
|
||||
}
|
||||
|
||||
// Everything went well, sync back the keyring on disk
|
||||
|
||||
_pubring_changed = true ;
|
||||
|
|
|
@ -108,6 +108,7 @@ const uint32_t PGP_KEYRING_REMOVAL_ERROR_NO_ERROR = 0x20 ;
|
|||
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANT_REMOVE_SECRET_KEYS = 0x21 ;
|
||||
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANNOT_CREATE_BACKUP = 0x22 ;
|
||||
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANNOT_WRITE_BACKUP = 0x23 ;
|
||||
const uint32_t PGP_KEYRING_REMOVAL_ERROR_DATA_INCONSISTENCY = 0x24 ;
|
||||
|
||||
/* LinkType Flags */
|
||||
|
||||
|
@ -253,6 +254,8 @@ class RsPeers
|
|||
/* Peer Details (Net & Auth) */
|
||||
virtual std::string getOwnId() = 0;
|
||||
|
||||
virtual bool haveSecretKey(const std::string& gpg_id) = 0 ;
|
||||
|
||||
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
|
||||
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
|
||||
|
|
|
@ -237,6 +237,10 @@ bool p3Peers::isFriend(const std::string &ssl_id)
|
|||
return mPeerMgr->isFriend(ssl_id);
|
||||
}
|
||||
|
||||
bool p3Peers::haveSecretKey(const std::string& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->haveSecretKey(id) ;
|
||||
}
|
||||
|
||||
/* There are too many dependancies of this function
|
||||
* to shift it immeidately
|
||||
|
|
|
@ -46,6 +46,7 @@ virtual bool OthersChanged();
|
|||
/* Peer Details (Net & Auth) */
|
||||
virtual std::string getOwnId();
|
||||
|
||||
virtual bool haveSecretKey(const std::string& gpg_id) ;
|
||||
|
||||
|
||||
virtual bool getOnlineList(std::list<std::string> &ids);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue