polkit Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
PolkitAgentSession; PolkitAgentSession * polkit_agent_session_new (PolkitIdentity *identity
,const gchar *cookie
); void polkit_agent_session_initiate (PolkitAgentSession *session
); void polkit_agent_session_response (PolkitAgentSession *session
,const gchar *response
); void polkit_agent_session_cancel (PolkitAgentSession *session
);
"cookie" gchar* : Read / Write / Construct Only "identity" PolkitIdentity* : Read / Write / Construct Only
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
.
typedef struct _PolkitAgentSession PolkitAgentSession;
The PolkitAgentSession struct should not be accessed directly.
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.
|
The identity to authenticate. |
|
The cookie obtained from the PolicyKit daemon |
Returns : |
A PolkitAgentSession. Free with g_object_unref() . |
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.
|
A PolkitAgentSession. |
void polkit_agent_session_response (PolkitAgentSession *session
,const gchar *response
);
Function for providing response to requests received via the "request" signal.
|
A PolkitAgentSession. |
|
Response from the user, typically a password. |
void polkit_agent_session_cancel (PolkitAgentSession *session
);
Cancels an authentication session. This will make session
emit the "completed"
signal.
|
A PolkitAgentSession. |
"cookie"
property"cookie" gchar* : Read / Write / Construct Only
The cookie obtained from the PolicyKit daemon
Default value: NULL
"identity"
property"identity" PolkitIdentity* : Read / Write / Construct Only
The identity to authenticate.
"completed"
signalvoid user_function (PolkitAgentSession *session,
gboolean gained_authorization,
gpointer user_data) : Run Last
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()
.
|
A PolkitAgentSession. |
|
TRUE only if the authorization was successfully obtained. |
|
user data set when the signal handler was connected. |
"request"
signalvoid user_function (PolkitAgentSession *session,
gchar *request,
gboolean echo_on,
gpointer user_data) : Run Last
Emitted when the user is requested to answer a question.
When the response has been collected from the user, call polkit_agent_session_response()
.
|
A PolkitAgentSession. |
|
The request to show the user, e.g. "name: " or "password: ". |
|
TRUE if the response to the request SHOULD be echoed on the
screen, FALSE if the response MUST NOT be echoed to the screen. |
|
user data set when the signal handler was connected. |
"show-error"
signalvoid user_function (PolkitAgentSession *session,
gchar *text,
gpointer user_data) : Run Last
Emitted when there is information related to an error condition to be displayed to the user.
|
A PolkitAgentSession. |
|
An error string to display to the user. |
|
user data set when the signal handler was connected. |
"show-info"
signalvoid user_function (PolkitAgentSession *session,
gchar *text,
gpointer user_data) : Run Last
Emitted when there is information to be displayed to the user.
|
A PolkitAgentSession. |
|
A string to display to the user. |
|
user data set when the signal handler was connected. |