Merge branch 'develop'

Conflicts:
	src/core/Tools.cpp
	src/sshagent/SSHAgent.cpp
This commit is contained in:
Jonathan White 2018-12-30 16:32:57 -05:00
commit 21de6f6163
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
57 changed files with 1296 additions and 395 deletions

View file

@ -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.