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
wilder
David Faure 8 years ago
parent d60c5c5168
commit c6bb7aea21
  1. 7
      src/core/kconfig.cpp
  2. 6
      src/core/kconfigini.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

@ -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);
}
}

Loading…
Cancel
Save