mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
Merge pull request #2211 from csoler/v0.6-BugFixing_5
Various bug fixes
This commit is contained in:
commit
d92132d025
17 changed files with 201 additions and 126 deletions
|
@ -187,7 +187,7 @@ RsGenExchange::RsGenExchange(
|
|||
GxsMsgReq msgsToDel;
|
||||
|
||||
RsGxsSinglePassIntegrityCheck::check(mServType,mGixs,mDataStore,
|
||||
this, mSerialiser,
|
||||
this, *mSerialiser,
|
||||
grpsToDel,msgsToDel);
|
||||
|
||||
for(auto& grpId: grpsToDel)
|
||||
|
@ -2309,7 +2309,16 @@ void RsGenExchange::publishMsgs()
|
|||
uint32_t token = mit->first;
|
||||
|
||||
uint32_t size = mSerialiser->size(msgItem);
|
||||
char* mData = new char[size];
|
||||
|
||||
if(size > RsSerialiser::MAX_SERIAL_SIZE)
|
||||
{
|
||||
std::cerr << "Trying to publish a GXS message larger than the accepted maximal size of " << RsSerialiser::MAX_SERIAL_SIZE << " bytes. This is a bug." << std::endl;
|
||||
mDataAccess->updatePublicRequestStatus(token, RsTokenService::FAILED);
|
||||
delete msgItem;
|
||||
|
||||
continue;
|
||||
}
|
||||
RsTemporaryMemory mData(size);
|
||||
|
||||
// for fatal sign creation
|
||||
bool createOk = false;
|
||||
|
@ -2386,9 +2395,7 @@ void RsGenExchange::publishMsgs()
|
|||
|
||||
// check message not over single msg storage limit
|
||||
if(createOk)
|
||||
{
|
||||
validSize = mDataStore->validSize(msg);
|
||||
}
|
||||
|
||||
if(createOk && validSize)
|
||||
{
|
||||
|
@ -2404,11 +2411,14 @@ void RsGenExchange::publishMsgs()
|
|||
// now serialise meta data
|
||||
size = msg->metaData->serial_size();
|
||||
|
||||
char* metaDataBuff = new char[size];
|
||||
bool s = msg->metaData->serialise(metaDataBuff, &size);
|
||||
s &= msg->meta.setBinData(metaDataBuff, size);
|
||||
if (!s)
|
||||
std::cerr << "(WW) Can't serialise or set bin data" << std::endl;
|
||||
{
|
||||
RsTemporaryMemory metaDataBuff(size);
|
||||
|
||||
bool s = msg->metaData->serialise(metaDataBuff, &size);
|
||||
s &= msg->meta.setBinData(metaDataBuff, size);
|
||||
if (!s)
|
||||
std::cerr << "(WW) Can't serialise or set bin data" << std::endl;
|
||||
}
|
||||
|
||||
msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED;
|
||||
msgId = msg->msgId;
|
||||
|
@ -2416,6 +2426,7 @@ void RsGenExchange::publishMsgs()
|
|||
msg->metaData->recvTS = time(NULL);
|
||||
|
||||
// FIXTESTS global variable rsPeers not available in unittests!
|
||||
|
||||
if(rsPeers)
|
||||
mRoutingClues[msg->metaData->mAuthorId].insert(rsPeers->getOwnId()) ;
|
||||
|
||||
|
@ -2425,21 +2436,27 @@ void RsGenExchange::publishMsgs()
|
|||
mPublishedMsgs[token] = *msg->metaData;
|
||||
|
||||
RsGxsMsgItem *msg_item = dynamic_cast<RsGxsMsgItem*>(mSerialiser->deserialise(msg->msg.bin_data,&msg->msg.bin_len)) ;
|
||||
|
||||
if(!msg_item)
|
||||
{
|
||||
delete msg;
|
||||
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::FAILED);
|
||||
|
||||
std::cerr << "RsGenExchange::publishMsgs() failed to publish msg, probably because of data size limits. bin_len=" << msg->msg.bin_len << std::endl;
|
||||
continue; // next mit
|
||||
}
|
||||
msg_item->meta = *msg->metaData;
|
||||
|
||||
mDataAccess->addMsgData(msg); // msg is deleted by addMsgData()
|
||||
|
||||
msgChangeMap[grpId].push_back(msg_item);
|
||||
|
||||
delete[] metaDataBuff;
|
||||
|
||||
if(mNetService != NULL)
|
||||
mNetService->stampMsgServerUpdateTS(grpId) ;
|
||||
|
||||
// add to published to allow acknowledgement
|
||||
mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId)));
|
||||
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::COMPLETE);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2447,8 +2464,7 @@ void RsGenExchange::publishMsgs()
|
|||
delete msg;
|
||||
|
||||
if(!tryLater)
|
||||
mDataAccess->updatePublicRequestStatus(mit->first,
|
||||
RsTokenService::FAILED);
|
||||
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::FAILED);
|
||||
|
||||
std::cerr << "RsGenExchange::publishMsgs() failed to publish msg " << std::endl;
|
||||
}
|
||||
|
@ -2458,8 +2474,6 @@ void RsGenExchange::publishMsgs()
|
|||
std::cerr << "RsGenExchange::publishMsgs() failed to serialise msg " << std::endl;
|
||||
}
|
||||
|
||||
delete[] mData;
|
||||
|
||||
if(!tryLater)
|
||||
delete msgItem;
|
||||
}
|
||||
|
|
|
@ -199,14 +199,8 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check,std::vector<RsGxsGrou
|
|||
RsGxsIntegrityCheck::RsGxsIntegrityCheck(
|
||||
RsGeneralDataService* const dataService, RsGenExchange* genex,
|
||||
RsSerialType&
|
||||
#ifdef RS_DEEP_CHANNEL_INDEX
|
||||
serializer
|
||||
#endif
|
||||
, RsGixs* gixs )
|
||||
: mDs(dataService), mGenExchangeClient(genex),
|
||||
#ifdef RS_DEEP_CHANNEL_INDEX
|
||||
mSerializer(serializer),
|
||||
#endif
|
||||
mDone(false), mIntegrityMutex("integrity"), mGixs(gixs) {}
|
||||
|
||||
void RsGxsIntegrityCheck::run()
|
||||
|
|
|
@ -171,8 +171,8 @@ public:
|
|||
* @param chunkSize
|
||||
* @param sleepPeriod
|
||||
*/
|
||||
RsGxsIntegrityCheck( RsGeneralDataService* const dataService,
|
||||
RsGenExchange *genex, RsSerialType& gxsSerialiser,
|
||||
RsGxsIntegrityCheck(RsGeneralDataService* const dataService,
|
||||
RsGenExchange *genex, RsSerialType&,
|
||||
RsGixs *gixs);
|
||||
|
||||
static bool check(uint16_t service_type, RsGixs *mgixs, RsGeneralDataService *mds);
|
||||
|
|
|
@ -889,7 +889,7 @@ public:
|
|||
bool& is_short_format, uint32_t& error_code ) = 0;
|
||||
virtual std::string saveCertificateToString(const RsPeerId &id) = 0;
|
||||
|
||||
virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0;
|
||||
virtual bool signGPGCertificate(const RsPgpId &gpg_id,const std::string& gpg_passphrase) = 0;
|
||||
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
|
||||
|
||||
/* Group Stuff */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "pqi/authssl.h"
|
||||
#include "pqi/authgpg.h"
|
||||
#include "retroshare/rsinit.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "util/rsurl.h"
|
||||
#include "util/radix64.h"
|
||||
|
@ -1680,19 +1681,23 @@ std::string p3Peers::saveCertificateToString(const RsPeerId &id)
|
|||
}
|
||||
}
|
||||
|
||||
bool p3Peers::signGPGCertificate(const RsPgpId &id)
|
||||
bool p3Peers::signGPGCertificate(const RsPgpId &id, const std::string &gpg_passphrase)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::SignCertificate() " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
rsNotify->cachePgpPassphrase(gpg_passphrase);
|
||||
rsNotify->setDisableAskPassword(true);
|
||||
|
||||
bool res = AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
|
||||
|
||||
AuthGPG::getAuthGPG()->AllowConnection(id, true);
|
||||
return AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
|
||||
rsNotify->clearPgpPassphrase();
|
||||
rsNotify->setDisableAskPassword(false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool p3Peers::trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert, bool &is_short_format, uint32_t& error_code) override;
|
||||
virtual std::string saveCertificateToString(const RsPeerId &id) override;
|
||||
|
||||
virtual bool signGPGCertificate(const RsPgpId &id) override;
|
||||
virtual bool signGPGCertificate(const RsPgpId &id,const std::string& gpg_passphrase) override;
|
||||
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl) override;
|
||||
|
||||
/* Group Stuff */
|
||||
|
|
|
@ -1927,20 +1927,26 @@ RsInit::LoadCertificateStatus RsLoginHelper::attemptLogin(const RsPeerId& accoun
|
|||
{
|
||||
if(isLoggedIn()) return RsInit::ERR_ALREADY_RUNNING;
|
||||
|
||||
if(!password.empty())
|
||||
{
|
||||
if(!rsNotify->cachePgpPassphrase(password)) 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(!RsAccounts::SelectAccount(account))
|
||||
return RsInit::ERR_UNKNOWN;
|
||||
|
||||
if(!rsNotify->setDisableAskPassword(false)) return RsInit::ERR_UNKNOWN;
|
||||
if(!rsNotify->clearPgpPassphrase()) return RsInit::ERR_UNKNOWN;
|
||||
if(ret != RsInit::OK) return ret;
|
||||
if(RsControl::instance()->StartupRetroShare() == 1) return RsInit::OK;
|
||||
return RsInit::ERR_UNKNOWN;
|
||||
if(!password.empty())
|
||||
{
|
||||
rsNotify->cachePgpPassphrase(password);
|
||||
rsNotify->setDisableAskPassword(true);
|
||||
}
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue