From 9f7e9517a6666d86aad598ea39ddfa3acbb20bc4 Mon Sep 17 00:00:00 2001 From: joss17 Date: Thu, 8 Apr 2010 19:27:44 +0000 Subject: [PATCH] block the notify callback of authgpg when the main windows is launched Conflicts: libretroshare/src/pqi/authgpg.cc git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2699 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/authgpg.cc | 15 ++++++++++++--- libretroshare/src/pqi/authgpg.h | 5 +++++ libretroshare/src/rsserver/rsinit.cc | 21 ++------------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index d7103d775..2556681a4 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -88,7 +88,7 @@ gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passp #endif text = gpg_password_static; } else { - if(prev_was_bad) { + if(prev_was_bad || !AuthGPG::getAuthGPG()->getAutorisePasswordCallbackNotify()) { #ifdef GPG_DEBUG fprintf(stderr, "pgp_pwd_callback() allow only one try to be consistent with gpg agent.\n"); #endif @@ -124,7 +124,7 @@ static char *PgpPassword = NULL; AuthGPG::AuthGPG() - :gpgmeInit(false),gpgmeKeySelected(false),p3Config(CONFIG_TYPE_AUTHGPG) + :gpgmeInit(false),gpgmeKeySelected(false),autorisePasswordCallbackNotify(true),p3Config(CONFIG_TYPE_AUTHGPG) { RsStackMutex stack(pgpMtx); /******* LOCKED ******/ @@ -274,7 +274,7 @@ int AuthGPG::GPGInit(std::string ownId) { RsStackMutex stack(pgpMtx); /******* LOCKED ******/ std::cerr << "AuthGPG::GPGInit() called with own gpg id : " << ownId << std::endl; - + is_set_gpg_password_static= false; if (!gpgmeInit) { return 0; } @@ -2142,3 +2142,12 @@ bool AuthGPG::loadList(std::list load) } return true; } + +void AuthGPG::setAutorisePasswordCallbackNotify(bool autorise) { + autorisePasswordCallbackNotify = autorise; + return; +} + +bool AuthGPG::getAutorisePasswordCallbackNotify() { + return autorisePasswordCallbackNotify; +} diff --git a/libretroshare/src/pqi/authgpg.h b/libretroshare/src/pqi/authgpg.h index 322db7f70..ec01e43b4 100644 --- a/libretroshare/src/pqi/authgpg.h +++ b/libretroshare/src/pqi/authgpg.h @@ -120,6 +120,9 @@ class AuthGPG : public p3Config bool printKeys(); + void setAutorisePasswordCallbackNotify(bool); + bool getAutorisePasswordCallbackNotify(); + /*********************************************************************************/ /************************* STAGE 1 ***********************************************/ /*********************************************************************************/ @@ -239,6 +242,8 @@ private: bool gpgmeInit; bool gpgmeKeySelected; + + bool autorisePasswordCallbackNotify; gpgme_engine_info_t INFO; gpgme_ctx_t CTX; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 855618418..ec519d829 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -824,25 +824,6 @@ bool RsInit::SelectGPGAccount(std::string id) } -//bool RsInit::LoadGPGPassword(std::string inPGPpasswd) -//{ -// -// bool ok = false; -// if (0 < AuthGPG::getAuthGPG() -> LoadGPGPassword(inPGPpasswd)) -// { -// ok = true; -// std::cerr << "PGP LoadPwd Success!"; -// std::cerr << std::endl; -// } -// else -// { -// std::cerr << "PGP LoadPwd Failed!"; -// std::cerr << std::endl; -// } -// return ok; -//} - - bool RsInit::GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString) { return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString); } @@ -1185,6 +1166,8 @@ int RsInit::LoadCertificates(bool autoLoginNT) /* wipe password */ RsInitConfig::passwd = ""; create_configinit(RsInitConfig::basedir, RsInitConfig::preferedId); + //don't autorise the password callback again because it will lead to deadlock due to QT reentrance + AuthGPG::getAuthGPG()->setAutorisePasswordCallbackNotify(false); return 1; }