Skip to content

Commit

Permalink
[authentication manager] Use dedicated mutex for master password check
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored and nyalldawson committed May 15, 2020
1 parent 17d5377 commit 0cf8576
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/auth/qgsauthmanager.cpp
Expand Up @@ -103,6 +103,7 @@ QgsAuthManager *QgsAuthManager::instance()
QgsAuthManager::QgsAuthManager()
{
mMutex = new QMutex( QMutex::Recursive );
mMasterPasswordMutex = new QMutex( QMutex::Recursive );
connect( this, &QgsAuthManager::messageOut,
this, &QgsAuthManager::writeToConsole );
}
Expand Down Expand Up @@ -491,7 +492,7 @@ const QString QgsAuthManager::disabledMessage() const

bool QgsAuthManager::setMasterPassword( bool verify )
{
QMutexLocker locker( mMutex );
QMutexLocker locker( mMasterPasswordMutex );
if ( isDisabled() )
return false;

Expand All @@ -501,13 +502,11 @@ bool QgsAuthManager::setMasterPassword( bool verify )
if ( mMasterPass.isEmpty() )
{
QgsDebugMsg( QStringLiteral( "Master password is not yet set by user" ) );
locker.unlock();
if ( !masterPasswordInput() )
{
QgsDebugMsg( QStringLiteral( "Master password input canceled by user" ) );
return false;
}
locker.relock();
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/core/auth/qgsauthmanager.h
Expand Up @@ -863,6 +863,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
bool mScheduledDbEraseRequestEmitted = false;
int mScheduledDbEraseRequestCount = 0;
QMutex *mMutex = nullptr;
QMutex *mMasterPasswordMutex = nullptr;

#ifndef QT_NO_SSL
// mapping of sha1 digest and cert source and cert
Expand Down

0 comments on commit 0cf8576

Please sign in to comment.