Improve error handling in file ioslave
ClosedPublic

Authored by chinmoyr on Feb 3 2018, 9:10 AM.

Details

Summary

When executing an action with elevated privileges file ioslave directly checks errno
and then decides whether to continue or not. Since errno can change frequently
between function call it should not be relied upon.
With this patch after a function fails errno value is saved and then that saved value
is used wherever required.

Diff Detail

Repository
R241 KIO
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
chinmoyr created this revision.Feb 3 2018, 9:10 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 3 2018, 9:10 AM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
chinmoyr requested review of this revision.Feb 3 2018, 9:10 AM
chinmoyr updated this revision to Diff 26415.Feb 3 2018, 9:21 AM

Used KIO error codes for windows

dfaure requested changes to this revision.Feb 3 2018, 9:31 AM
dfaure added inline comments.
src/ioslaves/file/file_unix.cpp
122 ↗(On Diff #26415)

Why errno here? What sets it? Shouldn't that be errcode?

815 ↗(On Diff #26415)

What happened to the code that was passing socketPath() for OPEN and OPENDIR? It wasn't needed?

src/ioslaves/file/file_win.cpp
392 ↗(On Diff #26415)

Why not just return the errcode that was given as input?
Won't this change mess up all error handling on Windows, otherwise, by "eating" the proper error codes?

This revision now requires changes to proceed.Feb 3 2018, 9:31 AM
chinmoyr updated this revision to Diff 26417.Feb 3 2018, 9:40 AM

errno -> errcode
KIO::ERR_ACCESS_DENIED -> err
socketPath is passed as an argument in line 106

socketPath() being passed by argument: true for OPEN indeed, but what about OPENDIR?

socketPath() being passed by argument: true for OPEN indeed, but what about OPENDIR?

No method in FileProtocol calls execWithElevatedPrivilege with OPENDIR action. If one does in future then we can pass socetPath() as argument there.

dfaure accepted this revision.Feb 3 2018, 10:27 AM

Ah OK so it was dead code. Removing dead code is always good.

The patch looks ok to me now -- assuming the unittests still pass, which you didn't mention in the testing section of this review request.

This revision is now accepted and ready to land.Feb 3 2018, 10:27 AM

The unittests pass.

This revision was automatically updated to reflect the committed changes.