From f7c1f242840bc5a4ff8635b43d69ce8a48ef289d Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 1 Jun 2024 05:36:16 +0300 Subject: [PATCH] kutils: force the cache only option of KPasswdStore to off after the timeout Signed-off-by: Ivailo Monev --- kutils/kpasswdstore/kded/kpasswdstoreimpl.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kutils/kpasswdstore/kded/kpasswdstoreimpl.cpp b/kutils/kpasswdstore/kded/kpasswdstoreimpl.cpp index dabdffc6..2ec272f3 100644 --- a/kutils/kpasswdstore/kded/kpasswdstoreimpl.cpp +++ b/kutils/kpasswdstore/kded/kpasswdstoreimpl.cpp @@ -102,8 +102,9 @@ bool KPasswdStoreImpl::isOpen() const bool KPasswdStoreImpl::openStore(const qlonglong windowid) { #if defined(HAVE_OPENSSL) - if (m_cacheonly && m_passwdtimer.elapsed() < m_timeout) { + if (cacheOnly()) { kDebug() << "cache store" << m_storeid; + m_passwdtimer.start(); return false; } @@ -177,12 +178,12 @@ void KPasswdStoreImpl::setCacheOnly(const bool cacheonly) bool KPasswdStoreImpl::cacheOnly() const { - return m_cacheonly; + return (m_cacheonly && m_passwdtimer.elapsed() < m_timeout); } QString KPasswdStoreImpl::getPasswd(const QByteArray &key, const qlonglong windowid) { - if (m_cacheonly) { + if (cacheOnly()) { kDebug() << "returning password from cache" << m_storeid << key; return m_cachemap.value(key, QString()); } @@ -205,7 +206,7 @@ QString KPasswdStoreImpl::getPasswd(const QByteArray &key, const qlonglong windo bool KPasswdStoreImpl::storePasswd(const QByteArray &key, const QString &passwd, const qlonglong windowid) { - if (m_cacheonly) { + if (cacheOnly()) { kDebug() << "storing password temporary" << key; m_cachemap.insert(key, passwd); return true; @@ -234,7 +235,7 @@ bool KPasswdStoreImpl::storePasswd(const QByteArray &key, const QString &passwd, bool KPasswdStoreImpl::ensurePasswd(const qlonglong windowid, const bool showerror, bool *cancel) { - Q_ASSERT(!cacheonly); + Q_ASSERT(!m_cacheonly); #if defined(HAVE_OPENSSL) if (!m_passwd.isEmpty() && m_passwdtimer.elapsed() >= m_timeout) {