Core API Reference - Results
Desktop Apps Training - Policy Kit

Results

Results — Definition of results of PolicyKit queries.

 

Synopsis



enum PolKitResult;
const char* polkit_result_to_string_representation
(PolKitResult result);
polkit_bool_t polkit_result_from_string_representation
(const char *string,
PolKitResult *out_result);

Description

These functions are used to manipulate PolicyKit results.

 

Details

enum PolKitResult

typedef enum
{
POLKIT_RESULT_UNKNOWN,

POLKIT_RESULT_NO,

POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH,
POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION,
POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS,

POLKIT_RESULT_ONLY_VIA_SELF_AUTH,
POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION,
POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS,

POLKIT_RESULT_YES,

POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT,
POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT,

POLKIT_RESULT_N_RESULTS
} PolKitResult;

Result codes from queries to PolicyKit. This enumeration may grow in the future. One should never rely on the ordering

 

POLKIT_RESULT_UNKNOWN

The result is unknown / cannot be computed. This is mostly used internally in libpolkit.

POLKIT_RESULT_NO

Access denied.

POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH

Access denied, but authentication by the caller as administrator (e.g. root or a member in the wheel group depending on configuration) will grant access to the process the caller is originating from.

POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION

Access denied, but authentication by the caller as administrator (e.g. root or a member in the wheel group depending on configuration) will grant access for the remainder of the session

POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS

Access denied, but authentication by the caller as administrator (e.g. root or a member in the wheel group depending on configuration) will grant access in the future.

POLKIT_RESULT_ONLY_VIA_SELF_AUTH

Access denied, but authentication by the caller as himself will grant access to the process the caller is originating from.

POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION

Access denied, but authentication by the caller as himself will grant access to the resource for the remainder of the session

POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS

Access denied, but authentication by the caller as himself will grant access to the resource in the future.

POLKIT_RESULT_YES

Access granted.

POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT

Access denied, but authentication by the caller as administrator (e.g. root or a member in the wheel group depending on configuration) will grant access exactly one time to the process the caller is originating from. See polkit_context_is_caller_authorized() for discussion (and limitations) about one-shot authorizations.

POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT

Access denied, but authentication by the caller as himself will grant access exactly one time to the process the caller is originating from. See polkit_context_is_caller_authorized() for discussion (and limitations) about one-shot authorizations.

POLKIT_RESULT_N_RESULTS

Number of result codes

polkit_result_to_string_representation ()

const char*         polkit_result_to_string_representation
(PolKitResult result);

Gives a textual representation of a PolKitResult object. This string is not suitable for displaying to an end user (it's not localized for starters) but is useful for serialization as it can be converted back to a PolKitResult object using polkit_result_from_string_representation().

 

result :

the given result to get a textual representation of

Returns :

string representing the result (do not free) or NULL if the given result is invalid

polkit_result_from_string_representation ()

polkit_bool_t       polkit_result_from_string_representation
(const char *string,
PolKitResult *out_result);

Given a textual representation of a PolKitResult object, find the PolKitResult value.

 

string :

textual representation of a PolKitResult object

out_result :

return location for PolKitResult

Returns :

TRUE if the textual representation was valid, otherwise FALSE