diff --git a/src/browser/NativeMessagingBase.cpp b/src/browser/NativeMessagingBase.cpp index f61a36045..7c0760de3 100644 --- a/src/browser/NativeMessagingBase.cpp +++ b/src/browser/NativeMessagingBase.cpp @@ -36,14 +36,16 @@ #include #endif -NativeMessagingBase::NativeMessagingBase() +NativeMessagingBase::NativeMessagingBase(const bool enabled) { #ifdef Q_OS_WIN _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); #else - m_notifier.reset(new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this)); - connect(m_notifier.data(), SIGNAL(activated(int)), this, SLOT(newNativeMessage())); + if (enabled) { + m_notifier.reset(new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this)); + connect(m_notifier.data(), SIGNAL(activated(int)), this, SLOT(newNativeMessage())); + } #endif } diff --git a/src/browser/NativeMessagingBase.h b/src/browser/NativeMessagingBase.h index 26e0a9902..2cd63d24c 100644 --- a/src/browser/NativeMessagingBase.h +++ b/src/browser/NativeMessagingBase.h @@ -44,7 +44,7 @@ class NativeMessagingBase : public QObject Q_OBJECT public: - explicit NativeMessagingBase(); + explicit NativeMessagingBase(const bool enabled); ~NativeMessagingBase() = default; protected slots: diff --git a/src/browser/NativeMessagingHost.cpp b/src/browser/NativeMessagingHost.cpp index d607698b7..db1a1319d 100755 --- a/src/browser/NativeMessagingHost.cpp +++ b/src/browser/NativeMessagingHost.cpp @@ -27,8 +27,8 @@ #include #endif -NativeMessagingHost::NativeMessagingHost(DatabaseTabWidget* parent) : - NativeMessagingBase(), +NativeMessagingHost::NativeMessagingHost(DatabaseTabWidget* parent, const bool enabled) : + NativeMessagingBase(enabled), m_mutex(QMutex::Recursive), m_browserClients(m_browserService), m_browserService(parent) @@ -77,6 +77,11 @@ void NativeMessagingHost::run() QString serverPath = getLocalServerPath(); QFile::remove(serverPath); + // Ensure that STDIN is not being listened when proxy is used + if (m_notifier->isEnabled()) { + m_notifier->setEnabled(false); + } + if (m_localServer->isListening()) { m_localServer->close(); } diff --git a/src/browser/NativeMessagingHost.h b/src/browser/NativeMessagingHost.h index 80825237b..cc0a2e84c 100755 --- a/src/browser/NativeMessagingHost.h +++ b/src/browser/NativeMessagingHost.h @@ -31,7 +31,7 @@ class NativeMessagingHost : public NativeMessagingBase typedef QList SocketList; public: - explicit NativeMessagingHost(DatabaseTabWidget* parent = 0); + explicit NativeMessagingHost(DatabaseTabWidget* parent = 0, const bool enabled = false); ~NativeMessagingHost(); int init(); void run(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index d7dadb0c0..2e87b4d8c 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -117,7 +117,7 @@ class BrowserPlugin: public ISettingsPage { public: BrowserPlugin(DatabaseTabWidget* tabWidget) { - m_nativeMessagingHost = QSharedPointer(new NativeMessagingHost(tabWidget)); + m_nativeMessagingHost = QSharedPointer(new NativeMessagingHost(tabWidget, BrowserSettings::isEnabled())); } ~BrowserPlugin() { diff --git a/src/proxy/NativeMessagingHost.cpp b/src/proxy/NativeMessagingHost.cpp index aabeb01af..a0d713d0c 100755 --- a/src/proxy/NativeMessagingHost.cpp +++ b/src/proxy/NativeMessagingHost.cpp @@ -22,7 +22,7 @@ #include #endif -NativeMessagingHost::NativeMessagingHost() : NativeMessagingBase() +NativeMessagingHost::NativeMessagingHost() : NativeMessagingBase(true) { m_localSocket = new QLocalSocket(); m_localSocket->connectToServer(getLocalServerPath());