mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-04 21:17:43 +03:00
Add option to use both Pageant and OpenSSH agent on Windows
This commit is contained in:
parent
250cd1933c
commit
d2c74340a3
6 changed files with 44 additions and 6 deletions
|
@ -72,10 +72,20 @@ bool SSHAgent::useOpenSSH() const
|
|||
return config()->get(Config::SSHAgent_UseOpenSSH).toBool();
|
||||
}
|
||||
|
||||
bool SSHAgent::usePageant() const
|
||||
{
|
||||
return config()->get(Config::SSHAgent_UsePageant).toBool();
|
||||
}
|
||||
|
||||
void SSHAgent::setUseOpenSSH(bool useOpenSSH)
|
||||
{
|
||||
config()->set(Config::SSHAgent_UseOpenSSH, useOpenSSH);
|
||||
}
|
||||
|
||||
void SSHAgent::setUsePageant(bool usePageant)
|
||||
{
|
||||
config()->set(Config::SSHAgent_UsePageant, usePageant);
|
||||
}
|
||||
#endif
|
||||
|
||||
QString SSHAgent::socketPath(bool allowOverride) const
|
||||
|
@ -110,10 +120,14 @@ bool SSHAgent::isAgentRunning() const
|
|||
QFileInfo socketFileInfo(socketPath());
|
||||
return !socketFileInfo.path().isEmpty() && socketFileInfo.exists();
|
||||
#else
|
||||
if (!useOpenSSH()) {
|
||||
if (usePageant() && useOpenSSH()) {
|
||||
return (FindWindowA("Pageant", "Pageant") != nullptr) && WaitNamedPipe(socketPath().toLatin1().data(), 100);
|
||||
} else if (useOpenSSH()) {
|
||||
return WaitNamedPipe(socketPath().toLatin1().data(), 100);
|
||||
} else if (usePageant()) {
|
||||
return (FindWindowA("Pageant", "Pageant") != nullptr);
|
||||
} else {
|
||||
return WaitNamedPipe(socketPath().toLatin1().data(), 100);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -121,11 +135,20 @@ bool SSHAgent::isAgentRunning() const
|
|||
bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if (!useOpenSSH()) {
|
||||
return sendMessagePageant(in, out);
|
||||
if (usePageant() && !sendMessagePageant(in, out)) {
|
||||
return false;
|
||||
}
|
||||
if (useOpenSSH() && !sendMessageOpenSSH(in, out)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
return sendMessageOpenSSH(in, out);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SSHAgent::sendMessageOpenSSH(const QByteArray& in, QByteArray& out)
|
||||
{
|
||||
QLocalSocket socket;
|
||||
BinaryStream stream(&socket);
|
||||
|
||||
|
@ -144,7 +167,6 @@ bool SSHAgent::sendMessage(const QByteArray& in, QByteArray& out)
|
|||
}
|
||||
|
||||
socket.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue