mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-12 11:02:30 -04:00
- Enabled compile on Windows (bzip2 library needed).
- Fixed crash after the second call to RsInit::InitRetroShare when keyring does not exist. The instance of AuthSSL was created twice and AuthGPG was deleted without stopping the thread. Stopped the AuthGPG thread on exit of RetroShare. - Added the correct path to the keyring for Windows in RsInit::copyGnuPGKeyrings. - Changed the detection of the portable version on Windows from the file "gpg.exe" to the file "portable". git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5211 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a91e859b66
commit
1885fb66c4
14 changed files with 92 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
|
openpgpsdk/src/src.pro \
|
||||||
libbitdht/src/libbitdht.pro \
|
libbitdht/src/libbitdht.pro \
|
||||||
libretroshare/src/libretroshare.pro \
|
libretroshare/src/libretroshare.pro \
|
||||||
retroshare-gui/src/RetroShare.pro \
|
retroshare-gui/src/RetroShare.pro \
|
||||||
|
|
|
@ -303,6 +303,8 @@ win32 {
|
||||||
ZLIB_DIR = ../../../zlib-1.2.3
|
ZLIB_DIR = ../../../zlib-1.2.3
|
||||||
SSL_DIR = ../../../../OpenSSL
|
SSL_DIR = ../../../../OpenSSL
|
||||||
|
|
||||||
|
OPENPGPSDK_DIR = ../../openpgpsdk/include
|
||||||
|
INCLUDEPATH *= $${OPENPGPSDK_DIR}
|
||||||
|
|
||||||
INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void AuthGPG::init(const std::string& path_to_public_keyring,const std::string&
|
||||||
{
|
{
|
||||||
if(_instance != NULL)
|
if(_instance != NULL)
|
||||||
{
|
{
|
||||||
delete _instance ;
|
exit();
|
||||||
std::cerr << "AuthGPG::init() called twice!" << std::endl ;
|
std::cerr << "AuthGPG::init() called twice!" << std::endl ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,16 @@ void AuthGPG::init(const std::string& path_to_public_keyring,const std::string&
|
||||||
_instance = new AuthGPG(path_to_public_keyring,path_to_secret_keyring) ;
|
_instance = new AuthGPG(path_to_public_keyring,path_to_secret_keyring) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthGPG::exit()
|
||||||
|
{
|
||||||
|
if(_instance != NULL)
|
||||||
|
{
|
||||||
|
_instance->join();
|
||||||
|
delete _instance ;
|
||||||
|
_instance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& path_to_secret_keyring)
|
AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& path_to_secret_keyring)
|
||||||
:p3Config(CONFIG_TYPE_AUTHGPG),
|
:p3Config(CONFIG_TYPE_AUTHGPG),
|
||||||
PGPHandler(path_to_public_keyring,path_to_secret_keyring),
|
PGPHandler(path_to_public_keyring,path_to_secret_keyring),
|
||||||
|
|
|
@ -110,6 +110,7 @@ class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void init(const std::string& path_to_pubring, const std::string& path_to_secring);
|
static void init(const std::string& path_to_pubring, const std::string& path_to_secring);
|
||||||
|
static void exit();
|
||||||
static AuthGPG *getAuthGPG() { return _instance ; }
|
static AuthGPG *getAuthGPG() { return _instance ; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -65,9 +65,12 @@ void setAuthSSL(AuthSSL *newssl)
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthSSLInit()
|
void AuthSSLInit()
|
||||||
|
{
|
||||||
|
if (instance_ssl == NULL)
|
||||||
{
|
{
|
||||||
instance_ssl = new AuthSSLimpl();
|
instance_ssl = new AuthSSLimpl();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AuthSSL *AuthSSL::getAuthSSL()
|
AuthSSL *AuthSSL::getAuthSSL()
|
||||||
{
|
{
|
||||||
|
|
|
@ -193,5 +193,5 @@ void RsServer::rsGlobalShutDown()
|
||||||
#endif
|
#endif
|
||||||
#endif // MINIMAL_LIBRS
|
#endif // MINIMAL_LIBRS
|
||||||
|
|
||||||
// AuthGPGExit();
|
AuthGPG::exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ void RsInit::InitRsConfig()
|
||||||
|
|
||||||
#ifdef WINDOWS_SYS
|
#ifdef WINDOWS_SYS
|
||||||
// test for portable version
|
// test for portable version
|
||||||
if (GetFileAttributes (L"gpg.exe") != (DWORD) -1 && GetFileAttributes (L"gpgme-w32spawn.exe") != (DWORD) -1) {
|
if (GetFileAttributes(L"portable") != (DWORD) -1) {
|
||||||
// use portable version
|
// use portable version
|
||||||
RsInitConfig::portable = true;
|
RsInitConfig::portable = true;
|
||||||
}
|
}
|
||||||
|
@ -718,14 +718,22 @@ bool RsInit::copyGnuPGKeyrings()
|
||||||
if(!RsDirUtil::checkCreateDirectory(pgp_dir))
|
if(!RsDirUtil::checkCreateDirectory(pgp_dir))
|
||||||
throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ;
|
throw std::runtime_error("Cannot create pgp directory " + pgp_dir) ;
|
||||||
|
|
||||||
|
std::string source_public_keyring;
|
||||||
|
std::string source_secret_keyring;
|
||||||
|
|
||||||
#ifdef WINDOWS_SYS
|
#ifdef WINDOWS_SYS
|
||||||
std::cerr << "CRITICAL: UNIMPLEMENTED SECTION FOR WINDOWS - Press ^C to abort" << std::endl;
|
if (RsInit::isPortable())
|
||||||
while(true)
|
{
|
||||||
Sleep(10000) ;
|
source_public_keyring = RsInit::RsConfigDirectory() + "/gnupg/pubring.gpg";
|
||||||
|
source_secret_keyring = RsInit::RsConfigDirectory() + "/gnupg/secring.gpg" ;
|
||||||
|
} else {
|
||||||
|
source_public_keyring = RsInitConfig::basedir + "/../gnupg/pubring.gpg" ;
|
||||||
|
source_secret_keyring = RsInitConfig::basedir + "/../gnupg/secring.gpg" ;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// We need a specific part for MacOS and Linux as well
|
// We need a specific part for MacOS and Linux as well
|
||||||
std::string source_public_keyring = RsInitConfig::basedir + "/../.gnupg/pubring.gpg" ;
|
source_public_keyring = RsInitConfig::basedir + "/../.gnupg/pubring.gpg" ;
|
||||||
std::string source_secret_keyring = RsInitConfig::basedir + "/../.gnupg/secring.gpg" ;
|
source_secret_keyring = RsInitConfig::basedir + "/../.gnupg/secring.gpg" ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!RsDirUtil::copyFile(source_public_keyring,pgp_dir + "/retroshare_public_keyring.gpg"))
|
if(!RsDirUtil::copyFile(source_public_keyring,pgp_dir + "/retroshare_public_keyring.gpg"))
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <openpgpsdk/configure.h>
|
#include <openpgpsdk/configure.h>
|
||||||
#ifdef HAVE_ALLOCA_H
|
#if HAVE_ALLOCA_H
|
||||||
# include <alloca.h>
|
# include <alloca.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -102,11 +102,7 @@ static int encrypted_data_reader(void *dest,size_t length,ops_error_t **errors,
|
||||||
arg->decrypted_count-=n;
|
arg->decrypted_count-=n;
|
||||||
arg->decrypted_offset+=n;
|
arg->decrypted_offset+=n;
|
||||||
length-=n;
|
length-=n;
|
||||||
#ifdef WIN32
|
|
||||||
(char*)dest+=n;
|
|
||||||
#else
|
|
||||||
dest+=n;
|
dest+=n;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <termios.h>
|
||||||
#else
|
#else
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#endif
|
#endif
|
||||||
#include <termios.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -35,6 +35,48 @@
|
||||||
|
|
||||||
#include "parse_local.h"
|
#include "parse_local.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <conio.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define PASS_MAX 512
|
||||||
|
|
||||||
|
char *getpass (const char *prompt)
|
||||||
|
{
|
||||||
|
static char getpassbuf [PASS_MAX + 1];
|
||||||
|
size_t i = 0;
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (prompt) {
|
||||||
|
fputs (prompt, stderr);
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
c = _getch ();
|
||||||
|
if (c == '\r') {
|
||||||
|
getpassbuf [i] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (i < PASS_MAX) {
|
||||||
|
getpassbuf[i++] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= PASS_MAX) {
|
||||||
|
getpassbuf [i] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prompt) {
|
||||||
|
fputs ("\r\n", stderr);
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getpassbuf;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\ingroup Core_Writers
|
\ingroup Core_Writers
|
||||||
\brief Create and initialise cinfo and mem; Set for writing to mem
|
\brief Create and initialise cinfo and mem; Set for writing to mem
|
||||||
|
|
|
@ -10,6 +10,16 @@ DESTDIR = ../lib
|
||||||
DEPENDPATH += .
|
DEPENDPATH += .
|
||||||
INCLUDEPATH += . ../include
|
INCLUDEPATH += . ../include
|
||||||
|
|
||||||
|
#################################### Windows #####################################
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
SSL_DIR = ../../../../OpenSSL
|
||||||
|
ZLIB_DIR = ../../../zlib-1.2.3
|
||||||
|
BZIP_DIR = ../../../bzip2-1.0.6
|
||||||
|
|
||||||
|
INCLUDEPATH += . $${SSL_DIR}/include $${ZLIB_DIR} $${BZIP_DIR}
|
||||||
|
}
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
HEADERS += keyring_local.h parse_local.h
|
HEADERS += keyring_local.h parse_local.h
|
||||||
SOURCES += accumulate.c \
|
SOURCES += accumulate.c \
|
||||||
|
|
|
@ -22,9 +22,11 @@
|
||||||
/** \file
|
/** \file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <openpgpsdk/create.h>
|
#include <openpgpsdk/create.h>
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ win32 {
|
||||||
PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a
|
PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a
|
||||||
|
|
||||||
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
||||||
|
LIBS += ../../openpgpsdk/lib/libops.a -lbz2
|
||||||
LIBS += -L"../../../lib"
|
LIBS += -L"../../../lib"
|
||||||
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
|
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
|
||||||
# added after bitdht
|
# added after bitdht
|
||||||
|
|
|
@ -55,6 +55,7 @@ win32 {
|
||||||
MOC_DIR = temp/moc
|
MOC_DIR = temp/moc
|
||||||
|
|
||||||
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
||||||
|
LIBS += ../../openpgpsdk/lib/libops.a -lbz2
|
||||||
LIBS += -L"../../../lib" -lssl -lcrypto -lpthreadGC2d -lminiupnpc -lz
|
LIBS += -L"../../../lib" -lssl -lcrypto -lpthreadGC2d -lminiupnpc -lz
|
||||||
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
|
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
|
||||||
# added after bitdht
|
# added after bitdht
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue