PolKit Actions KCM: do not crash if policies could not be read

Review Request #111093 - Created June 18, 2013 and submitted

Jonathan Marten
kde-workspace, polkit-kde-kcmodules-1
The referenced bug describes a crash in the System Settings - System Administration - Actions Policy module.  The first time that an action is clicked on, an attempt is made to read the current system policy settings via ActionWidget::reloadPKLAs().  Internally this checks the authorisation for the org.kde.polkitkde1.readauthorizations action.  If this action is not allowed, or the authorization fails, then a DBus error is returned - but never checked.  There is then a crash (via qFatal) when an attempt is made to read from the invalid returned QDBusArgument.

Unless the user made a mistake (e.g. typing the root password incorrectly), this indicates a system configuration problem.  However, even if the fix needs to be elsewhere, systemsettings should not just crash with no indication of where the problem lies.

This change checks and reports the DBus error if one is returned.  Nothing can be done within this module if this is the case, but at least there is a diagnostic message.  The widget is left disabled, but will try the authorization again if another action is selected.
With the default policy in place for org.kde.polkit1.readauthorizations (active session = auth_admin, inactive session = no), run 'kcmshell4 kcm_polkitactions'.  Expand the tree and click on any action.  In the password dialogue, either cancel or enter an incorrect password.  Check that there is no crash and that the message box is displayed.

Click on another action, correctly enter the password and observe that there is no message and policies are displayed as expected.
Jonathan Marten
Jaime Torres Amate
Commit Hook
Jonathan Marten
Review request changed

Status: Closed (submitted)