summaryrefslogtreecommitdiff
path: root/src/main-lib
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2022-03-21 23:42:44 +0100
committerRobert Griebl <robert.griebl@qt.io>2022-03-22 14:44:39 +0000
commitbc06a04dd845d039ba802f94b5eae57519ec63a8 (patch)
treef8080dff2b7f24a20661b9dc1d1340af93c30375 /src/main-lib
parent8f0a7fc2429b01f4196e615e1dff2be13f26306d (diff)
downloadqtapplicationmanager-bc06a04dd845d039ba802f94b5eae57519ec63a8.tar.gz
Handle an empty or invalid documentDir correctly
Not specifying the documentDir, but enabling the installer would - unexpectedly - use $PWD as documentDir. The code does now follow the documentation: if not set, no document directories will be created on package installation. Also, we now fail early if the documentDir and installationDir are sub-directories of each other, as that would lead to mayhem on PackageManager::cleanupBrokenInstallations(). Change-Id: Id8d89f82bf0d63c771f3d86a963c66681f43f195 Fixes: QTBUG-101881 Pick-to: 6.3 6.2 5.15 Reviewed-by: Bernd Weimer <bernd.weimer@qt.io>
Diffstat (limited to 'src/main-lib')
-rw-r--r--src/main-lib/main.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp
index 323431aa..a0140294 100644
--- a/src/main-lib/main.cpp
+++ b/src/main-lib/main.cpp
@@ -491,6 +491,15 @@ void Main::setupInstaller(bool devMode, bool allowUnsigned, const QStringList &c
"even automatically switching to C.UTF-8 or en_US.UTF-8 failed.";
}
+ // make sure the installation and document dirs are valid
+ Q_ASSERT(!m_installationDir.isEmpty());
+ const auto instPath = QDir(m_installationDir).canonicalPath();
+ const auto docPath = m_documentDir.isEmpty() ? QString { }
+ : QDir(m_documentDir).canonicalPath();
+
+ if (!docPath.isEmpty() && (instPath.startsWith(docPath) || docPath.startsWith(instPath)))
+ throw Exception("either installationDir or documentDir cannot be a sub-directory of the other");
+
// we only output these deployment warnings, if we are on embedded, applicationUserIdSeparation
// is enabled and either...
if (isRunningOnEmbedded() && userIdSeparation && userIdSeparation(nullptr, nullptr, nullptr)) {