Move/copy job: skip stat'ing sources if the destination dir isn't writable
ClosedPublic

Authored by dfaure on Dec 16 2018, 7:30 PM.

Details

Summary

BUG: 141564

Test Plan

Unit test, but also copying to / in dolphin, to check what the error message looks like.

Diff Detail

Repository
R241 KIO
Branch
skip_stat
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 6259
Build 6277: arc lint + arc unit
dfaure created this revision.Dec 16 2018, 7:30 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 16 2018, 7:30 PM
Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald Transcript
dfaure requested review of this revision.Dec 16 2018, 7:30 PM
dfaure updated this revision to Diff 47689.Dec 16 2018, 7:32 PM

merge the commits

dfaure retitled this revision from Unittest only to Move/copy job: skip stat'ing sources if the destination dir isn't writable.Dec 16 2018, 7:32 PM
dfaure edited the summary of this revision. (Show Details)
chinmoyr added inline comments.
src/core/copyjob.cpp
419

For file permissions, 'file:' and 'trash:' use the result of QT_LSTAT, 'archive:' makes use of stat, 'sftp:' uses sftp_lstat, and smb sets UDS_ACCESS to 0500. These are the kioslaves(I found) which KDE ships and set UDS_ACCESS entry. I think using UDSEntry can be considered here.

chinmoyr added inline comments.Dec 17 2018, 4:04 PM
src/core/copyjob.cpp
419

These are the kioslaves(I found) which KDE ships and set UDS_ACCESS entry. I think using UDSEntry can be considered here.

Well I was completely wrong here. There are plenty other protocols that set UDS_ACCESS and someone needs to check if their UDSEntry has the correct permission since flags are being set manually. For the time being this TODO should be here.

Can you try copying multiple folders?

Same result: I copy 4 folders into "/", and I get one error saying: Access denied. Could not write to "/".

Did you expect (or desire) anything else?

Did you expect (or desire) anything else?

I meant of adding test for copying multiple folders.

dfaure updated this revision to Diff 48002.Dec 22 2018, 12:01 PM

Upgrade the unittest to be data-driven, and to test for many different cases.

shubham added a comment.EditedFeb 9 2019, 3:30 PM

Can somebody experienced review this?

Usually I'm the one reviewing patches for KIO, but yeah, for my own patches, who's going to review them? :-)

ngraham accepted this revision.Sep 17 2019, 7:37 PM
ngraham added a subscriber: ngraham.

FWIW I can confirm that it fixes the bug. I'm not an expert in KIO code but it all looks sensible enough to me, and the autotest passes.

Maybe we should land it sooner rather than later with a "you break it you buy fix it" caveat. :)

This revision is now accepted and ready to land.Sep 17 2019, 7:37 PM
dfaure closed this revision.Sep 17 2019, 10:20 PM

Hmm, this broke PrivilegeJobTest::privilegeCopy.
If we don't give a chance to the kioslave to see the copy operation, it can't offer escalating priviledges to run the operation as root.

I guess the bug report is from before we have privilege escalation....

I think that all I can do is skip this check unless privilege escalation is disabled (but that won't help dolphin).