mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 17:09:34 -05:00
Portable version for Windows.
RetroShare checks for locale gpg.exe and gpgme-w32spawn.exe and if exists, it starts as portable version. Modified version of libgpgme-11.dll needed. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2815 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f88cd1c0aa
commit
e5e43741d6
@ -26,6 +26,8 @@
|
||||
|
||||
#include "authgpg.h"
|
||||
#include <rsiface/rsiface.h>
|
||||
#include <rsiface/rsinit.h>
|
||||
#include <util/rsdir.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
@ -34,7 +36,7 @@
|
||||
|
||||
//#define GPG_DEBUG 1
|
||||
|
||||
// initialisation du pointeur de singleton à zéro
|
||||
// initialisation du pointeur de singleton à zéro
|
||||
AuthGPG *AuthGPG::instance_gpg = new AuthGPG();
|
||||
|
||||
/* Turn a set of parameters into a string */
|
||||
@ -162,23 +164,43 @@ AuthGPG::AuthGPG()
|
||||
return;
|
||||
}
|
||||
|
||||
/* setup the protocol */
|
||||
if (GPG_ERR_NO_ERROR != gpgme_set_protocol(CTX, GPGME_PROTOCOL_OpenPGP))
|
||||
{
|
||||
std::cerr << "Error creating Setting Protocol" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
gpgme_set_passphrase_cb(CTX, pgp_pwd_callback, (void *) NULL);
|
||||
|
||||
gpgmeInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
storeAllKeys_locked();
|
||||
#ifdef GPG_DEBUG
|
||||
printAllKeys_locked();
|
||||
#endif
|
||||
//updateTrustAllKeys_locked();
|
||||
/* Initialize */
|
||||
bool AuthGPG::InitAuth ()
|
||||
{
|
||||
std::string HomeDir;
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
if (RsInit::isPortable ()) {
|
||||
// set home dir of gpg to configdir\gnupg
|
||||
HomeDir = RsInit::RsConfigDirectory() + RsInit::dirSeperator() + "gnupg";
|
||||
|
||||
if (!RsDirUtil::checkCreateDirectory(HomeDir)) {
|
||||
std::cerr << "Error creating gnupg directory" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setup protocol and homedir */
|
||||
if (GPG_ERR_NO_ERROR != gpgme_ctx_set_engine_info(CTX, GPGME_PROTOCOL_OpenPGP, NULL, HomeDir.empty () ? NULL : HomeDir.c_str ()))
|
||||
{
|
||||
std::cerr << "Error creating Setting Protocol" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
gpgmeInit = true;
|
||||
|
||||
storeAllKeys_locked();
|
||||
#ifdef GPG_DEBUG
|
||||
printAllKeys_locked();
|
||||
#endif
|
||||
//updateTrustAllKeys_locked();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This function is called when retroshare is first started
|
||||
|
@ -145,6 +145,9 @@ class AuthGPG : public p3Config
|
||||
****/
|
||||
bool active();
|
||||
|
||||
/* Initialize */
|
||||
bool InitAuth ();
|
||||
|
||||
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
||||
int GPGInit(std::string ownId);
|
||||
bool CloseAuth();
|
||||
|
@ -43,6 +43,8 @@ class RsInit
|
||||
/* PreLogin */
|
||||
static void InitRsConfig() ;
|
||||
static int InitRetroShare(int argc, char **argv);
|
||||
static char dirSeperator();
|
||||
static bool isPortable();
|
||||
|
||||
|
||||
/* Account Details (Combined GPG+SSL Setup) */
|
||||
|
@ -70,6 +70,9 @@ class RsInitConfig
|
||||
/* Directories (SetupBaseDir) */
|
||||
static std::string basedir;
|
||||
static std::string homePath;
|
||||
#ifdef WINDOWS_SYS
|
||||
static bool portable;
|
||||
#endif
|
||||
|
||||
static std::list<accountId> accountIds;
|
||||
static std::string preferedId;
|
||||
@ -148,6 +151,9 @@ char RsInitConfig::dirSeperator;
|
||||
/* Directories */
|
||||
std::string RsInitConfig::basedir;
|
||||
std::string RsInitConfig::homePath;
|
||||
#ifdef WINDOWS_SYS
|
||||
bool RsInitConfig::portable = false;
|
||||
#endif
|
||||
|
||||
/* Listening Port */
|
||||
bool RsInitConfig::forceExtPort;
|
||||
@ -202,10 +208,16 @@ void RsInit::InitRsConfig()
|
||||
RsInitConfig::debugLevel = PQL_WARNING;
|
||||
RsInitConfig::udpListenerOnly = false;
|
||||
|
||||
RsInitConfig::/* setup the homePath (default save location) */
|
||||
|
||||
/* setup the homePath (default save location) */
|
||||
RsInitConfig::homePath = getHomePath();
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
// test for portable version
|
||||
if (GetFileAttributes ("gpg.exe") != -1 && GetFileAttributes ("gpgme-w32spawn.exe") != -1) {
|
||||
// use portable version
|
||||
RsInitConfig::portable = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Setup the Debugging */
|
||||
// setup debugging for desired zones.
|
||||
@ -482,6 +494,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored)
|
||||
// first check config directories, and set bootstrap values.
|
||||
setupBaseDir();
|
||||
get_configinit(RsInitConfig::basedir, RsInitConfig::preferedId);
|
||||
|
||||
/* Initialize AuthGPG */
|
||||
AuthGPG::getAuthGPG()->InitAuth();
|
||||
|
||||
//std::list<accountId> ids;
|
||||
std::list<accountId>::iterator it;
|
||||
getAvailableAccounts(RsInitConfig::accountIds);
|
||||
@ -629,35 +645,40 @@ void RsInit::setupBaseDir()
|
||||
RsInitConfig::basedir = h;
|
||||
RsInitConfig::basedir += "/.retroshare";
|
||||
#else
|
||||
char *h = getenv("APPDATA");
|
||||
std::cerr << "retroShare::basedir() -> $APPDATA = ";
|
||||
std::cerr << h << std::endl;
|
||||
char *h2 = getenv("HOMEDRIVE");
|
||||
std::cerr << "retroShare::basedir() -> $HOMEDRIVE = ";
|
||||
std::cerr << h2 << std::endl;
|
||||
char *h3 = getenv("HOMEPATH");
|
||||
std::cerr << "retroShare::basedir() -> $HOMEPATH = ";
|
||||
std::cerr << h3 << std::endl;
|
||||
if (h == NULL)
|
||||
{
|
||||
// generating default
|
||||
std::cerr << "load_check_basedir() getEnv Error --Win95/98?";
|
||||
std::cerr << std::endl;
|
||||
if (RsInitConfig::portable) {
|
||||
// use directory "Data" in portable version
|
||||
RsInitConfig::basedir = "Data";
|
||||
} else {
|
||||
char *h = getenv("APPDATA");
|
||||
std::cerr << "retroShare::basedir() -> $APPDATA = ";
|
||||
std::cerr << h << std::endl;
|
||||
char *h2 = getenv("HOMEDRIVE");
|
||||
std::cerr << "retroShare::basedir() -> $HOMEDRIVE = ";
|
||||
std::cerr << h2 << std::endl;
|
||||
char *h3 = getenv("HOMEPATH");
|
||||
std::cerr << "retroShare::basedir() -> $HOMEPATH = ";
|
||||
std::cerr << h3 << std::endl;
|
||||
if (h == NULL)
|
||||
{
|
||||
// generating default
|
||||
std::cerr << "load_check_basedir() getEnv Error --Win95/98?";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsInitConfig::basedir="C:\\Retro";
|
||||
RsInitConfig::basedir="C:\\Retro";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
RsInitConfig::basedir = h;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RsInitConfig::basedir = h;
|
||||
}
|
||||
|
||||
if (!RsDirUtil::checkCreateDirectory(RsInitConfig::basedir))
|
||||
{
|
||||
std::cerr << "Cannot Create BaseConfig Dir" << std::endl;
|
||||
exit(1);
|
||||
if (!RsDirUtil::checkCreateDirectory(RsInitConfig::basedir))
|
||||
{
|
||||
std::cerr << "Cannot Create BaseConfig Dir" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
RsInitConfig::basedir += "\\RetroShare";
|
||||
}
|
||||
RsInitConfig::basedir += "\\RetroShare";
|
||||
#endif
|
||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
}
|
||||
@ -1756,6 +1777,16 @@ bool RsInit::RsClearAutoLogin()
|
||||
|
||||
|
||||
|
||||
char RsInit::dirSeperator()
|
||||
{
|
||||
return RsInitConfig::dirSeperator;
|
||||
}
|
||||
|
||||
bool RsInit::isPortable()
|
||||
{
|
||||
return RsInitConfig::portable;
|
||||
}
|
||||
|
||||
std::string RsInit::RsConfigDirectory()
|
||||
{
|
||||
return RsInitConfig::basedir;
|
||||
|
Loading…
Reference in New Issue
Block a user