forked from qt-creator/qt-creator
Ssh: Use FilePath for SshConnectionParameters::privateKeyFile
Change-Id: Ifaf97cc744f80e1fa0f4000aabf83671b2ffd972 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -130,7 +130,7 @@ struct SshConnection::SshConnectionPrivate
|
||||
SshConnectionParameters::AuthenticationTypeSpecificKey;
|
||||
if (keyOnly) {
|
||||
args << "-o" << "IdentitiesOnly=yes";
|
||||
args << "-i" << connParams.privateKeyFile;
|
||||
args << "-i" << connParams.privateKeyFile.path();
|
||||
}
|
||||
if (keyOnly || SshSettings::askpassFilePath().isEmpty())
|
||||
args << "-o" << "BatchMode=yes";
|
||||
|
||||
@@ -28,20 +28,19 @@
|
||||
#include "sftpdefs.h"
|
||||
#include "ssh_global.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/processutils.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QFlags>
|
||||
#include <QHostAddress>
|
||||
#include <QMetaType>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QHostAddress>
|
||||
#include <QUrl>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace QSsh {
|
||||
class SshRemoteProcess;
|
||||
|
||||
@@ -69,7 +68,7 @@ public:
|
||||
void setUserName(const QString &name) { url.setUserName(name); }
|
||||
|
||||
QUrl url;
|
||||
QString privateKeyFile;
|
||||
Utils::FilePath privateKeyFile;
|
||||
QString x11DisplayName;
|
||||
int timeout = 0; // In seconds.
|
||||
AuthenticationType authenticationType = AuthenticationTypeAll;
|
||||
|
||||
@@ -625,7 +625,8 @@ void IDevice::fromMap(const QVariantMap &map)
|
||||
? QSsh::SshConnectionParameters::AuthenticationTypeAll
|
||||
: static_cast<AuthType>(storedAuthType);
|
||||
|
||||
d->sshParameters.privateKeyFile = map.value(QLatin1String(KeyFileKey), defaultPrivateKeyFilePath()).toString();
|
||||
d->sshParameters.privateKeyFile =
|
||||
FilePath::fromVariant(map.value(QLatin1String(KeyFileKey), defaultPrivateKeyFilePath()));
|
||||
d->sshParameters.timeout = map.value(QLatin1String(TimeoutKey), DefaultTimeout).toInt();
|
||||
d->sshParameters.hostKeyCheckingMode = static_cast<QSsh::SshHostKeyCheckingMode>
|
||||
(map.value(QLatin1String(HostKeyCheckingKey), QSsh::SshHostKeyCheckingNone).toInt());
|
||||
@@ -661,7 +662,7 @@ QVariantMap IDevice::toMap() const
|
||||
map.insert(QLatin1String(SshPortKey), d->sshParameters.port());
|
||||
map.insert(QLatin1String(UserNameKey), d->sshParameters.userName());
|
||||
map.insert(QLatin1String(AuthKey), d->sshParameters.authenticationType);
|
||||
map.insert(QLatin1String(KeyFileKey), d->sshParameters.privateKeyFile);
|
||||
map.insert(QLatin1String(KeyFileKey), d->sshParameters.privateKeyFile.toVariant());
|
||||
map.insert(QLatin1String(TimeoutKey), d->sshParameters.timeout);
|
||||
map.insert(QLatin1String(HostKeyCheckingKey), d->sshParameters.hostKeyCheckingMode);
|
||||
|
||||
|
||||
@@ -1067,7 +1067,7 @@ void DeviceKitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *expande
|
||||
expander->registerVariable("Device:KeyFile", tr("Private key file"),
|
||||
[kit]() -> QString {
|
||||
const IDevice::ConstPtr device = DeviceKitAspect::device(kit);
|
||||
return device ? device->sshParameters().privateKeyFile : QString();
|
||||
return device ? device->sshParameters().privateKeyFile.toString() : QString();
|
||||
});
|
||||
expander->registerVariable("Device:Name", tr("Device name"),
|
||||
[kit]() -> QString {
|
||||
@@ -1294,7 +1294,7 @@ void BuildDeviceKitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *ex
|
||||
expander->registerVariable("BuildDevice:KeyFile", tr("Build private key file"),
|
||||
[kit]() -> QString {
|
||||
const IDevice::ConstPtr device = BuildDeviceKitAspect::device(kit);
|
||||
return device ? device->sshParameters().privateKeyFile : QString();
|
||||
return device ? device->sshParameters().privateKeyFile.toString() : QString();
|
||||
});
|
||||
expander->registerVariable("BuildDevice:Name", tr("Build device name"),
|
||||
[kit]() -> QString {
|
||||
|
||||
@@ -123,7 +123,7 @@ void GenericLinuxDeviceConfigurationWidget::userNameEditingFinished()
|
||||
void GenericLinuxDeviceConfigurationWidget::keyFileEditingFinished()
|
||||
{
|
||||
SshConnectionParameters sshParams = device()->sshParameters();
|
||||
sshParams.privateKeyFile = m_ui->keyFileLineEdit->filePath().toString();
|
||||
sshParams.privateKeyFile = m_ui->keyFileLineEdit->filePath();
|
||||
device()->setSshParameters(sshParams);
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ void GenericLinuxDeviceConfigurationWidget::initGui()
|
||||
m_ui->portsLineEdit->setText(device()->freePorts().toString());
|
||||
m_ui->timeoutSpinBox->setValue(sshParams.timeout);
|
||||
m_ui->userLineEdit->setText(sshParams.userName());
|
||||
m_ui->keyFileLineEdit->setPath(sshParams.privateKeyFile);
|
||||
m_ui->keyFileLineEdit->setFilePath(sshParams.privateKeyFile);
|
||||
m_ui->gdbServerLineEdit->setText(device()->debugServerPath().toString());
|
||||
updatePortsWarningLabel();
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ bool GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::validatePage()
|
||||
if (!d->defaultKeys().contains(d->keyFileChooser.filePath().toString())) {
|
||||
SshConnectionParameters sshParams = d->device->sshParameters();
|
||||
sshParams.authenticationType = SshConnectionParameters::AuthenticationTypeSpecificKey;
|
||||
sshParams.privateKeyFile = d->keyFileChooser.filePath().toString();
|
||||
sshParams.privateKeyFile = d->keyFileChooser.filePath();
|
||||
d->device->setSshParameters(sshParams);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -49,7 +49,7 @@ using namespace Internal;
|
||||
PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(
|
||||
const IDevice::ConstPtr &deviceConfig, QWidget *parent)
|
||||
{
|
||||
const FilePath dir = FilePath::fromString(deviceConfig->sshParameters().privateKeyFile).parentDir();
|
||||
const FilePath dir = deviceConfig->sshParameters().privateKeyFile.parentDir();
|
||||
const FilePath publicKeyFileName = FileUtils::getOpenFilePath(nullptr,
|
||||
tr("Choose Public Key File"), dir,
|
||||
tr("Public Key Files (*.pub);;All Files (*)"));
|
||||
|
||||
@@ -95,7 +95,7 @@ static SshConnectionParameters getParameters()
|
||||
params.setPort(getPortFromEnvironment());
|
||||
params.setUserName(getUserFromEnvironment());
|
||||
params.timeout = 10;
|
||||
params.privateKeyFile = getKeyFileFromEnvironment();
|
||||
params.privateKeyFile = Utils::FilePath::fromUserInput(getKeyFileFromEnvironment());
|
||||
params.authenticationType = !params.privateKeyFile.isEmpty()
|
||||
? SshConnectionParameters::AuthenticationTypeSpecificKey
|
||||
: SshConnectionParameters::AuthenticationTypeAll;
|
||||
@@ -185,7 +185,7 @@ void tst_Ssh::errorHandling()
|
||||
params.setUserName(user);
|
||||
params.timeout = 3;
|
||||
params.authenticationType = authType;
|
||||
params.privateKeyFile = keyFile;
|
||||
params.privateKeyFile = Utils::FilePath::fromString(keyFile);
|
||||
SshConnection connection(params);
|
||||
QEventLoop loop;
|
||||
bool disconnected = false;
|
||||
|
||||
Reference in New Issue
Block a user