From c6bb7aea21320b9f3cd0e0127aee3aef6db7ccb4 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 19 Aug 2018 12:32:11 +0200 Subject: 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 --- src/core/kconfig.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/kconfig.cpp') 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 -- cgit v1.2.1