Core API Reference - Configuration
Desktop Apps Training - Policy Kit

Configuration

Configuration — Represents the system-wide /etc/PolicyKit/PolicyKit.conf file.

 

Synopsis



PolKitConfig;
PolKitConfig* polkit_config_new (const char *path,
PolKitError **error);
PolKitConfig* polkit_config_ref (PolKitConfig *pk_config);
void polkit_config_unref (PolKitConfig *pk_config);
PolKitResult polkit_config_can_session_do_action (PolKitConfig *pk_config,
PolKitAction *action,
PolKitSession *session);
PolKitResult polkit_config_can_caller_do_action (PolKitConfig *pk_config,
PolKitAction *action,
PolKitCaller *caller);
enum PolKitConfigAdminAuthType;
polkit_bool_t polkit_config_determine_admin_auth_type
(PolKitConfig *pk_config,
PolKitAction *action,
PolKitCaller *caller,
PolKitConfigAdminAuthType *out_admin_auth_type,
const char **out_data);

Description

This class is used to represent the /etc/PolicyKit/PolicyKit.conf configuration file. Applications using PolicyKit should never use this class; it's only here for integration with other PolicyKit components.

 

Details

PolKitConfig

typedef struct _PolKitConfig PolKitConfig;

This class represents the system-wide configuration file for PolicyKit. Applications using PolicyKit should never use this class; it's only here for integration with other PolicyKit components.

 


polkit_config_new ()

PolKitConfig*       polkit_config_new                   (const char *path,
PolKitError **error);

Load and parse a PolicyKit configuration file.

 

path :

Path to configuration, typically /etc/PolicyKit/PolicyKit.conf is passed.

error :

return location for error

Returns :

the configuration file object

polkit_config_ref ()

PolKitConfig*       polkit_config_ref                   (PolKitConfig *pk_config);

Increase reference count.

 

pk_config :

the object

Returns :

the object

polkit_config_unref ()

void                polkit_config_unref                 (PolKitConfig *pk_config);

Decreases the reference count of the object. If it becomes zero, the object is freed. Before freeing, reference counts on embedded objects are decresed by one.

 

pk_config :

the object

polkit_config_can_session_do_action ()

PolKitResult        polkit_config_can_session_do_action (PolKitConfig *pk_config,
PolKitAction *action,
PolKitSession *session);

Determine if the /etc/PolicyKit/PolicyKit.conf configuration file says that a given session can do a given action.

 

pk_config :

the PolicyKit context

action :

the type of access to check for

session :

the session in question

Returns :

A PolKitResult - returns POLKIT_RESULT_UNKNOWN if there was no match in the configuration file.

polkit_config_can_caller_do_action ()

PolKitResult        polkit_config_can_caller_do_action  (PolKitConfig *pk_config,
PolKitAction *action,
PolKitCaller *caller);

Determine if the /etc/PolicyKit/PolicyKit.conf configuration file says that a given caller can do a given action.

 

pk_config :

the PolicyKit context

action :

the type of access to check for

caller :

the caller in question

Returns :

A PolKitResult - returns POLKIT_RESULT_UNKNOWN if there was no match in the configuration file.

enum PolKitConfigAdminAuthType

typedef enum
{
POLKIT_CONFIG_ADMIN_AUTH_TYPE_USER,
POLKIT_CONFIG_ADMIN_AUTH_TYPE_GROUP
} PolKitConfigAdminAuthType;

This enumeration reflects results defined in the "define_admin_auth" configuration element.

 

POLKIT_CONFIG_ADMIN_AUTH_TYPE_USER

Authentication as administrator matches one or more users

POLKIT_CONFIG_ADMIN_AUTH_TYPE_GROUP

Authentication as administrator matches users from one or more groups

polkit_config_determine_admin_auth_type ()

polkit_bool_t       polkit_config_determine_admin_auth_type
(PolKitConfig *pk_config,
PolKitAction *action,
PolKitCaller *caller,
PolKitConfigAdminAuthType *out_admin_auth_type,
const char **out_data);

Determine what "Authenticate as admin" means for a given caller and a given action. This basically returns the result of the "define_admin_auth" in the configuration file when drilling down for a specific caller / action.

 

pk_config :

the PolicyKit context

action :

the type of access to check for

caller :

the caller in question

out_admin_auth_type :

return location for the authentication type

out_data :

return location for the match value of the given authentication type. Caller shall not manipulate or free this string.

Returns :

TRUE if value was returned