Skip to content

Commit

Permalink
Check for write permission before entering portable mode
Browse files Browse the repository at this point in the history
* Fix #7585
  • Loading branch information
droidmonkey committed Sep 7, 2022
1 parent 9e81c31 commit 61f9221
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")};
}

Expand Down

0 comments on commit 61f9221

Please sign in to comment.