libpolkit-grant

libpolkit-grant —

Synopsis




struct      LibPolKitGrantContext_s;
typedef     LibPolKitGrantContext;
void        (*LibPolKitGrantQuestions)      (LibPolKitGrantContext *ctx,
                                             const char **questions,
                                             gpointer user_data);
void        (*LibPolKitGrantComplete)       (LibPolKitGrantContext *ctx,
                                             gboolean obtained_privilege,
                                             const char *reason_not_obtained,
                                             gpointer user_data);
LibPolKitGrantContext* libpolkit_grant_new_context
                                            (DBusGConnection *dbus_g_connection,
                                             const char *user,
                                             const char *privilege,
                                             const char *resource,
                                             gboolean restrict _to_dbus_connection,
                                             gpointer user_data);
const char* libpolkit_grant_get_user        (LibPolKitGrantContext *ctx);
const char* libpolkit_grant_get_privilege   (LibPolKitGrantContext *ctx);
const char* libpolkit_grant_get_resource    (LibPolKitGrantContext *ctx);
LibPolKitContext* libpolkit_grant_get_libpolkit_context
                                            (LibPolKitGrantContext *ctx);
void        libpolkit_grant_set_questions_handler
                                            (LibPolKitGrantContext *ctx,
                                             LibPolKitGrantQuestions questions_handler);
void        libpolkit_grant_set_grant_complete_handler
                                            (LibPolKitGrantContext *ctx,
                                             LibPolKitGrantComplete grant_complete_handler);
gboolean    libpolkit_grant_initiate_temporary_grant
                                            (LibPolKitGrantContext *ctx);
const char* libpolkit_grant_get_user_for_auth
                                            (LibPolKitGrantContext *ctx);
const char* libpolkit_grant_get_pam_service_for_auth
                                            (LibPolKitGrantContext *ctx);
void        libpolkit_grant_provide_answers (LibPolKitGrantContext *ctx,
                                             const char **answers);
gboolean    libpolkit_grant_close           (LibPolKitGrantContext *ctx,
                                             gboolean revoke_privilege);
void        libpolkit_grant_free_context    (LibPolKitGrantContext *ctx);

Description

Details

struct LibPolKitGrantContext_s

struct LibPolKitGrantContext_s;


LibPolKitGrantContext

typedef struct LibPolKitGrantContext_s LibPolKitGrantContext;


LibPolKitGrantQuestions ()

void        (*LibPolKitGrantQuestions)      (LibPolKitGrantContext *ctx,
                                             const char **questions,
                                             gpointer user_data);

Callback when information is needed from the user in order to authenticate.

The first component of the each pair in the questions array denote the question type. It can assume the values "PamPromptEchoOff" (meaning prompt for answer but don't echo it on the screen as the user types it), "PamPromptEchoOn" (meaning prompt for answer and echo the answer on the screen as the user types it), "PamErrorMsg" (display the message as an error message to the user) and "PamTextInfo" (textual information to the user). The second component in the pair is the actual question or information (e.g. "Password:") and it should be shown to the user next to the text input box.

The callee should call libpolkit_grant_provide_answers with a string array once it the answers have been obtained from the user.

ctx : Context
questions : NULL terminated series of pairs. Each pair represent one question.
user_data : User data

LibPolKitGrantComplete ()

void        (*LibPolKitGrantComplete)       (LibPolKitGrantContext *ctx,
                                             gboolean obtained_privilege,
                                             const char *reason_not_obtained,
                                             gpointer user_data);

Callback when authorization was complete or there was an error.

ctx :
obtained_privilege : Whether the user sucessfully authenticated and was granted the privilege.
reason_not_obtained : If the user did not obtain the privilege this is the reason. May be NULL.
user_data : User data

libpolkit_grant_new_context ()

LibPolKitGrantContext* libpolkit_grant_new_context
                                            (DBusGConnection *dbus_g_connection,
                                             const char *user,
                                             const char *privilege,
                                             const char *resource,
                                             gboolean restrict _to_dbus_connection,
                                             gpointer user_data);

Create a new context for obtaining a privilege.

dbus_g_connection :
user : User to request privilege for
privilege : Privilege to ask for
resource : Resource to ask for. May be NULL.
_to_dbus_connection :
user_data : User data to be passed to callbacks
Returns : The context. It is an opaque data structure. Free with libpolkit_grant_free_context.

libpolkit_grant_get_user ()

const char* libpolkit_grant_get_user        (LibPolKitGrantContext *ctx);

ctx :
Returns :

libpolkit_grant_get_privilege ()

const char* libpolkit_grant_get_privilege   (LibPolKitGrantContext *ctx);

ctx :
Returns :

libpolkit_grant_get_resource ()

const char* libpolkit_grant_get_resource    (LibPolKitGrantContext *ctx);

Get the resource as passed in from libpolkit_grant_new_context.

ctx : Context
Returns : The resource. May be NULL.

libpolkit_grant_get_libpolkit_context ()

LibPolKitContext* libpolkit_grant_get_libpolkit_context
                                            (LibPolKitGrantContext *ctx);

ctx :
Returns :

libpolkit_grant_set_questions_handler ()

void        libpolkit_grant_set_questions_handler
                                            (LibPolKitGrantContext *ctx,
                                             LibPolKitGrantQuestions questions_handler);

ctx :
questions_handler :

libpolkit_grant_set_grant_complete_handler ()

void        libpolkit_grant_set_grant_complete_handler
                                            (LibPolKitGrantContext *ctx,
                                             LibPolKitGrantComplete grant_complete_handler);

ctx :
grant_complete_handler :

libpolkit_grant_initiate_temporary_grant ()

gboolean    libpolkit_grant_initiate_temporary_grant
                                            (LibPolKitGrantContext *ctx);

ctx :
Returns :

libpolkit_grant_get_user_for_auth ()

const char* libpolkit_grant_get_user_for_auth
                                            (LibPolKitGrantContext *ctx);

ctx :
Returns :

libpolkit_grant_get_pam_service_for_auth ()

const char* libpolkit_grant_get_pam_service_for_auth
                                            (LibPolKitGrantContext *ctx);

ctx :
Returns :

libpolkit_grant_provide_answers ()

void        libpolkit_grant_provide_answers (LibPolKitGrantContext *ctx,
                                             const char **answers);

ctx :
answers :

libpolkit_grant_close ()

gboolean    libpolkit_grant_close           (LibPolKitGrantContext *ctx,
                                             gboolean revoke_privilege);

ctx :
revoke_privilege :
Returns :

libpolkit_grant_free_context ()

void        libpolkit_grant_free_context    (LibPolKitGrantContext *ctx);

ctx :