aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2018-08-19 12:32:11 +0200
committerDavid Faure <faure@kde.org>2019-02-04 13:42:18 +0100
commitc6bb7aea21320b9f3cd0e0127aee3aef6db7ccb4 (patch)
tree828c33cc37810f663b8ed329b1b2b175a54c9ed9
parentd60c5c516880c3859a0f5d3cca46a3b0ba77fa1d (diff)
downloadkconfig-c6bb7aea21320b9f3cd0e0127aee3aef6db7ccb4.tar.gz
kconfig-c6bb7aea21320b9f3cd0e0127aee3aef6db7ccb4.tar.bz2
KConfig: handle directory symlinks correctly.
Summary: When /home is a symlink, for instance (as is often the case on FreeBSD), group deletion would fail because KConfig was comparing non-canonical paths with canonical-paths: QDEBUG : KConfigTest::testDelete() Comparing "/home/adridg/.qttest/config/ kconfigtest_subdir/kconfigtest" and "/usr/home/adridg/.qttest/config/ kconfigtest_subdir/kconfigtest" Test Plan: mkdir /tmp/derp; ln -s /tmp/derp /tmp/drop HOME=/tmp/derp bin/kconfigtest testDelete # Success HOME=/tmp/drop bin/kconfigtest testDelete # Fail Reviewers: adridg, arichardson, apol Reviewed By: apol Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14927
-rw-r--r--src/core/kconfig.cpp7
-rw-r--r--src/core/kconfigini.cpp6
2 files changed, 10 insertions, 3 deletions
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index bc2871c1..bdf89b1e 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -755,10 +755,13 @@ void KConfigPrivate::parseConfigFiles()
files = getGlobalFiles();
} else {
if (QDir::isAbsolutePath(fileName)) {
- files << fileName;
+ const QString canonicalFile = QFileInfo(fileName).canonicalFilePath();
+ if (!canonicalFile.isEmpty()) { // empty if it doesn't exist
+ files << canonicalFile;
+ }
} else {
Q_FOREACH (const QString &f, QStandardPaths::locateAll(resourceType, fileName)) {
- files.prepend(f);
+ files.prepend(QFileInfo(f).canonicalFilePath());
}
// allow fallback to config files bundled in resources
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index b6749731..84d77b48 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -602,7 +602,11 @@ void KConfigIniBackend::setFilePath(const QString &file)
if (info.exists()) {
setLocalFilePath(info.canonicalFilePath());
} else {
- setLocalFilePath(file);
+ const QString dir = info.dir().canonicalPath();
+ if (!dir.isEmpty())
+ setLocalFilePath(dir + QLatin1Char('/') + info.fileName());
+ else
+ setLocalFilePath(file);
}
}