mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 23:39:45 -05:00
Add possibility to configure timeout for remote process (#11271)
* Add possibility to configure timeout for remote process * Fixes #11234
This commit is contained in:
parent
ea2e36c676
commit
abcb1414a3
@ -2372,6 +2372,14 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
|
|||||||
</source>
|
</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Timeout:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source> seconds</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DatabaseTabWidget</name>
|
<name>DatabaseTabWidget</name>
|
||||||
|
@ -46,8 +46,10 @@ DatabaseSettingsWidgetRemote::DatabaseSettingsWidgetRemote(QWidget* parent)
|
|||||||
connect(m_ui->nameLineEdit, &QLineEdit::textChanged, setModified);
|
connect(m_ui->nameLineEdit, &QLineEdit::textChanged, setModified);
|
||||||
connect(m_ui->downloadCommand, &QLineEdit::textChanged, setModified);
|
connect(m_ui->downloadCommand, &QLineEdit::textChanged, setModified);
|
||||||
connect(m_ui->inputForDownload, &QPlainTextEdit::textChanged, setModified);
|
connect(m_ui->inputForDownload, &QPlainTextEdit::textChanged, setModified);
|
||||||
|
connect(m_ui->downloadTimeoutSec, QOverload<int>::of(&QSpinBox::valueChanged), setModified);
|
||||||
connect(m_ui->uploadCommand, &QLineEdit::textChanged, setModified);
|
connect(m_ui->uploadCommand, &QLineEdit::textChanged, setModified);
|
||||||
connect(m_ui->inputForUpload, &QPlainTextEdit::textChanged, setModified);
|
connect(m_ui->inputForUpload, &QPlainTextEdit::textChanged, setModified);
|
||||||
|
connect(m_ui->uploadTimeoutSec, QOverload<int>::of(&QSpinBox::valueChanged), setModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseSettingsWidgetRemote::~DatabaseSettingsWidgetRemote() = default;
|
DatabaseSettingsWidgetRemote::~DatabaseSettingsWidgetRemote() = default;
|
||||||
@ -100,8 +102,10 @@ void DatabaseSettingsWidgetRemote::saveCurrentSettings()
|
|||||||
params->name = m_ui->nameLineEdit->text();
|
params->name = m_ui->nameLineEdit->text();
|
||||||
params->downloadCommand = m_ui->downloadCommand->text();
|
params->downloadCommand = m_ui->downloadCommand->text();
|
||||||
params->downloadInput = m_ui->inputForDownload->toPlainText();
|
params->downloadInput = m_ui->inputForDownload->toPlainText();
|
||||||
|
params->downloadTimeoutMsec = m_ui->downloadTimeoutSec->value() * 1000;
|
||||||
params->uploadCommand = m_ui->uploadCommand->text();
|
params->uploadCommand = m_ui->uploadCommand->text();
|
||||||
params->uploadInput = m_ui->inputForUpload->toPlainText();
|
params->uploadInput = m_ui->inputForUpload->toPlainText();
|
||||||
|
params->uploadTimeoutMsec = m_ui->uploadTimeoutSec->value() * 1000;
|
||||||
|
|
||||||
m_remoteSettings->addRemoteParams(params);
|
m_remoteSettings->addRemoteParams(params);
|
||||||
updateSettingsList();
|
updateSettingsList();
|
||||||
@ -145,8 +149,10 @@ void DatabaseSettingsWidgetRemote::editCurrentSettings()
|
|||||||
m_ui->nameLineEdit->setText(params->name);
|
m_ui->nameLineEdit->setText(params->name);
|
||||||
m_ui->downloadCommand->setText(params->downloadCommand);
|
m_ui->downloadCommand->setText(params->downloadCommand);
|
||||||
m_ui->inputForDownload->setPlainText(params->downloadInput);
|
m_ui->inputForDownload->setPlainText(params->downloadInput);
|
||||||
|
m_ui->downloadTimeoutSec->setValue(params->downloadTimeoutMsec / 1000);
|
||||||
m_ui->uploadCommand->setText(params->uploadCommand);
|
m_ui->uploadCommand->setText(params->uploadCommand);
|
||||||
m_ui->inputForUpload->setPlainText(params->uploadInput);
|
m_ui->inputForUpload->setPlainText(params->uploadInput);
|
||||||
|
m_ui->uploadTimeoutSec->setValue(params->uploadTimeoutMsec / 1000);
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,8 +171,10 @@ void DatabaseSettingsWidgetRemote::clearFields()
|
|||||||
m_ui->nameLineEdit->setText("");
|
m_ui->nameLineEdit->setText("");
|
||||||
m_ui->downloadCommand->setText("");
|
m_ui->downloadCommand->setText("");
|
||||||
m_ui->inputForDownload->setPlainText("");
|
m_ui->inputForDownload->setPlainText("");
|
||||||
|
m_ui->downloadTimeoutSec->setValue(10);
|
||||||
m_ui->uploadCommand->setText("");
|
m_ui->uploadCommand->setText("");
|
||||||
m_ui->inputForUpload->setPlainText("");
|
m_ui->inputForUpload->setPlainText("");
|
||||||
|
m_ui->uploadTimeoutSec->setValue(10);
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,6 +184,7 @@ void DatabaseSettingsWidgetRemote::testDownload()
|
|||||||
params->name = m_ui->nameLineEdit->text();
|
params->name = m_ui->nameLineEdit->text();
|
||||||
params->downloadCommand = m_ui->downloadCommand->text();
|
params->downloadCommand = m_ui->downloadCommand->text();
|
||||||
params->downloadInput = m_ui->inputForDownload->toPlainText();
|
params->downloadInput = m_ui->inputForDownload->toPlainText();
|
||||||
|
params->downloadTimeoutMsec = m_ui->downloadTimeoutSec->value() * 1000;
|
||||||
|
|
||||||
QScopedPointer<RemoteHandler> remoteHandler(new RemoteHandler(this));
|
QScopedPointer<RemoteHandler> remoteHandler(new RemoteHandler(this));
|
||||||
if (params->downloadCommand.isEmpty()) {
|
if (params->downloadCommand.isEmpty()) {
|
||||||
|
@ -132,6 +132,16 @@
|
|||||||
<string>Download</string>
|
<string>Download</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="downloadCommandInputLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Input:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="downloadCommandLabel">
|
<widget class="QLabel" name="downloadCommandLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -139,6 +149,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPlainTextEdit" name="inputForDownload">
|
||||||
|
<property name="accessibleName">
|
||||||
|
<string>Download input field</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>e.g.:
|
||||||
|
get DatabaseOnRemote.kdbx {TEMP_DATABASE}
|
||||||
|
exit
|
||||||
|
---
|
||||||
|
{TEMP_DATABASE} is used as placeholder to store the database in a temporary location
|
||||||
|
The command has to exit. In case of `sftp` as last command `exit` has to be sent
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
@ -160,29 +186,26 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="downloadCommandInputLabel">
|
<widget class="QLabel" name="downloadTimeoutLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Input:</string>
|
<string>Timeout:</string>
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QPlainTextEdit" name="inputForDownload">
|
<widget class="QSpinBox" name="downloadTimeoutSec">
|
||||||
<property name="accessibleName">
|
<property name="suffix">
|
||||||
<string>Download input field</string>
|
<string> seconds</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="placeholderText">
|
<property name="minimum">
|
||||||
<string>e.g.:
|
<number>1</number>
|
||||||
get DatabaseOnRemote.kdbx {TEMP_DATABASE}
|
</property>
|
||||||
exit
|
<property name="maximum">
|
||||||
---
|
<number>300</number>
|
||||||
{TEMP_DATABASE} is used as placeholder to store the database in a temporary location
|
</property>
|
||||||
The command has to exit. In case of `sftp` as last command `exit` has to be sent
|
<property name="value">
|
||||||
</string>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -193,33 +216,6 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
|
|||||||
<string>Upload</string>
|
<string>Upload</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="uploadCommandInputLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Input:</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="uploadCommandLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Command:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="uploadCommand">
|
|
||||||
<property name="accessibleName">
|
|
||||||
<string>Upload command field</string>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>e.g.: "sftp user@hostname" or "scp {TEMP_DATABASE} user@hostname:DatabaseOnRemote.kdbx"</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QPlainTextEdit" name="inputForUpload">
|
<widget class="QPlainTextEdit" name="inputForUpload">
|
||||||
<property name="accessibleName">
|
<property name="accessibleName">
|
||||||
@ -236,6 +232,56 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="uploadCommandInputLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Input:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="uploadCommand">
|
||||||
|
<property name="accessibleName">
|
||||||
|
<string>Upload command field</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>e.g.: "sftp user@hostname" or "scp {TEMP_DATABASE} user@hostname:DatabaseOnRemote.kdbx"</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="uploadCommandLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="uploadTimeoutLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Timeout:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="uploadTimeoutSec">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> seconds</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>300</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -67,7 +67,7 @@ RemoteHandler::RemoteResult RemoteHandler::download(const RemoteParams* params)
|
|||||||
remoteProcess->closeWriteChannel();
|
remoteProcess->closeWriteChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool finished = remoteProcess->waitForFinished(10000);
|
bool finished = remoteProcess->waitForFinished(params->downloadTimeoutMsec);
|
||||||
int statusCode = remoteProcess->exitCode();
|
int statusCode = remoteProcess->exitCode();
|
||||||
|
|
||||||
// TODO: For future use
|
// TODO: For future use
|
||||||
@ -118,7 +118,7 @@ RemoteHandler::RemoteResult RemoteHandler::upload(const QString& filePath, const
|
|||||||
remoteProcess->closeWriteChannel();
|
remoteProcess->closeWriteChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool finished = remoteProcess->waitForFinished(10000);
|
bool finished = remoteProcess->waitForFinished(params->uploadTimeoutMsec);
|
||||||
int statusCode = remoteProcess->exitCode();
|
int statusCode = remoteProcess->exitCode();
|
||||||
|
|
||||||
// TODO: For future use
|
// TODO: For future use
|
||||||
|
@ -89,8 +89,10 @@ QString RemoteSettings::toConfig() const
|
|||||||
object["name"] = params->name;
|
object["name"] = params->name;
|
||||||
object["downloadCommand"] = params->downloadCommand;
|
object["downloadCommand"] = params->downloadCommand;
|
||||||
object["downloadCommandInput"] = params->downloadInput;
|
object["downloadCommandInput"] = params->downloadInput;
|
||||||
|
object["downloadTimeoutMsec"] = params->downloadTimeoutMsec;
|
||||||
object["uploadCommand"] = params->uploadCommand;
|
object["uploadCommand"] = params->uploadCommand;
|
||||||
object["uploadCommandInput"] = params->uploadInput;
|
object["uploadCommandInput"] = params->uploadInput;
|
||||||
|
object["uploadTimeoutMsec"] = params->uploadTimeoutMsec;
|
||||||
config << object;
|
config << object;
|
||||||
}
|
}
|
||||||
QJsonDocument doc(config);
|
QJsonDocument doc(config);
|
||||||
@ -108,8 +110,10 @@ void RemoteSettings::fromConfig(const QString& data)
|
|||||||
params->name = itemMap["name"].toString();
|
params->name = itemMap["name"].toString();
|
||||||
params->downloadCommand = itemMap["downloadCommand"].toString();
|
params->downloadCommand = itemMap["downloadCommand"].toString();
|
||||||
params->downloadInput = itemMap["downloadCommandInput"].toString();
|
params->downloadInput = itemMap["downloadCommandInput"].toString();
|
||||||
|
params->downloadTimeoutMsec = itemMap.value("downloadTimeoutMsec", 10000).toInt();
|
||||||
params->uploadCommand = itemMap["uploadCommand"].toString();
|
params->uploadCommand = itemMap["uploadCommand"].toString();
|
||||||
params->uploadInput = itemMap["uploadCommandInput"].toString();
|
params->uploadInput = itemMap["uploadCommandInput"].toString();
|
||||||
|
params->uploadTimeoutMsec = itemMap.value("uploadTimeoutMsec", 10000).toInt();
|
||||||
|
|
||||||
m_remoteParams.insert(params->name, params);
|
m_remoteParams.insert(params->name, params);
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,10 @@ struct RemoteParams
|
|||||||
QString name;
|
QString name;
|
||||||
QString downloadCommand;
|
QString downloadCommand;
|
||||||
QString downloadInput;
|
QString downloadInput;
|
||||||
|
int downloadTimeoutMsec;
|
||||||
QString uploadCommand;
|
QString uploadCommand;
|
||||||
QString uploadInput;
|
QString uploadInput;
|
||||||
|
int uploadTimeoutMsec;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(RemoteParams)
|
Q_DECLARE_METATYPE(RemoteParams)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user