Check error status after every PolKitAuthority usage
ClosedPublic

Authored by skalinichev on May 27 2017, 7:02 AM.

Details

Summary

Otherwise if some error occurred in e.g. checkAuthorizationSync call, enumerateActions call would also fail (as PolKitAuthority already set error flag internally)

Diff Detail

Repository
R283 KAuth
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
skalinichev created this revision.May 27 2017, 7:02 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 27 2017, 7:02 AM
aacid added a subscriber: aacid.May 27 2017, 9:25 AM
aacid added inline comments.
src/backends/polkit-1/Polkit1Backend.cpp
220

This seems a bit weird since we have done nothing with authority here, so how would it have an error?

skalinichev added inline comments.May 27 2017, 3:28 PM
src/backends/polkit-1/Polkit1Backend.cpp
220

Well yes it shouldn't happen now with the two other checks above. This check here just in case (that's why I use qWarning here instead of qCDebug as in two other cases).

Also since PolkitAuthoruty is a singleton theoretically some other code using PolkitQt1::Authority methods could trigger such errors.

skalinichev added inline comments.
src/backends/polkit-1/Polkit1Backend.cpp
220

Thinking a bit more about it, it can actually happen if enumerateActions call failed.

aacid added a comment.May 28 2017, 9:00 PM

Have you had these errors happen to you?

How can one reproduce them?

Or is it more of a "this should be the right code but i don't know how to trigger it" case?

In D5983#112386, @aacid wrote:

Have you had these errors happen to you?

How can one reproduce them?

Or is it more of a "this should be the right code but i don't know how to trigger it" case?

Yes, for me it happens all the time when I try to adjust screen brightness after switching between VT's.

Here is the error that I get with my patch:
KAuth::Polkit1Backend::actionStatus: Encountered error while checking action status, error code: 2 "GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Action org.kde.powerdevil.discretegpuhelper.hasdualgpu is not registered"

Sure one has to fix this error in the first place, but it's always a good thing to error-proof the code.

This revision was automatically updated to reflect the committed changes.
aacid added a comment.Jun 4 2017, 12:21 PM

Did you commit this on purpose without the review being accepted or was it a mistake?

In D5983#113975, @aacid wrote:

Did you commit this on purpose without the review being accepted or was it a mistake?

Yeah, I did it on purpose since:

  1. It was on review long enough (more than a week), so anyone who wanted to review it had plenty of time to do so.
  2. There are no open issues.
  3. The patch itself is very simple: it just checks error status after polkit authority function calls.
  4. I've been using it localy on 2 different configurations for more than 2 weeks with no issues.

Anyway if you have any comments regarding this patch please feel free to make a postreiew I'll gladly fix any bugs you can find!

aacid added a comment.Jun 4 2017, 10:39 PM
In D5983#113975, @aacid wrote:

Did you commit this on purpose without the review being accepted or was it a mistake?

Yeah, I did it on purpose since:

  1. It was on review long enough (more than a week), so anyone who wanted to review it had plenty of time to do so.
  2. There are no open issues.
  3. The patch itself is very simple: it just checks error status after polkit authority function calls.
  4. I've been using it localy on 2 different configurations for more than 2 weeks with no issues.

    Anyway if you have any comments regarding this patch please feel free to make a postreiew I'll gladly fix any bugs you can find!

I find this impolite, it was on my queue for reviewing properly, just i have had a very busy week.

But anyway you're the maintainer of kauth now, congratulations :)

Please next time you want to commit something because you feel it's been long enough in the queue i would sincerely appreciate if you say "i'll commit this in a week if noone disagrees", it will give people a chance to say "wait i want to have another look"

In D5983#114146, @aacid wrote:

I find this impolite, it was on my queue for reviewing properly, just i have had a very busy week.

Ah, sorry for the misunderstanding, I simply thought that you didn't care about it anymore :)

Please next time you want to commit something because you feel it's been long enough in the queue i would sincerely appreciate if you say "i'll commit this in a week if noone disagrees", it will give people a chance to say "wait i want to have another look"

That's a very useful advice, I'll definitely follow it, thanks!