mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-31 18:36:24 -05:00
Fixed the OSX GPG bug!!!! Turns out that the gpg processes were not being cleaned up,
so RS ended up with 200+ zombie child processes. This prevented gpg from being called. The fix was to add waitpid() calls to cleanup the zombies. * added cleanupZombies() to authgpg.cc (OSX only). * updated OSX gpgme libraries to 1.3.0 (added libassuan to RetroShare.pro). git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3974 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a1154b6935
commit
1f33bdc471
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
const time_t STORE_KEY_TIMEOUT = 1 * 60 * 60; //store key is call around every hour
|
const time_t STORE_KEY_TIMEOUT = 1 * 60 * 60; //store key is call around every hour
|
||||||
|
|
||||||
|
void cleanupZombies(int numkill); // function to cleanup zombies under OSX.
|
||||||
|
|
||||||
//#define GPG_DEBUG 1
|
//#define GPG_DEBUG 1
|
||||||
|
|
||||||
static AuthGPGimpl *instance_gpg = NULL;
|
static AuthGPGimpl *instance_gpg = NULL;
|
||||||
@ -894,6 +896,8 @@ bool AuthGPGimpl::DoOwnSignature(const void *data, unsigned int datalen, void *b
|
|||||||
std::cerr << "Error create Sig" << std::endl;
|
std::cerr << "Error create Sig" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
/* move string data to gpgmeData */
|
/* move string data to gpgmeData */
|
||||||
gpgme_set_armor (CTX, 0);
|
gpgme_set_armor (CTX, 0);
|
||||||
|
|
||||||
@ -995,7 +999,7 @@ bool AuthGPGimpl::VerifySignature(const void *data, int datalen, const void *sig
|
|||||||
std::cerr << "Error create Sig" << std::endl;
|
std::cerr << "Error create Sig" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move string data to gpgmeData */
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
gpgme_set_armor (CTX, 0);
|
gpgme_set_armor (CTX, 0);
|
||||||
|
|
||||||
@ -1083,6 +1087,8 @@ bool AuthGPGimpl::GeneratePGPCertificate(std::string name, std::string email,
|
|||||||
gpgme_genkey_result_t result;
|
gpgme_genkey_result_t result;
|
||||||
gpg_error_t ERR;
|
gpg_error_t ERR;
|
||||||
|
|
||||||
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
|
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
|
||||||
passwd).c_str(), NULL, NULL))) {
|
passwd).c_str(), NULL, NULL))) {
|
||||||
ProcessPGPmeError(ERR);
|
ProcessPGPmeError(ERR);
|
||||||
@ -1207,6 +1213,9 @@ bool AuthGPGimpl::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
|
|||||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||||
gpgme_set_armor (CTX, 1);
|
gpgme_set_armor (CTX, 1);
|
||||||
gpg_error_t ERR;
|
gpg_error_t ERR;
|
||||||
|
|
||||||
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
|
||||||
{
|
{
|
||||||
ProcessPGPmeError(ERR);
|
ProcessPGPmeError(ERR);
|
||||||
@ -1223,6 +1232,10 @@ bool AuthGPGimpl::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
|
|||||||
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
|
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
|
||||||
gpgme_set_armor (CTX, 1);
|
gpgme_set_armor (CTX, 1);
|
||||||
gpg_error_t ERR;
|
gpg_error_t ERR;
|
||||||
|
|
||||||
|
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
|
||||||
|
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_encrypt(CTX, keys, *flags, PLAIN, CIPHER)))
|
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_encrypt(CTX, keys, *flags, PLAIN, CIPHER)))
|
||||||
{
|
{
|
||||||
ProcessPGPmeError(ERR);
|
ProcessPGPmeError(ERR);
|
||||||
@ -2395,3 +2408,48 @@ bool AuthGPGimpl::addService(AuthGPGService *service)
|
|||||||
services.push_back(service);
|
services.push_back(service);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** HACK to Cleanup OSX Zombies *****************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
void cleanupZombies(int numkill)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
pid_t wpid = -1; // any child.
|
||||||
|
int stat_loc = 0;
|
||||||
|
int options = WNOHANG ;
|
||||||
|
|
||||||
|
//std::cerr << "cleanupZombies() checking for dead children";
|
||||||
|
//std::cerr << std::endl;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < numkill; i++)
|
||||||
|
{
|
||||||
|
pid_t childpid = waitpid(wpid, &stat_loc, options);
|
||||||
|
|
||||||
|
if (childpid > 0)
|
||||||
|
{
|
||||||
|
std::cerr << "cleanupZombies() Found stopped child with pid: " << childpid;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//std::cerr << "cleanupZombies() No Zombies around!";
|
||||||
|
//std::cerr << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "cleanupZombies() Killed " << i << " zombies";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ macx {
|
|||||||
|
|
||||||
CONFIG += version_detail_bash_script
|
CONFIG += version_detail_bash_script
|
||||||
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
LIBS += ../../libretroshare/src/lib/libretroshare.a
|
||||||
LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error
|
LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan
|
||||||
LIBS += ../../../miniupnpc-1.0/libminiupnpc.a
|
LIBS += ../../../miniupnpc-1.0/libminiupnpc.a
|
||||||
LIBS += -framework CoreFoundation
|
LIBS += -framework CoreFoundation
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user