Bug 510456

Summary: Writing to ftp servers fails
Product: [Frameworks and Libraries] frameworks-kio Reporter: Friedrich W. H. Kossebau <kossebau>
Component: FTPAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: aronkvh, heiko.becker, kdelibs-bugs-null, nate, nicolas.fella
Priority: NOR Keywords: regression
Version First Reported In: 6.19.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.19.0
Sentry Crash Report:

Description Friedrich W. H. Kossebau 2025-10-10 13:46:38 UTC
Trying to copy files to ftp servers fails with "Access denied".

On first look this seems due to some things failing when KIO's CopyJob stats the destination dir:

the implementation in FtpInternal::stat() has a code path which just assumes details about the dir instead of querying for it, and the details do not assume S_IWUSR (see also code comment "Don't list the parent dir. Too slow, might not show it, etc. Just return that it's a dir.").
https://invent.kde.org/frameworks/kio/-/blob/v6.18.0/src/kioworkers/ftp/ftp.cpp?ref_type=tags#L1365

CopyJob though checks for S_IWUSR obviously, and errors out if not set for the dir.
https://invent.kde.org/frameworks/kio/-/blob/v6.19.0-rc1/src/core/copyjob.cpp?ref_type=tags#L552

This seems to have been uncovered by the change in https://invent.kde.org/frameworks/kio/-/commit/15fff1b8592648f11f20a303c8f82d61d3f19584#a255943687657ca8eb60300f623327855b34bd67_571_553
The old condition `!m_privilegeExecutionEnabled && !isWritable` might have wrongly prevented entering the error branch, as `m_privilegeExecutionEnabled` usually might have been true, and the `&&` should have rather been a `||`.

Possibly needs fixing by improving the ftp worker code to actually query the real details, instead of hardcoding some?
Comment 1 Bug Janitor Service 2025-10-10 14:22:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/2017
Comment 2 Nicolas Fella 2025-10-11 19:58:48 UTC
Git commit eaaf877aed31c0d7483fd2a1bccbe06df0e6c0a6 by Nicolas Fella.
Committed on 11/10/2025 at 19:58.
Pushed by nicolasfella into branch 'master'.

[ftp] Claim that dir is writable during stat

This isn't really correct, but neither is saying it's not writable

Without this CopyJob will refuse to work, at least since 15fff1b8592648f11f20a303c8f82d61d3f19584

M  +1    -1    src/kioworkers/ftp/ftp.cpp

https://invent.kde.org/frameworks/kio/-/commit/eaaf877aed31c0d7483fd2a1bccbe06df0e6c0a6
Comment 3 Nicolas Fella 2025-10-11 19:59:53 UTC
Git commit cb2c6096763e20dae1941ea8e34a8b7e69b20fdd by Nicolas Fella.
Committed on 11/10/2025 at 19:59.
Pushed by nicolasfella into branch 'Frameworks/6.19'.

[ftp] Claim that dir is writable during stat

This isn't really correct, but neither is saying it's not writable

Without this CopyJob will refuse to work, at least since 15fff1b8592648f11f20a303c8f82d61d3f19584
(cherry picked from commit eaaf877aed31c0d7483fd2a1bccbe06df0e6c0a6)

M  +1    -1    src/kioworkers/ftp/ftp.cpp

https://invent.kde.org/frameworks/kio/-/commit/cb2c6096763e20dae1941ea8e34a8b7e69b20fdd