![]() |
![]() |
![]() |
![]() |
polkit applications are privileged mechanisms using the polkit 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 polkit Authority.
Note that clients normally doesn't use the polkit 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 polkit 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. Alternatively, the pkttyagent(1) helper can be used 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”.