mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-24 09:11:11 -04:00
Merge branch 'develop'
Conflicts: src/core/Tools.cpp src/sshagent/SSHAgent.cpp
This commit is contained in:
commit
21de6f6163
57 changed files with 1296 additions and 395 deletions
|
@ -26,6 +26,9 @@ AgentSettingsWidget::AgentSettingsWidget(QWidget* parent)
|
|||
, m_ui(new Ui::AgentSettingsWidget())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
#ifndef Q_OS_WIN
|
||||
m_ui->useOpenSSHCheckBox->setVisible(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
AgentSettingsWidget::~AgentSettingsWidget()
|
||||
|
@ -35,9 +38,15 @@ AgentSettingsWidget::~AgentSettingsWidget()
|
|||
void AgentSettingsWidget::loadSettings()
|
||||
{
|
||||
m_ui->enableSSHAgentCheckBox->setChecked(config()->get("SSHAgent", false).toBool());
|
||||
#ifdef Q_OS_WIN
|
||||
m_ui->useOpenSSHCheckBox->setChecked(config()->get("SSHAgentOpenSSH", false).toBool());
|
||||
#endif
|
||||
}
|
||||
|
||||
void AgentSettingsWidget::saveSettings()
|
||||
{
|
||||
config()->set("SSHAgent", m_ui->enableSSHAgentCheckBox->isChecked());
|
||||
#ifdef Q_OS_WIN
|
||||
config()->set("SSHAgentOpenSSH", m_ui->useOpenSSHCheckBox->isChecked());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -30,6 +30,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useOpenSSHCheckBox">
|
||||
<property name="text">
|
||||
<string>Use OpenSSH for Windows instead of Pageant</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -21,10 +21,11 @@
|
|||
#include "crypto/ssh/OpenSSHKey.h"
|
||||
#include "crypto/ssh/BinaryStream.h"
|
||||
#include "sshagent/KeeAgentSettings.h"
|
||||
#include "core/Config.h"
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#include <QtNetwork>
|
||||
#else
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
@ -35,6 +36,8 @@ SSHAgent::SSHAgent(QObject* parent)
|
|||
{
|
||||
#ifndef Q_OS_WIN
|
||||
m_socketPath = QProcessEnvironment::systemEnvironment().value("SSH_AUTH_SOCK");
|
||||
#else
|
||||
m_socketPath = "\\\\.\\pipe\\openssh-ssh-agent";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -72,13 +75,22 @@ bool SSHAgent::isAgentRunning() const
|
|||
#ifndef Q_OS_WIN
|
||||
return !m_socketPath.isEmpty();
|
||||
#else
|
||||
return (FindWindowA("Pageant", "Pageant") != nullptr);
|
||||
if (!config()->get("SSHAgentOpenSSH").toBool()) {
|
||||
return (FindWindowA("Pageant", "Pageant") != nullptr);
|
||||
} else {
|
||||
return WaitNamedPipe(m_socketPath.toLatin1().data(), 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
if (!config()->get("SSHAgentOpenSSH").toBool()) {
|
||||
return sendMessagePageant(in, out);
|
||||
}
|
||||
#endif
|
||||
|
||||
QLocalSocket socket;
|
||||
BinaryStream stream(&socket);
|
||||
|
||||
|
@ -99,7 +111,11 @@ bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
|
|||
socket.close();
|
||||
|
||||
return true;
|
||||
#else
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool SSHAgent::sendMessagePageant(const QByteArray& in, QByteArray& out)
|
||||
{
|
||||
HWND hWnd = FindWindowA("Pageant", "Pageant");
|
||||
|
||||
if (!hWnd) {
|
||||
|
@ -159,8 +175,8 @@ bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
|
|||
CloseHandle(handle);
|
||||
|
||||
return (res > 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add the identity to the SSH agent.
|
||||
|
|
|
@ -62,12 +62,14 @@ private:
|
|||
~SSHAgent();
|
||||
|
||||
bool sendMessage(const QByteArray& in, QByteArray& out);
|
||||
#ifdef Q_OS_WIN
|
||||
bool sendMessagePageant(const QByteArray& in, QByteArray& out);
|
||||
#endif
|
||||
|
||||
static SSHAgent* m_instance;
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QString m_socketPath;
|
||||
#else
|
||||
#ifdef Q_OS_WIN
|
||||
const quint32 AGENT_MAX_MSGLEN = 8192;
|
||||
const quint32 AGENT_COPYDATA_ID = 0x804e50ba;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue