mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Disable STDIN listening when not needed
This commit is contained in:
parent
13a313ff66
commit
9d7e7c1ca8
@ -36,14 +36,16 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NativeMessagingBase::NativeMessagingBase()
|
NativeMessagingBase::NativeMessagingBase(const bool enabled)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
_setmode(_fileno(stdin), _O_BINARY);
|
_setmode(_fileno(stdin), _O_BINARY);
|
||||||
_setmode(_fileno(stdout), _O_BINARY);
|
_setmode(_fileno(stdout), _O_BINARY);
|
||||||
#else
|
#else
|
||||||
m_notifier.reset(new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this));
|
if (enabled) {
|
||||||
connect(m_notifier.data(), SIGNAL(activated(int)), this, SLOT(newNativeMessage()));
|
m_notifier.reset(new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this));
|
||||||
|
connect(m_notifier.data(), SIGNAL(activated(int)), this, SLOT(newNativeMessage()));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class NativeMessagingBase : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NativeMessagingBase();
|
explicit NativeMessagingBase(const bool enabled);
|
||||||
~NativeMessagingBase() = default;
|
~NativeMessagingBase() = default;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include <Winsock2.h>
|
#include <Winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NativeMessagingHost::NativeMessagingHost(DatabaseTabWidget* parent) :
|
NativeMessagingHost::NativeMessagingHost(DatabaseTabWidget* parent, const bool enabled) :
|
||||||
NativeMessagingBase(),
|
NativeMessagingBase(enabled),
|
||||||
m_mutex(QMutex::Recursive),
|
m_mutex(QMutex::Recursive),
|
||||||
m_browserClients(m_browserService),
|
m_browserClients(m_browserService),
|
||||||
m_browserService(parent)
|
m_browserService(parent)
|
||||||
@ -77,6 +77,11 @@ void NativeMessagingHost::run()
|
|||||||
QString serverPath = getLocalServerPath();
|
QString serverPath = getLocalServerPath();
|
||||||
QFile::remove(serverPath);
|
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()) {
|
if (m_localServer->isListening()) {
|
||||||
m_localServer->close();
|
m_localServer->close();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class NativeMessagingHost : public NativeMessagingBase
|
|||||||
typedef QList<QLocalSocket*> SocketList;
|
typedef QList<QLocalSocket*> SocketList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NativeMessagingHost(DatabaseTabWidget* parent = 0);
|
explicit NativeMessagingHost(DatabaseTabWidget* parent = 0, const bool enabled = false);
|
||||||
~NativeMessagingHost();
|
~NativeMessagingHost();
|
||||||
int init();
|
int init();
|
||||||
void run();
|
void run();
|
||||||
|
@ -117,7 +117,7 @@ class BrowserPlugin: public ISettingsPage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BrowserPlugin(DatabaseTabWidget* tabWidget) {
|
BrowserPlugin(DatabaseTabWidget* tabWidget) {
|
||||||
m_nativeMessagingHost = QSharedPointer<NativeMessagingHost>(new NativeMessagingHost(tabWidget));
|
m_nativeMessagingHost = QSharedPointer<NativeMessagingHost>(new NativeMessagingHost(tabWidget, BrowserSettings::isEnabled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
~BrowserPlugin() {
|
~BrowserPlugin() {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <Winsock2.h>
|
#include <Winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NativeMessagingHost::NativeMessagingHost() : NativeMessagingBase()
|
NativeMessagingHost::NativeMessagingHost() : NativeMessagingBase(true)
|
||||||
{
|
{
|
||||||
m_localSocket = new QLocalSocket();
|
m_localSocket = new QLocalSocket();
|
||||||
m_localSocket->connectToServer(getLocalServerPath());
|
m_localSocket->connectToServer(getLocalServerPath());
|
||||||
|
Loading…
Reference in New Issue
Block a user