summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2016-11-07 10:28:52 +0100
committerGatis Paeglis <gatis.paeglis@qt.io>2016-11-07 09:58:08 +0000
commitce430f4abf71b5efe70fc9821f0eb2560307baf9 (patch)
treeb95c2b62360b07075b4d9fde6ffa59e749d99cf6
parentb3875fd3b8f0659ca23ba29d88235530c573bc94 (diff)
check if paths exist in repo configurations
ostree command line happily accepts paths that do not exist when setting tls-client-* and tls-ca-path. Due to this, requests to HTTP server (ostree pull ..) never return/timeout. Change-Id: I63bd4307cd5636f407742ccfd3342cb23a0704da Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
-rw-r--r--examples/qml/basic/main.qml7
-rw-r--r--src/lib/qotaclient.cpp22
2 files changed, 26 insertions, 3 deletions
diff --git a/examples/qml/basic/main.qml b/examples/qml/basic/main.qml
index 6728bcf..7e65462 100644
--- a/examples/qml/basic/main.qml
+++ b/examples/qml/basic/main.qml
@@ -74,8 +74,12 @@ Window {
return;
}
}
- if (!OtaClient.setRepositoryConfig(config))
+ if (!OtaClient.setRepositoryConfig(config)) {
logError("Failed to update repository configuration")
+ return;
+ }
+
+ log("Successfully updated repository configuration")
}
function updateConfigView(config) {
@@ -240,6 +244,7 @@ Window {
onInitializationFinished: {
logWithCondition("Initialization", OtaClient.initialized)
configureRepository(basicConfig, true)
+ updateConfigView(OtaClient.repositoryConfig())
updateBootedMetadataLabel()
updateRemoteMetadataLabel()
updateRollbackMetadataLabel()
diff --git a/src/lib/qotaclient.cpp b/src/lib/qotaclient.cpp
index 216eb27..f25beb9 100644
--- a/src/lib/qotaclient.cpp
+++ b/src/lib/qotaclient.cpp
@@ -497,6 +497,15 @@ bool QOtaClient::repositoryConfigsEqual(QOtaRepositoryConfig *a, QOtaRepositoryC
return QOtaRepositoryConfig().d_func()->repositoryConfigsEqual(a, b);
}
+static inline bool pathExists(QOtaClientPrivate *d, const QString &path)
+{
+ if (!QDir().exists(path)) {
+ d->errorOccurred(path + QLatin1String(" does not exist"));
+ return false;
+ }
+ return true;
+}
+
/*!
//! [set-repository-config]
Change the configuration for the repository. The repository configuration
@@ -525,12 +534,19 @@ bool QOtaClient::setRepositoryConfig(QOtaRepositoryConfig *config)
d->errorOccurred(QStringLiteral("Repository URL can not be empty"));
return false;
}
+
// TLS client certs
int tlsClientArgs = 0;
- if (!config->tlsClientCertPath().isEmpty())
+ if (!config->tlsClientCertPath().isEmpty()) {
+ if (!pathExists(d, config->tlsClientCertPath()))
+ return false;
++tlsClientArgs;
- if (!config->tlsClientKeyPath().isEmpty())
+ }
+ if (!config->tlsClientKeyPath().isEmpty()) {
+ if (!pathExists(d, config->tlsClientKeyPath()))
+ return false;
++tlsClientArgs;
+ }
if (tlsClientArgs == 1) {
d->errorOccurred(QStringLiteral("Both tlsClientCertPath and tlsClientKeyPath are required"
" for TLS client authentication functionality"));
@@ -553,6 +569,8 @@ bool QOtaClient::setRepositoryConfig(QOtaRepositoryConfig *config)
cmd.append(QStringLiteral(" --set=tls-permissive="));
config->tlsPermissive() ? cmd.append(QStringLiteral("true")) : cmd.append(QStringLiteral("false"));
if (!config->tlsCaPath().isEmpty()) {
+ if (!pathExists(d, config->tlsCaPath()))
+ return false;
cmd.append(QStringLiteral(" --set=tls-ca-path="));
cmd.append(config->tlsCaPath());
}