Commit a167286b authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Ssh: Get confirmation from user for overwriting an existing key.

Change-Id: I3d74423ef647fd59d303517b0a0e987b24973095
Reviewed-by: default avatarRobert Loehning <>
parent 6c12a060
......@@ -69,6 +69,9 @@ void SshKeyCreationDialog::keyTypeChanged()
void SshKeyCreationDialog::generateKeys()
if (userForbidsOverwriting())
const SshKeyGenerator::KeyType keyType = m_ui->rsa->isChecked()
? SshKeyGenerator::Rsa
: SshKeyGenerator::Dsa;
......@@ -130,6 +133,16 @@ void SshKeyCreationDialog::saveKeys()
bool SshKeyCreationDialog::userForbidsOverwriting()
if (!QFileInfo(privateKeyFilePath()).exists() && !QFileInfo(publicKeyFilePath()).exists())
return false;
const QMessageBox::StandardButton reply = QMessageBox::question(this, tr("File Exists"),
tr("There already is a file of that name. Do you want to overwrite it?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
return reply != QMessageBox::Yes;
QString SshKeyCreationDialog::privateKeyFilePath() const
return m_ui->privateKeyFileValueLabel->text();
......@@ -57,6 +57,7 @@ private slots:
void setPrivateKeyFile(const QString &filePath);
void saveKeys();
bool userForbidsOverwriting();
SshKeyGenerator *m_keyGenerator;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment