Top |
PolkitAgentSession * | polkit_agent_session_new () |
void | polkit_agent_session_initiate () |
void | polkit_agent_session_response () |
void | polkit_agent_session_cancel () |
gchar * | cookie | Read / Write / Construct Only |
PolkitIdentity * | identity | Read / Write / Construct Only |
void | completed | Run Last |
void | request | Run Last |
void | show-error | Run Last |
void | show-info | Run Last |
The PolkitAgentSession class is an abstraction used for interacting with the native authentication system (for example PAM) for obtaining authorizations. This class is typically used together with instances that are derived from the PolkitAgentListener abstract base class.
To perform the actual authentication, PolkitAgentSession uses a trusted suid helper.
The authentication conversation is done through a pipe. This is transparent; the user
only need to handle the
“request”,
“show-info”,
“show-error” and
“completed”
signals and invoke polkit_agent_session_response()
in response to requests.
If the user successfully authenticates, the authentication helper will invoke
a method on the PolicyKit daemon (see polkit_authority_authentication_agent_response_sync()
)
with the given cookie
. Upon receiving a positive response from the PolicyKit daemon (via
the authentication helper), the “completed” signal will be emitted
with the gained_authorization
paramter set to TRUE
.
If the user is unable to authenticate, the “completed” signal will
be emitted with the gained_authorization
paramter set to FALSE
.
PolkitAgentSession * polkit_agent_session_new (PolkitIdentity *identity
,const gchar *cookie
);
Creates a new authentication session.
The caller should connect to the
“request”,
“show-info”,
“show-error” and
“completed”
signals and then call polkit_agent_session_initiate()
to initiate the authentication session.
void
polkit_agent_session_initiate (PolkitAgentSession *session
);
Initiates the authentication session. Before calling this method,
make sure to connect to the various signals. The signals will be
emitted in the
Use polkit_agent_session_cancel()
to cancel the session.
void polkit_agent_session_response (PolkitAgentSession *session
,const gchar *response
);
Function for providing response to requests received via the “request” signal.
void
polkit_agent_session_cancel (PolkitAgentSession *session
);
Cancels an authentication session. This will make session
emit the “completed”
signal.
typedef struct _PolkitAgentSession PolkitAgentSession;
The PolkitAgentSession struct should not be accessed directly.
“cookie”
property “cookie” gchar *
The cookie obtained from the PolicyKit daemon
Flags: Read / Write / Construct Only
Default value: NULL
“identity”
property“identity” PolkitIdentity *
The identity to authenticate.
Flags: Read / Write / Construct Only
“completed”
signalvoid user_function (PolkitAgentSession *session, gboolean gained_authorization, gpointer user_data)
Emitted when the authentication session has been completed or
cancelled. The gained_authorization
parameter is TRUE
only if
the user successfully authenticated.
Upon receiving this signal, the user should free session
using g_object_unref()
.
session |
||
gained_authorization |
|
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“request”
signalvoid user_function (PolkitAgentSession *session, gchar *request, gboolean echo_on, gpointer user_data)
Emitted when the user is requested to answer a question.
When the response has been collected from the user, call polkit_agent_session_response()
.
session |
||
request |
The request to show the user, e.g. "name: " or "password: ". |
|
echo_on |
|
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“show-error”
signalvoid user_function (PolkitAgentSession *session, gchar *text, gpointer user_data)
Emitted when there is information related to an error condition to be displayed to the user.
session |
||
text |
An error string to display to the user. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“show-info”
signalvoid user_function (PolkitAgentSession *session, gchar *text, gpointer user_data)
Emitted when there is information to be displayed to the user.
session |
||
text |
A string to display to the user. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last