diff options
author | Jonathan White <support@dmapps.us> | 2022-09-07 04:51:20 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2022-09-07 14:06:23 +0300 |
commit | 61f922179b8ef1446cc85385e391c83f86f204ce (patch) | |
tree | b60cb43499aa2fe15a900944f71efd2ba80b30cf | |
parent | 9e81c31e5a5f262662cb448f92ac0aafdae97698 (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")}; } |