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 Apr 28, 2020
1 parent 048d1ad commit 845c587
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 @@ -99,6 +99,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 @@ -487,7 +488,7 @@ const QString QgsAuthManager::disabledMessage() const

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

Expand All @@ -497,13 +498,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 845c587

Please sign in to comment.