summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-18 22:32:37 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-18 22:32:37 +0300
commit4a822253405ed41c70a57356aca0a4cff8defecd (patch)
tree0df076131b864cbb8558accf742f0bee2314f45a /plugins/New_GPG
parent2a6a16162ecc09731974ddca069a4824305f9641 (diff)
NewGPG: fix for hangup during key generation
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-xplugins/New_GPG/src/gpg_wrapper.cpp50
-rw-r--r--plugins/New_GPG/src/gpg_wrapper.h4
-rwxr-xr-xplugins/New_GPG/src/ui.cpp1
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp1
4 files changed, 40 insertions, 16 deletions
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp
index b31dca5475..d7e9677ead 100755
--- a/plugins/New_GPG/src/gpg_wrapper.cpp
+++ b/plugins/New_GPG/src/gpg_wrapper.cpp
@@ -18,6 +18,12 @@
namespace bp = boost::process;
+gpg_execution_params::gpg_execution_params()
+{ }
+
+gpg_execution_params::~gpg_execution_params()
+{ }
+
void pxEexcute_thread(gpg_execution_params *params)
{
if (!globals.gpg_valid)
@@ -64,27 +70,39 @@ void pxEexcute_thread(gpg_execution_params *params)
wchar_t mir_path[MAX_PATH];
PathToAbsoluteW(L"\\", mir_path);
+ bp::child *c;
bp::ipstream perr, pout;
- bp::child c(bin_path.c_str(), argv, bp::windows::hide, bp::std_out > pout, bp::std_err > perr);
- params->child = &c;
- c.wait();
+ if (params->bNoOutput)
+ c = new bp::child(bin_path.c_str(), argv, bp::windows::hide);
+ else
+ c = new bp::child(bin_path.c_str(), argv, bp::windows::hide, bp::std_out > pout, bp::std_err > perr);
+
+ params->child = c;
+ c->wait();
+
+ if (!params->bNoOutput) {
+ std::string s;
+ while (!pout.eof()) {
+ std::getline(pout, s);
+ params->out.Append(s.c_str());
+ params->out.Append("\n");
+ }
- std::string s;
- while (std::getline(pout, s)) {
- params->out.Append(s.c_str());
- params->out.Append("\n");
- }
- while (std::getline(perr, s)) {
- params->out.Append(s.c_str());
- params->out.Append("\n");
- }
- params->out.Replace("\r\r", "");
+ while (!perr.eof()) {
+ std::getline(perr, s);
+ params->out.Append(s.c_str());
+ params->out.Append("\n");
+ }
+
+ params->out.Replace("\r\r", "");
- if (globals.bDebugLog)
- globals.debuglog << "gpg out: " << params->out.c_str();
+ if (globals.bDebugLog)
+ globals.debuglog << "gpg out: " << params->out.c_str();
+ }
- params->code = c.exit_code();
params->child = nullptr;
+ params->code = c->exit_code();
+ delete c;
if (params->code) {
if (globals.bDebugLog)
diff --git a/plugins/New_GPG/src/gpg_wrapper.h b/plugins/New_GPG/src/gpg_wrapper.h
index 2079f7d12d..819bd5c14a 100644
--- a/plugins/New_GPG/src/gpg_wrapper.h
+++ b/plugins/New_GPG/src/gpg_wrapper.h
@@ -34,9 +34,13 @@ enum pxResult
struct gpg_execution_params
{
+ gpg_execution_params();
+ ~gpg_execution_params();
+
std::vector<std::wstring> aargv;
CMStringA out;
DWORD code = 0;
+ int bNoOutput = false;
pxResult result = pxSuccess;
boost::process::child *child = nullptr;
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index a09a973a1c..5c45535c2b 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -983,6 +983,7 @@ bool CDlgKeyGen::OnApply()
params.addParam(L"--yes");
params.addParam(L"--gen-key");
params.addParam(path.c_str());
+ params.bNoOutput = true;
if (!gpg_launcher(params, boost::posix_time::minutes(10)))
return false;
if (params.result == pxNotFound)
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index fc4f39df5c..ec91c56660 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -1682,6 +1682,7 @@ bool gpg_use_new_random_key(const char *account_name)
params.addParam(L"--yes");
params.addParam(L"--gen-key");
params.addParam(path.c_str());
+ params.bNoOutput = true;
if (!gpg_launcher(params, boost::posix_time::minutes(10)))
return false;
if (params.result == pxNotFound)