Commit 5a870554 authored by Harald Sitter's avatar Harald Sitter 🌹
Browse files

improve error reporting for when kpasswdserver is unreachable

Summary:
previously we'd not forward the errors coming out of the password dialog
helper and instead eventually end up on generic access denied errors.
seeing as the access denied is likely because we couldn't query auth info
that is fairly misleading.

checkPassword is now returning an error code instead of a bool. when we
actually consider checkPassword an error we'll now raise this error
instead of the generic access denied errors. when the user canceled
the query we'll continue to raise the more topical error from smb (e.g.
"access denied")

primarily these errors appear when kiod/kpasswdserver is defunct
or not installed meaning query functionality will not work at all.

Test Plan:
# broken kiod

- remove dbus service file
- kill
- dolphin smb://host
- no auth query
- error about broken dialog

# cancel

- repair kiod
- dolphin smb://host
- auth query
- cancel
- auth query
- cancel
- error about access denied (because refused to authenticate)

Reviewers: #frameworks, dfaure

Reviewed By: dfaure

Subscribers: ngraham, kde-frameworks-devel, kfm-devel

Tags: #dolphin, #frameworks

Differential Revision: https://phabricator.kde.org/D24387
parent 86462057
......@@ -144,7 +144,7 @@ protected:
*/
bool auth_initialize_smbc();
bool checkPassword(SMBUrl &url);
int checkPassword(SMBUrl &url);
//---------------------------------------------
......
......@@ -119,7 +119,7 @@ void SMBSlave::auth_smbc_get_data(const char *server,const char *share,
strncpy(password, info.password.toUtf8(), pwmaxlen - 1);
}
bool SMBSlave::checkPassword(SMBUrl &url)
int SMBSlave::checkPassword(SMBUrl &url)
{
qCDebug(KIO_SMB) << "checkPassword for " << url;
......@@ -163,10 +163,10 @@ bool SMBSlave::checkPassword(SMBUrl &url)
cacheAuthentication(info);
}
return true;
return KJob::NoError;
}
qCDebug(KIO_SMB) << "no value from openPasswordDialog\n";
return false;
qCDebug(KIO_SMB) << "no value from openPasswordDialog; error:" << passwordDialogErrorCode;
return passwordDialogErrorCode;
}
//--------------------------------------------------------------------------
......
......@@ -147,15 +147,20 @@ void SMBSlave::stat( const QUrl& kurl )
{
SMBUrl smbUrl(url);
if (checkPassword(smbUrl))
const int passwordError = checkPassword(smbUrl);
if (passwordError == KJob::NoError)
{
redirection(smbUrl);
finished();
}
else
else if (passwordError == KIO::ERR_USER_CANCELED)
{
reportError(url, ret);
}
else
{
error(passwordError, url.toString());
}
return;
}
......@@ -489,11 +494,17 @@ void SMBSlave::listDir( const QUrl& kurl )
else
{
if (errNum == EPERM || errNum == EACCES || workaroundEEXIST(errNum)) {
if (checkPassword(m_current_url)) {
const int passwordError = checkPassword(m_current_url);
if (passwordError == KJob::NoError) {
redirection( m_current_url );
finished();
return;
} else if (passwordError == KIO::ERR_USER_CANCELED) {
reportError(m_current_url, errNum);
} else {
error(passwordError, m_current_url.toString());
}
return;
}
reportError(m_current_url, errNum);
......
......@@ -67,7 +67,7 @@ void SMBSlave::special( const QByteArray & data)
smburl.setHost(host);
smburl.setPath('/' + share);
if ( !checkPassword(smburl) )
if ( checkPassword(smburl) != KJob::NoError )
{
finished();
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment