Implement SSH key file path env substitution

Supports all platforms, including Windows with %FOO% syntax.

Fixes #3523
This commit is contained in:
Toni Spets 2019-11-02 11:25:13 +02:00 committed by Jonathan White
parent 47ce81c9a6
commit 6fc7be78ea
6 changed files with 56 additions and 1 deletions

View file

@ -17,6 +17,7 @@
*/
#include "KeeAgentSettings.h"
#include "core/Tools.h"
KeeAgentSettings::KeeAgentSettings()
: m_lifetimeConstraintDuration(600)
@ -115,6 +116,11 @@ const QString KeeAgentSettings::fileName() const
return m_fileName;
}
const QString KeeAgentSettings::fileNameEnvSubst(QProcessEnvironment environment) const
{
return Tools::envSubstitute(m_fileName, environment);
}
void KeeAgentSettings::setAllowUseOfSshKey(bool allowUseOfSshKey)
{
m_allowUseOfSshKey = allowUseOfSshKey;
@ -361,7 +367,7 @@ bool KeeAgentSettings::toOpenSSHKey(const Entry* entry, OpenSSHKey& key, bool de
fileName = m_attachmentName;
privateKeyData = entry->attachments()->value(fileName);
} else {
QFile localFile(m_fileName);
QFile localFile(fileNameEnvSubst());
QFileInfo localFileInfo(localFile);
fileName = localFileInfo.fileName();

View file

@ -54,6 +54,7 @@ public:
const QString attachmentName() const;
bool saveAttachmentToTempFile() const;
const QString fileName() const;
const QString fileNameEnvSubst(QProcessEnvironment environment = QProcessEnvironment::systemEnvironment()) const;
void setAllowUseOfSshKey(bool allowUseOfSshKey);
void setAddAtDatabaseOpen(bool addAtDatabaseOpen);