![]() |
![]() |
![]() |
PolicyKit Reference Manual | ![]() |
---|
PolicyKit applications are privileged mechanisms using the PolicyKit authority as a decider component. To do this, a mechanism use either the GObject API, the D-Bus API or the pkcheck command to communicate with the PolicyKit Authority.
Note that clients normally doesn't use the PolicyKit API directly – it is intended for privileged mechanisms. If a client needs to disable, modify or remove UI elements to e.g. convey to the user that a certain action cannot be carried out (because e.g. the user is not authorized) or authentication is needed (by e.g. displaying a padlock icon in the UI), it is usually better to have the mechanism provide an API for this.
If a PolicyKit application wants to handle the case where no authentication agent exists (for example if the app is launched via a ssh(1) login), it is trivial for the application to use the PolkitAgentTextListener class to spawn its own authentication agent as needed. See the pkcheck or pkexec program sources for an example of how to do this.
As an example of code using the GObject API, see Example 1, “Querying the Authority”. For an example using the D-Bus API, see Example 2, “Accessing the Authority via D-Bus”.