From bcc840654fa2af68a4942fba6f58b2955e80e7ec Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Tue, 14 Oct 2025 13:14:20 +0300 Subject: [PATCH] CopyJob: Skip permission check if there is no UDS_ACCESS entry Lack of UDS_ACCESS or S_IWUSR flag in it does *not* mean that the item is definitely unwritable. The access can be indefinite until the item is actually worked with. KIO should not assume that items are unwritable, even if we lack the flag. We should just try working with the file and handle the results, not try pre-emptively decide the actions. BUG: 510567 --- src/core/copyjob.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/core/copyjob.cpp b/src/core/copyjob.cpp index 587a5d6805..16258ba3ae 100644 --- a/src/core/copyjob.cpp +++ b/src/core/copyjob.cpp @@ -546,16 +546,19 @@ void CopyJobPrivate::slotResultStating(KJob *job) } else { const bool isDir = entry.isDir(); - // Check for writability, before spending time stat'ing everything (#141564). - // This assumes all KIO workers set permissions correctly... const int permissions = entry.numberValue(KIO::UDSEntry::UDS_ACCESS, -1); - const bool isWritable = (permissions != -1) && (permissions & S_IWUSR); - if (!isWritable) { - const QUrl dest = m_asMethod ? m_dest.adjusted(QUrl::RemoveFilename) : m_dest; - q->setError(ERR_WRITE_ACCESS_DENIED); - q->setErrorText(dest.toDisplayString(QUrl::PreferLocalFile)); - q->emitResult(); - return; + // Skip check if we have no definite permissions set (BUG: 510567) + if (permissions != -1) { + // Check for writability, before spending time stat'ing everything (#141564). + // This assumes all KIO workers set permissions correctly... + const bool isWritable = (permissions & S_IWUSR); + if (!isWritable) { + const QUrl dest = m_asMethod ? m_dest.adjusted(QUrl::RemoveFilename) : m_dest; + q->setError(ERR_WRITE_ACCESS_DENIED); + q->setErrorText(dest.toDisplayString(QUrl::PreferLocalFile)); + q->emitResult(); + return; + } } // Treat symlinks to dirs as dirs here, so no test on isLink -- GitLab