diff options
author | Jonathan White <support@dmapps.us> | 2022-09-07 04:51:20 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2022-09-22 13:49:07 +0300 |
commit | 5b923aee1af6eabdc412c22f2454bdee6d92e71b (patch) | |
tree | 17b3eb99c0aec75930896040f8bae62459d05a16 | |
parent | f3d448485a34cf7b99368a38af7b7a68ab2fdff4 (diff) |
Check for write permission before entering portable mode
* Fix #7585
-rw-r--r-- | src/core/Config.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 3c20ff80d..8808abd75 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -481,8 +481,19 @@ void Config::init(const QString& configFileName, const QString& localConfigFileN QPair<QString, QString> Config::defaultConfigFiles() { // Check if we are running in portable mode, if so store the config files local to the app +#ifdef Q_OS_WIN + // Enable QFileInfo::isWritable check on Windows + extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; + qt_ntfs_permission_lookup++; +#endif auto portablePath = QCoreApplication::applicationDirPath().append("/%1"); - if (QFile::exists(portablePath.arg(".portable"))) { + auto portableFile = portablePath.arg(".portable"); + bool isPortable = QFile::exists(portableFile) && QFileInfo(portableFile).isWritable(); +#ifdef Q_OS_WIN + qt_ntfs_permission_lookup--; +#endif + + if (isPortable) { return {portablePath.arg("config/keepassxc.ini"), portablePath.arg("config/keepassxc_local.ini")}; } |