mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
started cleaning the mess with rsAccounts: only exposed useful functionality of rsAccount beyond a static class and removed all references to rsAccounts in the code
This commit is contained in:
parent
e2bb3aef1b
commit
0f758902cd
@ -94,7 +94,7 @@ namespace resource_api{
|
|||||||
|
|
||||||
std::string getDefaultDocroot()
|
std::string getDefaultDocroot()
|
||||||
{
|
{
|
||||||
return RsAccounts::DataDirectory(false) + "/webui";
|
return RsAccounts::systemDataDirectory(false) + "/webui";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* API_ENTRY_PATH = "/api/v2";
|
const char* API_ENTRY_PATH = "/api/v2";
|
||||||
|
@ -539,7 +539,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
|
|||||||
mPassword = pgp_password;
|
mPassword = pgp_password;
|
||||||
mFixedPassword = pgp_password;
|
mFixedPassword = pgp_password;
|
||||||
}
|
}
|
||||||
bool ssl_ok = RsAccounts::GenerateSSLCertificate(pgp_id, "", ssl_name, "", hidden_port!=0, ssl_password, ssl_id, err_string);
|
bool ssl_ok = RsAccounts::createNewAccount(pgp_id, "", ssl_name, "", hidden_port!=0, ssl_password, ssl_id, err_string);
|
||||||
|
|
||||||
// clear fixed password to restore normal password operation
|
// clear fixed password to restore normal password operation
|
||||||
// {
|
// {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "hash_cache.h"
|
#include "hash_cache.h"
|
||||||
#include "filelist_io.h"
|
#include "filelist_io.h"
|
||||||
#include "file_sharing_defaults.h"
|
#include "file_sharing_defaults.h"
|
||||||
|
#include "retroshare/rsinit.h"
|
||||||
|
|
||||||
//#define HASHSTORAGE_DEBUG 1
|
//#define HASHSTORAGE_DEBUG 1
|
||||||
|
|
||||||
@ -478,7 +479,7 @@ bool HashStorage::try_load_import_old_hash_cache()
|
|||||||
{
|
{
|
||||||
// compute file name
|
// compute file name
|
||||||
|
|
||||||
std::string base_dir = rsAccounts->PathAccountDirectory();
|
std::string base_dir = RsAccounts::AccountDirectory();
|
||||||
std::string old_cache_filename = base_dir + "/" + "file_cache.bin" ;
|
std::string old_cache_filename = base_dir + "/" + "file_cache.bin" ;
|
||||||
|
|
||||||
// check for unencrypted
|
// check for unencrypted
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "retroshare/rsids.h"
|
#include "retroshare/rsids.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
#include "rsserver/rsaccounts.h"
|
#include "retroshare/rsinit.h"
|
||||||
|
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
|||||||
{
|
{
|
||||||
// make sure the base directory exists
|
// make sure the base directory exists
|
||||||
|
|
||||||
std::string base_dir = rsAccounts->PathAccountDirectory();
|
std::string base_dir = RsAccounts::AccountDirectory();
|
||||||
|
|
||||||
if(base_dir.empty())
|
if(base_dir.empty())
|
||||||
throw std::runtime_error("Cannot create base directory to store/access file sharing files.") ;
|
throw std::runtime_error("Cannot create base directory to store/access file sharing files.") ;
|
||||||
|
@ -39,12 +39,12 @@
|
|||||||
|
|
||||||
#include "retroshare/rstypes.h"
|
#include "retroshare/rstypes.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
|
#include "retroshare/rsinit.h"
|
||||||
|
|
||||||
#include "rsitems/rsfiletransferitems.h"
|
#include "rsitems/rsfiletransferitems.h"
|
||||||
#include "rsitems/rsserviceids.h"
|
#include "rsitems/rsserviceids.h"
|
||||||
|
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
#include "rsserver/rsaccounts.h"
|
|
||||||
#include "turtle/p3turtle.h"
|
#include "turtle/p3turtle.h"
|
||||||
|
|
||||||
#include "util/rsdebug.h"
|
#include "util/rsdebug.h"
|
||||||
@ -148,8 +148,9 @@ void ftServer::SetupFtServer()
|
|||||||
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
|
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
|
||||||
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
|
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
|
||||||
|
|
||||||
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
|
std::string emergencySaveDir = RsAccounts::AccountDirectory();
|
||||||
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
|
std::string emergencyPartialsDir = RsAccounts::AccountDirectory();
|
||||||
|
|
||||||
if (emergencySaveDir != "")
|
if (emergencySaveDir != "")
|
||||||
{
|
{
|
||||||
emergencySaveDir += "/";
|
emergencySaveDir += "/";
|
||||||
|
@ -121,51 +121,78 @@ class RsInit
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Seperate Class for dealing with Accounts */
|
/* Seperate static Class for dealing with Accounts */
|
||||||
|
|
||||||
namespace RsAccounts
|
class RsAccountsDetail ;
|
||||||
|
|
||||||
|
class RsAccounts
|
||||||
{
|
{
|
||||||
/**
|
public:
|
||||||
* @brief ConfigDirectory (normally ~/.retroshare) you can call this method
|
// Should be called once before everything else.
|
||||||
* even before initialisation (you can't with some other methods)
|
|
||||||
* @see RsAccountsDetail::PathBaseDirectory()
|
static bool init(const std::string &opt_base_dir, int& error_code);
|
||||||
*/
|
|
||||||
std::string ConfigDirectory();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DataDirectory
|
* @brief ConfigDirectory (normally ~/.retroshare) you can call this method
|
||||||
* you can call this method even before initialisation (you can't with some other methods)
|
* even before initialisation (you can't with some other methods)
|
||||||
* @param check if set to true and directory does not exist, return empty string
|
*
|
||||||
* @return path where global platform independent files are stored, like bdboot.txt or webinterface files
|
* On linux: ~/.retroshare/
|
||||||
*/
|
*
|
||||||
std::string DataDirectory(bool check = true);
|
* @see RsAccountsDetail::PathBaseDirectory()
|
||||||
|
*/
|
||||||
|
static std::string ConfigDirectory();
|
||||||
|
|
||||||
std::string PGPDirectory();
|
/**
|
||||||
std::string AccountDirectory();
|
* @brief DataDirectory
|
||||||
|
* you can call this method even before initialisation (you can't with some other methods)
|
||||||
|
* @param check if set to true and directory does not exist, return empty string
|
||||||
|
* @return path where global platform independent files are stored, like bdboot.txt or webinterface files
|
||||||
|
*/
|
||||||
|
static std::string systemDataDirectory(bool check = true);
|
||||||
|
static std::string PGPDirectory();
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
static int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
||||||
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
static int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
||||||
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
||||||
|
|
||||||
// PGP Support Functions.
|
// PGP Support Functions.
|
||||||
bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
static bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
||||||
bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
static bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
||||||
bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
static bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
||||||
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
static void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
||||||
bool CopyGnuPGKeyrings() ;
|
static bool CopyGnuPGKeyrings() ;
|
||||||
|
|
||||||
// Rs Accounts
|
// Rs Accounts
|
||||||
bool SelectAccount(const RsPeerId& id);
|
static bool SelectAccount(const RsPeerId& id);
|
||||||
|
static bool GetPreferredAccountId(RsPeerId &id);
|
||||||
|
static bool GetAccountIds(std::list<RsPeerId> &ids);
|
||||||
|
|
||||||
bool GetPreferredAccountId(RsPeerId &id);
|
static bool GetAccountDetails(const RsPeerId &id, RsPgpId &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
||||||
bool GetAccountIds(std::list<RsPeerId> &ids);
|
|
||||||
bool GetAccountDetails(const RsPeerId &id,
|
|
||||||
RsPgpId &gpgId, std::string &gpgName,
|
|
||||||
std::string &gpgEmail, std::string &location);
|
|
||||||
|
|
||||||
bool GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
static bool createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
||||||
|
|
||||||
|
static void storeSelectedAccount() ;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// All methods bellow can only be called ones SelectAccount() as been called. //
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static bool getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time) ;
|
||||||
|
|
||||||
|
static bool checkCreateAccountDirectory(); // Generate the hierarchy of directories below ~/.retroshare/[SSL dir]/
|
||||||
|
|
||||||
|
static std::string AccountDirectory(); // linux: ~/.retroshare/[SSL dir]/
|
||||||
|
static std::string AccountKeysDirectory(); // linux: ~/.retroshare/[SSL dir]/keys/
|
||||||
|
static std::string AccountPathCertFile(); // linux: ~/.retroshare/[SSL dir]/keys/user_cert.pem
|
||||||
|
static std::string AccountPathKeyFile(); // linux: ~/.retroshare/[SSL dir]/keys/user_pk.pem
|
||||||
|
static std::string AccountLocationName();
|
||||||
|
|
||||||
|
static bool lockPreferredAccount() ; // are these methods any useful??
|
||||||
|
static void unlockPreferredAccount() ;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static RsAccountsDetail *rsAccounts ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
// Global singleton declaration of data.
|
// Global singleton declaration of data.
|
||||||
RsAccountsDetail *rsAccounts;
|
RsAccountsDetail *RsAccounts::rsAccounts;
|
||||||
|
|
||||||
/* Uses private class - so must be hidden */
|
/* Uses private class - so must be hidden */
|
||||||
static bool checkAccount(const std::string &accountdir, AccountDetails &account,std::map<std::string,std::vector<std::string> >& unsupported_keys);
|
static bool checkAccount(const std::string &accountdir, AccountDetails &account,std::map<std::string,std::vector<std::string> >& unsupported_keys);
|
||||||
@ -105,7 +105,7 @@ bool RsAccountsDetail::checkAccountDirectory()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return setupAccount(PathAccountDirectory());
|
return setupAccount(getCurrentAccountPathAccountDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning we need to clean that up. Login should only ask for a SSL id, instead of a std::string.
|
#warning we need to clean that up. Login should only ask for a SSL id, instead of a std::string.
|
||||||
@ -219,7 +219,7 @@ std::string RsAccountsDetail::PathBaseDirectory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string RsAccountsDetail::PathAccountDirectory()
|
std::string RsAccountsDetail::getCurrentAccountPathAccountDirectory()
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
||||||
@ -235,9 +235,9 @@ std::string RsAccountsDetail::PathAccountDirectory()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RsAccountsDetail::PathAccountKeysDirectory()
|
std::string RsAccountsDetail::getCurrentAccountPathAccountKeysDirectory()
|
||||||
{
|
{
|
||||||
std::string path = PathAccountDirectory();
|
std::string path = getCurrentAccountPathAccountDirectory();
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
@ -247,9 +247,9 @@ std::string RsAccountsDetail::PathAccountKeysDirectory()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RsAccountsDetail::PathKeyFile()
|
std::string RsAccountsDetail::getCurrentAccountPathKeyFile()
|
||||||
{
|
{
|
||||||
std::string path = PathAccountKeysDirectory();
|
std::string path = getCurrentAccountPathAccountKeysDirectory();
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
@ -259,9 +259,9 @@ std::string RsAccountsDetail::PathKeyFile()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RsAccountsDetail::PathCertFile()
|
std::string RsAccountsDetail::getCurrentAccountPathCertFile()
|
||||||
{
|
{
|
||||||
std::string path = PathAccountKeysDirectory();
|
std::string path = getCurrentAccountPathAccountKeysDirectory();
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
@ -270,7 +270,7 @@ std::string RsAccountsDetail::PathCertFile()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RsAccountsDetail::LocationName()
|
std::string RsAccountsDetail::getCurrentAccountLocationName()
|
||||||
{
|
{
|
||||||
std::map<RsPeerId, AccountDetails>::const_iterator it;
|
std::map<RsPeerId, AccountDetails>::const_iterator it;
|
||||||
it = mAccounts.find(mPreferredId);
|
it = mAccounts.find(mPreferredId);
|
||||||
@ -450,7 +450,7 @@ bool RsAccountsDetail::storePreferredAccount()
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool RsAccountsDetail::getPreferredAccountId(RsPeerId &id)
|
bool RsAccountsDetail::getCurrentAccountId(RsPeerId &id)
|
||||||
{
|
{
|
||||||
id = mPreferredId;
|
id = mPreferredId;
|
||||||
return (!mPreferredId.isNull());
|
return (!mPreferredId.isNull());
|
||||||
@ -479,7 +479,7 @@ bool RsAccountsDetail::getAccountIds(std::list<RsPeerId> &ids)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
|
bool RsAccountsDetail::getCurrentAccountDetails(const RsPeerId &id,
|
||||||
RsPgpId &gpgId, std::string &gpgName,
|
RsPgpId &gpgId, std::string &gpgName,
|
||||||
std::string &gpgEmail, std::string &location)
|
std::string &gpgEmail, std::string &location)
|
||||||
{
|
{
|
||||||
@ -496,14 +496,16 @@ bool RsAccountsDetail::getAccountDetails(const RsPeerId &id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccountsDetail::getAccountOptions(bool &ishidden, bool &isFirstTimeRun)
|
bool RsAccountsDetail::getCurrentAccountOptions(bool &ishidden,bool& isautotor, bool &isFirstTimeRun)
|
||||||
{
|
{
|
||||||
std::map<RsPeerId, AccountDetails>::iterator it;
|
std::map<RsPeerId, AccountDetails>::iterator it;
|
||||||
it = mAccounts.find(mPreferredId);
|
it = mAccounts.find(mPreferredId);
|
||||||
if (it != mAccounts.end())
|
if (it != mAccounts.end())
|
||||||
{
|
{
|
||||||
ishidden = it->second.mIsHiddenLoc;
|
ishidden = it->second.mIsHiddenLoc;
|
||||||
isFirstTimeRun = it->second.mFirstRun;
|
isFirstTimeRun = it->second.mFirstRun;
|
||||||
|
isautotor = it->second.mIsAutoTor;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -598,7 +600,9 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
|
|||||||
std::string lochex = (*it).substr(6); // rest of string.
|
std::string lochex = (*it).substr(6); // rest of string.
|
||||||
|
|
||||||
bool hidden_location = false;
|
bool hidden_location = false;
|
||||||
|
bool auto_tor = false;
|
||||||
bool valid_prefix = false;
|
bool valid_prefix = false;
|
||||||
|
|
||||||
if (prefix == "LOC06_")
|
if (prefix == "LOC06_")
|
||||||
{
|
{
|
||||||
valid_prefix = true;
|
valid_prefix = true;
|
||||||
@ -607,6 +611,8 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
|
|||||||
{
|
{
|
||||||
valid_prefix = true;
|
valid_prefix = true;
|
||||||
hidden_location = true;
|
hidden_location = true;
|
||||||
|
|
||||||
|
auto_tor = RsDirUtil::checkDirectory(PathDataDirectory()+"/hidden_service");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -626,7 +632,9 @@ bool RsAccountsDetail::getAvailableAccounts(std::map<RsPeerId, AccountDetails> &
|
|||||||
|
|
||||||
AccountDetails tmpId;
|
AccountDetails tmpId;
|
||||||
tmpId.mIsHiddenLoc = hidden_location;
|
tmpId.mIsHiddenLoc = hidden_location;
|
||||||
|
tmpId.mIsAutoTor = auto_tor;
|
||||||
tmpId.mAccountDir = *it;
|
tmpId.mAccountDir = *it;
|
||||||
|
|
||||||
if (checkAccount(accountdir, tmpId,unsupported_keys))
|
if (checkAccount(accountdir, tmpId,unsupported_keys))
|
||||||
{
|
{
|
||||||
#ifdef GPG_DEBUG
|
#ifdef GPG_DEBUG
|
||||||
@ -692,7 +700,7 @@ static bool checkAccount(const std::string &accountdir, AccountDetails &account,
|
|||||||
std::cerr << "issuerName: " << account.mPgpId << " id: " << account.mSslId << std::endl;
|
std::cerr << "issuerName: " << account.mPgpId << " id: " << account.mSslId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(! rsAccounts->GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail))
|
if(! RsAccounts::GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId))
|
if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId))
|
||||||
@ -1259,11 +1267,51 @@ bool RsInit::LoadPassword(const std::string& id, const std::string& inPwd)
|
|||||||
* PUBLIC INTERFACE FUNCTIONS
|
* PUBLIC INTERFACE FUNCTIONS
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
|
bool RsAccounts::init(const std::string& opt_base_dir,int& error_code)
|
||||||
|
{
|
||||||
|
rsAccounts = new RsAccountsDetail ;
|
||||||
|
|
||||||
|
// first check config directories, and set bootstrap values.
|
||||||
|
if(!rsAccounts->setupBaseDirectory(opt_base_dir))
|
||||||
|
{
|
||||||
|
error_code = RS_INIT_BASE_DIR_ERROR ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup PGP stuff.
|
||||||
|
std::string pgp_dir = rsAccounts->PathPGPDirectory();
|
||||||
|
|
||||||
|
if(!RsDirUtil::checkCreateDirectory(pgp_dir))
|
||||||
|
throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ;
|
||||||
|
|
||||||
|
AuthGPG::init( pgp_dir + "/retroshare_public_keyring.gpg",
|
||||||
|
pgp_dir + "/retroshare_secret_keyring.gpg",
|
||||||
|
pgp_dir + "/retroshare_trustdb.gpg",
|
||||||
|
pgp_dir + "/lock");
|
||||||
|
|
||||||
|
// load Accounts.
|
||||||
|
if (!rsAccounts->loadAccounts())
|
||||||
|
{
|
||||||
|
error_code = RS_INIT_NO_KEYRING ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Directories.
|
// Directories.
|
||||||
std::string RsAccounts::ConfigDirectory() { return RsAccountsDetail::PathBaseDirectory(); }
|
std::string RsAccounts::ConfigDirectory() { return RsAccountsDetail::PathBaseDirectory(); }
|
||||||
std::string RsAccounts::DataDirectory(bool check) { return RsAccountsDetail::PathDataDirectory(check); }
|
std::string RsAccounts::systemDataDirectory(bool check) { return RsAccountsDetail::PathDataDirectory(check); }
|
||||||
std::string RsAccounts::PGPDirectory() { return rsAccounts->PathPGPDirectory(); }
|
std::string RsAccounts::PGPDirectory() { return rsAccounts->PathPGPDirectory(); }
|
||||||
std::string RsAccounts::AccountDirectory() { return rsAccounts->PathAccountDirectory(); }
|
std::string RsAccounts::AccountDirectory() { return rsAccounts->getCurrentAccountPathAccountDirectory(); }
|
||||||
|
std::string RsAccounts::AccountKeysDirectory() { return rsAccounts->getCurrentAccountPathAccountKeysDirectory(); }
|
||||||
|
std::string RsAccounts::AccountPathCertFile() { return rsAccounts->getCurrentAccountPathCertFile(); }
|
||||||
|
std::string RsAccounts::AccountPathKeyFile() { return rsAccounts->getCurrentAccountPathKeyFile(); }
|
||||||
|
std::string RsAccounts::AccountLocationName() { return rsAccounts->getCurrentAccountLocationName(); }
|
||||||
|
|
||||||
|
bool RsAccounts::lockPreferredAccount() { return rsAccounts->lockPreferredAccount();} // are these methods any useful??
|
||||||
|
void RsAccounts::unlockPreferredAccount() { rsAccounts->unlockPreferredAccount(); }
|
||||||
|
|
||||||
|
bool RsAccounts::checkCreateAccountDirectory() { return rsAccounts->checkAccountDirectory(); }
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds)
|
int RsAccounts::GetPGPLogins(std::list<RsPgpId> &pgpIds)
|
||||||
@ -1307,6 +1355,7 @@ bool RsAccounts::CopyGnuPGKeyrings()
|
|||||||
return rsAccounts->copyGnuPGKeyrings();
|
return rsAccounts->copyGnuPGKeyrings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsAccounts::storeSelectedAccount() { rsAccounts->storePreferredAccount() ;}
|
||||||
// Rs Accounts
|
// Rs Accounts
|
||||||
bool RsAccounts::SelectAccount(const RsPeerId &id)
|
bool RsAccounts::SelectAccount(const RsPeerId &id)
|
||||||
{
|
{
|
||||||
@ -1315,7 +1364,12 @@ bool RsAccounts::SelectAccount(const RsPeerId &id)
|
|||||||
|
|
||||||
bool RsAccounts::GetPreferredAccountId(RsPeerId &id)
|
bool RsAccounts::GetPreferredAccountId(RsPeerId &id)
|
||||||
{
|
{
|
||||||
return rsAccounts->getPreferredAccountId(id);
|
return rsAccounts->getCurrentAccountId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RsAccounts::getCurrentAccountOptions(bool& is_hidden,bool& is_tor_auto,bool& is_first_time)
|
||||||
|
{
|
||||||
|
return rsAccounts->getCurrentAccountOptions(is_hidden,is_tor_auto,is_first_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
|
bool RsAccounts::GetAccountIds(std::list<RsPeerId> &ids)
|
||||||
@ -1327,10 +1381,10 @@ bool RsAccounts::GetAccountDetails(const RsPeerId &id,
|
|||||||
RsPgpId &pgpId, std::string &pgpName,
|
RsPgpId &pgpId, std::string &pgpName,
|
||||||
std::string &pgpEmail, std::string &location)
|
std::string &pgpEmail, std::string &location)
|
||||||
{
|
{
|
||||||
return rsAccounts->getAccountDetails(id, pgpId, pgpName, pgpEmail, location);
|
return rsAccounts->getCurrentAccountDetails(id, pgpId, pgpName, pgpEmail, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsAccounts::GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
bool RsAccounts::createNewAccount(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString)
|
||||||
{
|
{
|
||||||
return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
|
return rsAccounts->GenerateSSLCertificate(pgp_id, org, loc, country, ishiddenloc, passwd, sslId, errString);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ class AccountDetails
|
|||||||
std::string mLocation;
|
std::string mLocation;
|
||||||
bool mIsHiddenLoc;
|
bool mIsHiddenLoc;
|
||||||
bool mFirstRun;
|
bool mFirstRun;
|
||||||
|
bool mIsAutoTor;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,9 +59,6 @@ class RsAccountsDetail
|
|||||||
RsAccountsDetail();
|
RsAccountsDetail();
|
||||||
|
|
||||||
// These functions are externally accessible via RsAccounts namespace.
|
// These functions are externally accessible via RsAccounts namespace.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// These functions are accessible from inside libretroshare.
|
// These functions are accessible from inside libretroshare.
|
||||||
|
|
||||||
bool setupBaseDirectory(std::string alt_basedir);
|
bool setupBaseDirectory(std::string alt_basedir);
|
||||||
@ -87,52 +85,43 @@ class RsAccountsDetail
|
|||||||
// PGP Path is only dependent on BaseDirectory.
|
// PGP Path is only dependent on BaseDirectory.
|
||||||
std::string PathPGPDirectory();
|
std::string PathPGPDirectory();
|
||||||
|
|
||||||
// Below are dependent on mPreferredId.
|
// Generate a new account based on a given PGP key returns its SSL id and sets it to be the preferred account.
|
||||||
std::string PathAccountDirectory();
|
|
||||||
std::string PathAccountKeysDirectory();
|
bool GenerateSSLCertificate(const RsPgpId& gpg_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
||||||
std::string PathKeyFile();
|
|
||||||
std::string PathCertFile();
|
|
||||||
std::string LocationName();
|
|
||||||
|
|
||||||
// PGP Accounts.
|
// PGP Accounts.
|
||||||
|
|
||||||
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
||||||
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
||||||
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
||||||
|
bool SelectPGPAccount(const RsPgpId& pgpId);
|
||||||
bool SelectPGPAccount(const RsPgpId& pgpId);
|
|
||||||
|
|
||||||
// PGP Support Functions.
|
// PGP Support Functions.
|
||||||
bool exportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
bool exportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
||||||
bool importIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
bool importIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
||||||
bool importIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
bool importIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
||||||
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
||||||
bool copyGnuPGKeyrings() ;
|
bool copyGnuPGKeyrings() ;
|
||||||
|
|
||||||
|
|
||||||
// Selecting Rs Account.
|
// Selecting Rs Account.
|
||||||
|
bool getAccountIds(std::list<RsPeerId> &ids);
|
||||||
bool selectAccountByString(const std::string &prefUserString);
|
bool selectAccountByString(const std::string &prefUserString);
|
||||||
bool selectId(const RsPeerId& preferredId);
|
bool selectId(const RsPeerId& preferredId);
|
||||||
|
|
||||||
// Details of Rs Account.
|
|
||||||
bool getPreferredAccountId(RsPeerId &id);
|
|
||||||
bool getAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
|
||||||
|
|
||||||
bool getAccountOptions(bool &ishidden, bool &isFirstTimeRun);
|
|
||||||
|
|
||||||
|
|
||||||
bool getAccountIds(std::list<RsPeerId> &ids);
|
|
||||||
|
|
||||||
bool GenerateSSLCertificate(const RsPgpId& gpg_id,
|
|
||||||
const std::string& org, const std::string& loc,
|
|
||||||
const std::string& country, const bool ishiddenloc,
|
|
||||||
const std::string& passwd, RsPeerId &sslId,
|
|
||||||
std::string &errString);
|
|
||||||
|
|
||||||
// From init file.
|
|
||||||
bool storePreferredAccount();
|
bool storePreferredAccount();
|
||||||
bool loadPreferredAccount();
|
bool loadPreferredAccount();
|
||||||
|
|
||||||
|
// Details of current Rs Account.
|
||||||
|
bool getCurrentAccountId(RsPeerId &id);
|
||||||
|
bool getCurrentAccountDetails(const RsPeerId &id, RsPgpId& gpgId, std::string &gpgName, std::string &gpgEmail, std::string &location);
|
||||||
|
bool getCurrentAccountOptions(bool &ishidden, bool &isautotor, bool &isFirstTimeRun);
|
||||||
|
|
||||||
|
std::string getCurrentAccountPathAccountDirectory();
|
||||||
|
std::string getCurrentAccountPathAccountKeysDirectory();
|
||||||
|
std::string getCurrentAccountPathKeyFile();
|
||||||
|
std::string getCurrentAccountPathCertFile();
|
||||||
|
std::string getCurrentAccountLocationName();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkPreferredId();
|
bool checkPreferredId();
|
||||||
|
|
||||||
@ -155,6 +144,4 @@ class RsAccountsDetail
|
|||||||
std::map<std::string,std::vector<std::string> > mUnsupportedKeys ;
|
std::map<std::string,std::vector<std::string> > mUnsupportedKeys ;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global singleton declaration of data.
|
|
||||||
extern RsAccountsDetail *rsAccounts;
|
|
||||||
|
|
||||||
|
@ -431,26 +431,10 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
|
|||||||
AuthSSL::AuthSSLInit();
|
AuthSSL::AuthSSLInit();
|
||||||
AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL, "");
|
AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL, "");
|
||||||
|
|
||||||
rsAccounts = new RsAccountsDetail();
|
int error_code ;
|
||||||
|
|
||||||
// first check config directories, and set bootstrap values.
|
if(!RsAccounts::init(opt_base_dir,error_code))
|
||||||
if(!rsAccounts->setupBaseDirectory(opt_base_dir))
|
return error_code ;
|
||||||
return RS_INIT_BASE_DIR_ERROR ;
|
|
||||||
|
|
||||||
// Setup PGP stuff.
|
|
||||||
std::string pgp_dir = rsAccounts->PathPGPDirectory();
|
|
||||||
|
|
||||||
if(!RsDirUtil::checkCreateDirectory(pgp_dir))
|
|
||||||
throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ;
|
|
||||||
|
|
||||||
AuthGPG::init( pgp_dir + "/retroshare_public_keyring.gpg",
|
|
||||||
pgp_dir + "/retroshare_secret_keyring.gpg",
|
|
||||||
pgp_dir + "/retroshare_trustdb.gpg",
|
|
||||||
pgp_dir + "/lock");
|
|
||||||
|
|
||||||
// load Accounts.
|
|
||||||
if (!rsAccounts->loadAccounts())
|
|
||||||
return RS_INIT_NO_KEYRING ;
|
|
||||||
|
|
||||||
// choose alternative account.
|
// choose alternative account.
|
||||||
if(prefUserString != "")
|
if(prefUserString != "")
|
||||||
@ -464,7 +448,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
|
|||||||
return RS_INIT_AUTH_FAILED ;
|
return RS_INIT_AUTH_FAILED ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rsAccounts->selectId(ssl_id))
|
if(RsAccounts::SelectAccount(ssl_id))
|
||||||
{
|
{
|
||||||
std::cerr << "Auto-selectng account ID " << ssl_id << std::endl;
|
std::cerr << "Auto-selectng account ID " << ssl_id << std::endl;
|
||||||
return RS_INIT_HAVE_ACCOUNT;
|
return RS_INIT_HAVE_ACCOUNT;
|
||||||
@ -474,7 +458,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
|
|||||||
#ifdef RS_AUTOLOGIN
|
#ifdef RS_AUTOLOGIN
|
||||||
/* check that we have selected someone */
|
/* check that we have selected someone */
|
||||||
RsPeerId preferredId;
|
RsPeerId preferredId;
|
||||||
bool existingUser = rsAccounts->getPreferredAccountId(preferredId);
|
bool existingUser = RsAccounts::GetPreferredAccountId(preferredId);
|
||||||
|
|
||||||
if (existingUser)
|
if (existingUser)
|
||||||
{
|
{
|
||||||
@ -550,44 +534,43 @@ bool RsInit::LoadPassword(const std::string& inPwd)
|
|||||||
*/
|
*/
|
||||||
int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath)
|
int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath)
|
||||||
{
|
{
|
||||||
if (!rsAccounts->lockPreferredAccount())
|
try
|
||||||
{
|
{
|
||||||
return 3; // invalid PreferredAccount.
|
if (!RsAccounts::lockPreferredAccount())
|
||||||
|
throw 3; // invalid PreferredAccount.
|
||||||
|
|
||||||
|
// Logic that used to be external to RsInit...
|
||||||
|
RsPeerId accountId;
|
||||||
|
if (!RsAccounts::GetPreferredAccountId(accountId))
|
||||||
|
throw 3; // invalid PreferredAccount;
|
||||||
|
|
||||||
|
RsPgpId pgpId;
|
||||||
|
std::string pgpName, pgpEmail, location;
|
||||||
|
|
||||||
|
if(!RsAccounts::GetAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
|
||||||
|
throw 3; // invalid PreferredAccount;
|
||||||
|
|
||||||
|
if(0 == AuthGPG::getAuthGPG() -> GPGInit(pgpId))
|
||||||
|
throw 3; // PGP Error.
|
||||||
|
|
||||||
|
int retVal = LockConfigDirectory(RsAccounts::AccountDirectory(), lockFilePath);
|
||||||
|
|
||||||
|
if(retVal > 0)
|
||||||
|
throw retVal ;
|
||||||
|
|
||||||
|
if(LoadCertificates(autoLoginNT) != 1)
|
||||||
|
{
|
||||||
|
UnlockConfigDirectory();
|
||||||
|
throw 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
catch(int retVal)
|
||||||
int retVal = 0;
|
{
|
||||||
|
RsAccounts::unlockPreferredAccount();
|
||||||
// Logic that used to be external to RsInit...
|
return retVal ;
|
||||||
RsPeerId accountId;
|
}
|
||||||
if (!rsAccounts->getPreferredAccountId(accountId))
|
|
||||||
{
|
|
||||||
retVal = 3; // invalid PreferredAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
RsPgpId pgpId;
|
|
||||||
std::string pgpName, pgpEmail, location;
|
|
||||||
|
|
||||||
if (retVal == 0 && !rsAccounts->getAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
|
|
||||||
retVal = 3; // invalid PreferredAccount;
|
|
||||||
|
|
||||||
if (retVal == 0 && !rsAccounts->SelectPGPAccount(pgpId))
|
|
||||||
retVal = 3; // PGP Error.
|
|
||||||
|
|
||||||
if(retVal == 0)
|
|
||||||
retVal = LockConfigDirectory(rsAccounts->PathAccountDirectory(), lockFilePath);
|
|
||||||
|
|
||||||
if(retVal == 0 && LoadCertificates(autoLoginNT) != 1)
|
|
||||||
{
|
|
||||||
UnlockConfigDirectory();
|
|
||||||
retVal = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(retVal != 0)
|
|
||||||
{
|
|
||||||
rsAccounts->unlockPreferredAccount();
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -603,20 +586,20 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
|
|||||||
int RsInit::LoadCertificates(bool autoLoginNT)
|
int RsInit::LoadCertificates(bool autoLoginNT)
|
||||||
{
|
{
|
||||||
RsPeerId preferredId;
|
RsPeerId preferredId;
|
||||||
if (!rsAccounts->getPreferredAccountId(preferredId))
|
if (!RsAccounts::GetPreferredAccountId(preferredId))
|
||||||
{
|
{
|
||||||
std::cerr << "No Account Selected" << std::endl;
|
std::cerr << "No Account Selected" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rsAccounts->PathCertFile() == "")
|
if (RsAccounts::AccountPathCertFile() == "")
|
||||||
{
|
{
|
||||||
std::cerr << "RetroShare needs a certificate" << std::endl;
|
std::cerr << "RetroShare needs a certificate" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsAccounts->PathKeyFile() == "")
|
if (RsAccounts::AccountPathKeyFile() == "")
|
||||||
{
|
{
|
||||||
std::cerr << "RetroShare needs a key" << std::endl;
|
std::cerr << "RetroShare needs a key" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
@ -638,9 +621,10 @@ int RsInit::LoadCertificates(bool autoLoginNT)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "rsAccounts->PathKeyFile() : " << rsAccounts->PathKeyFile() << std::endl;
|
std::cerr << "rsAccounts->PathKeyFile() : " << RsAccounts::AccountPathKeyFile() << std::endl;
|
||||||
|
|
||||||
if(0 == AuthSSL::getAuthSSL() -> InitAuth(rsAccounts->PathCertFile().c_str(), rsAccounts->PathKeyFile().c_str(), rsInitConfig->passwd.c_str(), rsAccounts->LocationName()))
|
if(0 == AuthSSL::getAuthSSL() -> InitAuth(RsAccounts::AccountPathCertFile().c_str(), RsAccounts::AccountPathKeyFile().c_str(), rsInitConfig->passwd.c_str(),
|
||||||
|
RsAccounts::AccountLocationName()))
|
||||||
{
|
{
|
||||||
std::cerr << "SSL Auth Failed!";
|
std::cerr << "SSL Auth Failed!";
|
||||||
return 0 ;
|
return 0 ;
|
||||||
@ -665,7 +649,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
|
|||||||
rsInitConfig->gxs_passwd = rsInitConfig->passwd;
|
rsInitConfig->gxs_passwd = rsInitConfig->passwd;
|
||||||
rsInitConfig->passwd = "";
|
rsInitConfig->passwd = "";
|
||||||
|
|
||||||
rsAccounts->storePreferredAccount();
|
RsAccounts::storeSelectedAccount();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,7 +893,7 @@ int RsServer::StartupRetroShare()
|
|||||||
std::cerr << "set the debugging to crashMode." << std::endl;
|
std::cerr << "set the debugging to crashMode." << std::endl;
|
||||||
if ((!rsInitConfig->haveLogFile) && (!rsInitConfig->outStderr))
|
if ((!rsInitConfig->haveLogFile) && (!rsInitConfig->outStderr))
|
||||||
{
|
{
|
||||||
std::string crashfile = rsAccounts->PathAccountDirectory();
|
std::string crashfile = RsAccounts::AccountDirectory();
|
||||||
crashfile += "/" + configLogFileName;
|
crashfile += "/" + configLogFileName;
|
||||||
setDebugCrashMode(crashfile.c_str());
|
setDebugCrashMode(crashfile.c_str());
|
||||||
}
|
}
|
||||||
@ -921,7 +905,7 @@ int RsServer::StartupRetroShare()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check account directory */
|
/* check account directory */
|
||||||
if (!rsAccounts->checkAccountDirectory())
|
if (!RsAccounts::checkCreateAccountDirectory())
|
||||||
{
|
{
|
||||||
std::cerr << "RsServer::StartupRetroShare() - Fatal Error....." << std::endl;
|
std::cerr << "RsServer::StartupRetroShare() - Fatal Error....." << std::endl;
|
||||||
std::cerr << "checkAccount failed!" << std::endl;
|
std::cerr << "checkAccount failed!" << std::endl;
|
||||||
@ -933,8 +917,8 @@ int RsServer::StartupRetroShare()
|
|||||||
// Load up Certificates, and Old Configuration (if present)
|
// Load up Certificates, and Old Configuration (if present)
|
||||||
std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl;
|
std::cerr << "Load up Certificates, and Old Configuration (if present)." << std::endl;
|
||||||
|
|
||||||
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
|
std::string emergencySaveDir = RsAccounts::AccountDirectory();
|
||||||
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
|
std::string emergencyPartialsDir = RsAccounts::AccountDirectory();
|
||||||
if (emergencySaveDir != "")
|
if (emergencySaveDir != "")
|
||||||
{
|
{
|
||||||
emergencySaveDir += "/";
|
emergencySaveDir += "/";
|
||||||
@ -948,13 +932,15 @@ int RsServer::StartupRetroShare()
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
std::cerr << "Load Configuration" << std::endl;
|
std::cerr << "Load Configuration" << std::endl;
|
||||||
|
|
||||||
mConfigMgr = new p3ConfigMgr(rsAccounts->PathAccountDirectory());
|
mConfigMgr = new p3ConfigMgr(RsAccounts::AccountDirectory());
|
||||||
mGeneralConfig = new p3GeneralConfig();
|
mGeneralConfig = new p3GeneralConfig();
|
||||||
|
|
||||||
// Get configuration options from rsAccounts.
|
// Get configuration options from rsAccounts.
|
||||||
bool isHiddenNode = false;
|
bool isHiddenNode = false;
|
||||||
bool isFirstTimeRun = false;
|
bool isFirstTimeRun = false;
|
||||||
rsAccounts->getAccountOptions(isHiddenNode, isFirstTimeRun);
|
bool isTorAuto = false;
|
||||||
|
|
||||||
|
RsAccounts::getCurrentAccountOptions(isHiddenNode,isTorAuto, isFirstTimeRun);
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* setup classes / structures */
|
/* setup classes / structures */
|
||||||
@ -1032,12 +1018,12 @@ int RsServer::StartupRetroShare()
|
|||||||
#define BITDHT_FILTERED_IP_FILENAME "bdfilter.txt"
|
#define BITDHT_FILTERED_IP_FILENAME "bdfilter.txt"
|
||||||
|
|
||||||
|
|
||||||
std::string bootstrapfile = rsAccounts->PathAccountDirectory();
|
std::string bootstrapfile = RsAccounts::AccountDirectory();
|
||||||
if (bootstrapfile != "")
|
if (bootstrapfile != "")
|
||||||
bootstrapfile += "/";
|
bootstrapfile += "/";
|
||||||
bootstrapfile += BITDHT_BOOTSTRAP_FILENAME;
|
bootstrapfile += BITDHT_BOOTSTRAP_FILENAME;
|
||||||
|
|
||||||
std::string filteredipfile = rsAccounts->PathAccountDirectory();
|
std::string filteredipfile = RsAccounts::AccountDirectory();
|
||||||
if (filteredipfile != "")
|
if (filteredipfile != "")
|
||||||
filteredipfile += "/";
|
filteredipfile += "/";
|
||||||
filteredipfile += BITDHT_FILTERED_IP_FILENAME;
|
filteredipfile += BITDHT_FILTERED_IP_FILENAME;
|
||||||
@ -1077,7 +1063,7 @@ int RsServer::StartupRetroShare()
|
|||||||
bdbootRF.close();
|
bdbootRF.close();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string installfile = rsAccounts->PathDataDirectory();
|
std::string installfile = RsAccounts::systemDataDirectory();
|
||||||
installfile += "/";
|
installfile += "/";
|
||||||
installfile += BITDHT_BOOTSTRAP_FILENAME;
|
installfile += BITDHT_BOOTSTRAP_FILENAME;
|
||||||
|
|
||||||
@ -1208,7 +1194,7 @@ int RsServer::StartupRetroShare()
|
|||||||
|
|
||||||
/****** New Ft Server **** !!! */
|
/****** New Ft Server **** !!! */
|
||||||
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
|
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
|
||||||
ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory());
|
ftserver->setConfigDirectory(RsAccounts::AccountDirectory());
|
||||||
|
|
||||||
ftserver->SetupFtServer() ;
|
ftserver->SetupFtServer() ;
|
||||||
|
|
||||||
@ -1229,7 +1215,7 @@ int RsServer::StartupRetroShare()
|
|||||||
#if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR)
|
#if !defined(WINDOWS_SYS) && defined(PLUGIN_DIR)
|
||||||
plugins_directories.push_back(std::string(PLUGIN_DIR)) ;
|
plugins_directories.push_back(std::string(PLUGIN_DIR)) ;
|
||||||
#endif
|
#endif
|
||||||
std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ;
|
std::string extensions_dir = RsAccounts::ConfigDirectory() + "/extensions6/" ;
|
||||||
plugins_directories.push_back(extensions_dir) ;
|
plugins_directories.push_back(extensions_dir) ;
|
||||||
|
|
||||||
if(!RsDirUtil::checkCreateDirectory(extensions_dir))
|
if(!RsDirUtil::checkCreateDirectory(extensions_dir))
|
||||||
@ -1272,7 +1258,7 @@ int RsServer::StartupRetroShare()
|
|||||||
|
|
||||||
#ifdef RS_ENABLE_GXS
|
#ifdef RS_ENABLE_GXS
|
||||||
|
|
||||||
std::string currGxsDir = rsAccounts->PathAccountDirectory() + "/gxs";
|
std::string currGxsDir = RsAccounts::AccountDirectory() + "/gxs";
|
||||||
RsDirUtil::checkCreateDirectory(currGxsDir);
|
RsDirUtil::checkCreateDirectory(currGxsDir);
|
||||||
|
|
||||||
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl);
|
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <pqi/authgpg.h>
|
#include <pqi/authgpg.h>
|
||||||
#include "rsloginhandler.h"
|
#include "rsloginhandler.h"
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
#include "rsaccounts.h"
|
#include "retroshare/rsinit.h"
|
||||||
|
|
||||||
//#define DEBUG_RSLOGINHANDLER 1
|
//#define DEBUG_RSLOGINHANDLER 1
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string&
|
|||||||
|
|
||||||
std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/)
|
std::string RsLoginHandler::getSSLPasswdFileName(const RsPeerId& /*ssl_id*/)
|
||||||
{
|
{
|
||||||
return rsAccounts->PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
|
return RsAccounts::AccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RS_AUTOLOGIN
|
#ifdef RS_AUTOLOGIN
|
||||||
@ -755,7 +755,7 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
|
|||||||
|
|
||||||
std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/)
|
std::string RsLoginHandler::getAutologinFileName(const RsPeerId& /*ssl_id*/)
|
||||||
{
|
{
|
||||||
return rsAccounts->PathAccountKeysDirectory() + "/" + "help.dta" ;
|
return RsAccounts::AccountKeysDirectory() + "/" + "help.dta" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // RS_AUTOLOGIN
|
#endif // RS_AUTOLOGIN
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
#include "retroshare/rsfiles.h"
|
#include "retroshare/rsfiles.h"
|
||||||
#include "retroshare/rsiface.h"
|
#include "retroshare/rsiface.h"
|
||||||
#include "rsserver/rsaccounts.h"
|
#include "retroshare/rsinit.h"
|
||||||
#include "rsdiscspace.h"
|
#include "rsdiscspace.h"
|
||||||
#include <util/rsthreads.h>
|
#include <util/rsthreads.h>
|
||||||
|
|
||||||
@ -166,13 +166,13 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
|
|||||||
#endif
|
#endif
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathAccountDirectory().c_str(),free_blocks,block_size) ;
|
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(RsAccounts::AccountDirectory().c_str(),free_blocks,block_size) ;
|
||||||
#ifdef DEBUG_RSDISCSPACE
|
#ifdef DEBUG_RSDISCSPACE
|
||||||
std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ;
|
std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(rsAccounts->PathPGPDirectory().c_str(),free_blocks,block_size) ;
|
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(RsAccounts::PGPDirectory().c_str(),free_blocks,block_size) ;
|
||||||
#ifdef DEBUG_RSDISCSPACE
|
#ifdef DEBUG_RSDISCSPACE
|
||||||
std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ;
|
std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
|
@ -216,7 +216,7 @@ QTranslator* VOIPPlugin::qt_translator(QApplication */*app*/, const QString& lan
|
|||||||
|
|
||||||
void VOIPPlugin::qt_sound_events(SoundEvents &events) const
|
void VOIPPlugin::qt_sound_events(SoundEvents &events) const
|
||||||
{
|
{
|
||||||
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
|
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds");
|
||||||
|
|
||||||
events.addEvent(QApplication::translate("VOIP", "VOIP")
|
events.addEvent(QApplication::translate("VOIP", "VOIP")
|
||||||
, QApplication::translate("VOIP", "Incoming audio call")
|
, QApplication::translate("VOIP", "Incoming audio call")
|
||||||
|
@ -620,7 +620,7 @@ void GenCertDialog::genPerson()
|
|||||||
std::string err;
|
std::string err;
|
||||||
this->hide();//To show dialog asking password PGP Key.
|
this->hide();//To show dialog asking password PGP Key.
|
||||||
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::createNewAccount(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err);
|
||||||
|
|
||||||
if (okGen)
|
if (okGen)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ SoundManager::SoundManager() : QObject()
|
|||||||
|
|
||||||
void SoundManager::soundEvents(SoundEvents &events)
|
void SoundManager::soundEvents(SoundEvents &events)
|
||||||
{
|
{
|
||||||
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/sounds");
|
QDir baseDir = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/sounds");
|
||||||
|
|
||||||
events.mDefaultPath = baseDir.absolutePath();
|
events.mDefaultPath = baseDir.absolutePath();
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ static QStringList getBaseDirList()
|
|||||||
// Search chat styles in config dir and data dir (is application dir for portable)
|
// Search chat styles in config dir and data dir (is application dir for portable)
|
||||||
QStringList baseDirs;
|
QStringList baseDirs;
|
||||||
baseDirs.append(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
|
baseDirs.append(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()));
|
||||||
baseDirs.append(QString::fromUtf8(RsAccounts::DataDirectory().c_str()));
|
baseDirs.append(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()));
|
||||||
|
|
||||||
return baseDirs;
|
return baseDirs;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
|
|||||||
if(fi.exists() && fi.isFile()) {
|
if(fi.exists() && fi.isFile()) {
|
||||||
QString cpath = fi.canonicalFilePath();
|
QString cpath = fi.canonicalFilePath();
|
||||||
if (cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)
|
if (cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)
|
||||||
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
|
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
|
||||||
return QTextBrowser::loadResource(type, name);
|
return QTextBrowser::loadResource(type, name);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
static QMap<RsPlugin*, QTranslator*> translatorPlugins;
|
static QMap<RsPlugin*, QTranslator*> translatorPlugins;
|
||||||
|
|
||||||
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::DataDirectory().c_str())
|
#define EXTERNAL_TRANSLATION_DIR QString::fromUtf8(RsAccounts::systemDataDirectory().c_str())
|
||||||
|
|
||||||
/** Initializes the list of available languages. */
|
/** Initializes the list of available languages. */
|
||||||
QMap<QString, QString>
|
QMap<QString, QString>
|
||||||
|
@ -349,48 +349,57 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
|
|
||||||
SoundManager::create();
|
SoundManager::create();
|
||||||
|
|
||||||
#ifdef RETROTOR
|
bool is_hidden_node = false;
|
||||||
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
|
bool is_auto_tor = false ;
|
||||||
|
bool is_first_time = false ;
|
||||||
|
|
||||||
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
RsAccounts::getCurrentAccountOptions(is_hidden_node,is_auto_tor,is_first_time);
|
||||||
|
|
||||||
Tor::TorManager *torManager = Tor::TorManager::instance();
|
#ifdef UNFINISHED
|
||||||
torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
|
if(RsAccounts::AccountType() == RS_ACCOUNT_TYPE_HIDDEN_TOR_AUTO)
|
||||||
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
|
|
||||||
|
|
||||||
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
|
||||||
|
|
||||||
torManager->setupHiddenService();
|
|
||||||
|
|
||||||
if(! torManager->start() || torManager->hasError())
|
|
||||||
{
|
{
|
||||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ;
|
// Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service
|
||||||
return 1 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
QString tor_hidden_service_dir = QString::fromStdString(RsAccounts::AccountDirectory()) + QString("/hidden_service/") ;
|
||||||
TorControlDialog tcd(torManager) ;
|
|
||||||
QString error_msg ;
|
|
||||||
tcd.show();
|
|
||||||
|
|
||||||
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
|
Tor::TorManager *torManager = Tor::TorManager::instance();
|
||||||
|
torManager->setDataDirectory(Rshare::dataDirectory() + QString("/tor/"));
|
||||||
|
torManager->setHiddenServiceDirectory(tor_hidden_service_dir); // re-set it, because now it's changed to the specific location that is run
|
||||||
|
|
||||||
|
RsDirUtil::checkCreateDirectory(std::string(tor_hidden_service_dir.toUtf8())) ;
|
||||||
|
|
||||||
|
torManager->setupHiddenService();
|
||||||
|
|
||||||
|
if(! torManager->start() || torManager->hasError())
|
||||||
{
|
{
|
||||||
QCoreApplication::processEvents();
|
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor Manager!"),QObject::tr("Tor cannot be started on your system: \n\n")+torManager->errorMessage()) ;
|
||||||
rstime::rs_usleep(0.2*1000*1000) ;
|
return 1 ;
|
||||||
|
|
||||||
if(!error_msg.isNull())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tcd.hide();
|
|
||||||
|
|
||||||
if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK)
|
|
||||||
{
|
{
|
||||||
QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ;
|
TorControlDialog tcd(torManager) ;
|
||||||
return 1 ;
|
QString error_msg ;
|
||||||
|
tcd.show();
|
||||||
|
|
||||||
|
while(tcd.checkForTor(error_msg) != TorControlDialog::TOR_STATUS_OK || tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
|
||||||
|
{
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
rstime::rs_usleep(0.2*1000*1000) ;
|
||||||
|
|
||||||
|
if(!error_msg.isNull())
|
||||||
|
{
|
||||||
|
QMessageBox::critical(NULL,QObject::tr("Cannot start Tor"),QObject::tr("Sorry but Tor cannot be started on your system!\n\nThe error reported is:\"")+error_msg+"\"") ;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tcd.hide();
|
||||||
|
|
||||||
|
if(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(NULL,QObject::tr("Cannot start a hidden tor service!"),QObject::tr("It was not possible to start a hidden service.")) ;
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -748,7 +748,7 @@ void Rshare::loadStyleSheet(const QString &sheetName)
|
|||||||
/* external stylesheet */
|
/* external stylesheet */
|
||||||
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()), name, sheetName));
|
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str()), name, sheetName));
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::DataDirectory().c_str()), name, sheetName));
|
file.setFileName(QString("%1/qss/%2%3.qss").arg(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()), name, sheetName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
@ -787,7 +787,7 @@ void Rshare::getAvailableStyleSheets(QMap<QString, QString> &styleSheets)
|
|||||||
styleSheets.insert(name, name);
|
styleSheets.insert(name, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileInfoList = QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
|
fileInfoList = QDir(QString::fromUtf8(RsAccounts::systemDataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
|
||||||
foreach (fileInfo, fileInfoList) {
|
foreach (fileInfo, fileInfoList) {
|
||||||
if (fileInfo.isFile()) {
|
if (fileInfo.isFile()) {
|
||||||
QString name = fileInfo.baseName();
|
QString name = fileInfo.baseName();
|
||||||
|
Loading…
Reference in New Issue
Block a user