Polkit.Authority¶
- Subclasses:
None
Methods¶
- Inherited:
GObject.Object (37), Gio.AsyncInitable (4), Gio.Initable (2)
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r |
The features of the currently used Authority backend. |
||
r |
The name of the currently used Authority backend. |
||
r |
The version of the currently used Authority backend. |
||
r |
Owner. |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when actions and/or authorizations change |
Fields¶
- Inherited:
Class Details¶
- class Polkit.Authority(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Polkit.Authority
is used for checking whether a given subject is authorized to perform a given action. Typically privileged system daemons or suid helpers will use this when handling requests from untrusted clients.User sessions can register an authentication agent with the authority. This is used for requests from untrusted clients where system policy requires that the user needs to acknowledge (through proving he is the user or the administrator) a given action. See #PolkitAgentListener and #PolkitAgentSession for details.
- classmethod get()¶
- Returns:
value
- Return type:
(deprecated)
- classmethod get_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously gets a reference to the authority.
This is an asynchronous failable function. When the result is ready, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from and you can usePolkit.Authority.get_finish
() to get the result. SeePolkit.Authority.get_sync
() for the synchronous version.
- classmethod get_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from theGio.AsyncReadyCallback
passed toPolkit.Authority.get_async
().- Raises:
- Returns:
A
Polkit.Authority
. Free it withGObject.Object.unref
() when done with it.- Return type:
Finishes an operation started with
Polkit.Authority.get_async
().
- classmethod get_sync(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.- Raises:
- Returns:
A
Polkit.Authority
. Free it withGObject.Object.unref
() when done with it.- Return type:
Synchronously gets a reference to the authority.
This is a synchronous failable function - the calling thread is blocked until a reply is received. See
Polkit.Authority.get_async
() for the asynchronous version.
- authentication_agent_response(cookie, identity, cancellable, callback, *user_data)¶
- Parameters:
cookie (
str
) – The cookie passed to the authentication agent from the authority.identity (
Polkit.Identity
) – The identity that was authenticated.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously provide response that identity successfully authenticated for the authentication request identified by cookie.
This function is only used by the privileged bits of an authentication agent. It will fail if the caller is not sufficiently privileged (typically uid 0).
When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.authentication_agent_response_finish
() to get the result of the operation.
- authentication_agent_response_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
- Return type:
Finishes providing response from an authentication agent.
- authentication_agent_response_sync(cookie, identity, cancellable)¶
- Parameters:
cookie (
str
) – The cookie passed to the authentication agent from the authority.identity (
Polkit.Identity
) – The identity that was authenticated.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
- Return type:
Provide response that identity successfully authenticated for the authentication request identified by cookie. See
Polkit.Authority.authentication_agent_response
() for limitations on who is allowed is to call this method.The calling thread is blocked until a reply is received. See
Polkit.Authority.authentication_agent_response
() for the asynchronous version.
- check_authorization(subject, action_id, details, flags, cancellable, callback, *user_data)¶
- Parameters:
subject (
Polkit.Subject
) – APolkit.Subject
.action_id (
str
) – The action to check for.details (
Polkit.Details
orNone
) – Details about the action orNone
.flags (
Polkit.CheckAuthorizationFlags
) – A set ofPolkit.CheckAuthorizationFlags
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously checks if subject is authorized to perform the action represented by action_id.
Note that
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION
SHOULD be passed ONLY if the event that triggered the authorization check is stemming from an user action, e.g. the user pressing a button or attaching a device.When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.check_authorization_finish
() to get the result of the operation.Known keys in details include
polkit.message
andpolkit.gettext_domain
that can be used to override the message shown to the user. See the documentation for the ‘D-Bus method [eggdbus-method-org.freedesktop.PolicyKit1.Authority.CheckAuthorization]’ for more details.If details is non-empty then the request will fail with
Polkit.Error.FAILED
unless the process doing the check itsef is sufficiently authorized (e.g. running as uid 0).
- check_authorization_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
A
Polkit.AuthorizationResult
orNone
if error is set. Free withGObject.Object.unref
().- Return type:
Finishes checking if a subject is authorized for an action.
- check_authorization_sync(subject, action_id, details, flags, cancellable)¶
- Parameters:
subject (
Polkit.Subject
) – APolkit.Subject
.action_id (
str
) – The action to check for.details (
Polkit.Details
orNone
) – Details about the action orNone
.flags (
Polkit.CheckAuthorizationFlags
) – A set ofPolkit.CheckAuthorizationFlags
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
A
Polkit.AuthorizationResult
orNone
if error is set. Free withGObject.Object.unref
().- Return type:
Checks if subject is authorized to perform the action represented by action_id.
Note that
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION
SHOULD be passed ONLY if the event that triggered the authorization check is stemming from an user action, e.g. the user pressing a button or attaching a device.Note the calling thread is blocked until a reply is received. You should therefore NEVER do this from a GUI thread or a daemon service thread when using the
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION
flag. This is because it may potentially take minutes (or even hours) for the operation to complete because it involves waiting for the user to authenticate.Known keys in details include
polkit.message
andpolkit.gettext_domain
that can be used to override the message shown to the user. See the documentation for the ‘D-Bus method [eggdbus-method-org.freedesktop.PolicyKit1.Authority.CheckAuthorization]’ for more details.
- enumerate_actions(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously retrieves all registered actions.
When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.enumerate_actions_finish
() to get the result of the operation.
- enumerate_actions_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
A list of
Polkit.ActionDescription
objects orNone
if error is set. The returned list should be freed with g_list_free() after each element have been freed withGObject.Object.unref
().- Return type:
Finishes retrieving all registered actions.
- enumerate_actions_sync(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.- Raises:
- Returns:
A list of
Polkit.ActionDescription
orNone
if error is set. The returned list should be freed with g_list_free() after each element have been freed withGObject.Object.unref
().- Return type:
Synchronously retrieves all registered actions - the calling thread is blocked until a reply is received. See
Polkit.Authority.enumerate_actions
() for the asynchronous version.
- enumerate_temporary_authorizations(subject, cancellable, callback, *user_data)¶
- Parameters:
subject (
Polkit.Subject
) – APolkit.Subject
, typically aPolkit.UnixSession
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously gets all temporary authorizations for subject.
When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.enumerate_temporary_authorizations_finish
() to get the result of the operation.
- enumerate_temporary_authorizations_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
A list of
Polkit.TemporaryAuthorization
objects orNone
if error is set. The returned list should be freed with g_list_free() after each element have been freed withGObject.Object.unref
().- Return type:
Finishes retrieving all registered actions.
- enumerate_temporary_authorizations_sync(subject, cancellable)¶
- Parameters:
subject (
Polkit.Subject
) – APolkit.Subject
, typically aPolkit.UnixSession
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
A list of
Polkit.TemporaryAuthorization
objects orNone
if error is set. The returned list should be freed with g_list_free() after each element have been freed withGObject.Object.unref
().- Return type:
Synchronousky gets all temporary authorizations for subject.
The calling thread is blocked until a reply is received. See
Polkit.Authority.enumerate_temporary_authorizations
() for the asynchronous version.
- get_backend_features()¶
- Returns:
Flags from
Polkit.AuthorityFeatures
.- Return type:
Gets the features supported by the authority backend.
- get_backend_name()¶
- Returns:
The name of the backend.
- Return type:
Gets the name of the authority backend.
- get_backend_version()¶
- Returns:
The version string for the backend.
- Return type:
Gets the version of the authority backend.
- get_owner()¶
-
The unique name on the system message bus of the owner of the name
org.freedesktop.PolicyKit1
orNone
if no-one currently owns the name. You may connect to theGObject.Object
::notify
signal to track changes to thePolkit.Authority
:owner
property.
- register_authentication_agent(subject, locale, object_path, cancellable, callback, *user_data)¶
- Parameters:
subject (
Polkit.Subject
) – The subject the authentication agent is for, typically aPolkit.UnixSession
object.locale (
str
) – The locale of the authentication agent.object_path (
str
) – The object path for the authentication agent.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously registers an authentication agent.
Note that this should be called by the same effective UID which will be the real UID using the #PolkitAgentSession API or otherwise calling
Polkit.Authority.authentication_agent_response
().When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.register_authentication_agent_finish
() to get the result of the operation.
- register_authentication_agent_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
True
if the authentication agent was successfully registered,False
if error is set.- Return type:
Finishes registering an authentication agent.
- register_authentication_agent_sync(subject, locale, object_path, cancellable)¶
- Parameters:
subject (
Polkit.Subject
) – The subject the authentication agent is for, typically aPolkit.UnixSession
object.locale (
str
) – The locale of the authentication agent.object_path (
str
) – The object path for the authentication agent.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
True
if the authentication agent was successfully registered,False
if error is set.- Return type:
Registers an authentication agent.
Note that this should be called by the same effective UID which will be the real UID using the #PolkitAgentSession API or otherwise calling
Polkit.Authority.authentication_agent_response
().The calling thread is blocked until a reply is received. See
Polkit.Authority.register_authentication_agent
() for the asynchronous version.
- register_authentication_agent_with_options(subject, locale, object_path, options, cancellable, callback, *user_data)¶
- Parameters:
subject (
Polkit.Subject
) – The subject the authentication agent is for, typically aPolkit.UnixSession
object.locale (
str
) – The locale of the authentication agent.object_path (
str
) – The object path for the authentication agent.options (
GLib.Variant
orNone
) – AGLib.Variant
with options orNone
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously registers an authentication agent.
Note that this should be called by the same effective UID which will be the real UID using the #PolkitAgentSession API or otherwise calling
Polkit.Authority.authentication_agent_response
().When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.register_authentication_agent_with_options_finish
() to get the result of the operation.
- register_authentication_agent_with_options_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
True
if the authentication agent was successfully registered,False
if error is set.- Return type:
Finishes registering an authentication agent.
- register_authentication_agent_with_options_sync(subject, locale, object_path, options, cancellable)¶
- Parameters:
subject (
Polkit.Subject
) – The subject the authentication agent is for, typically aPolkit.UnixSession
object.locale (
str
) – The locale of the authentication agent.object_path (
str
) – The object path for the authentication agent.options (
GLib.Variant
orNone
) – AGLib.Variant
with options orNone
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
True
if the authentication agent was successfully registered,False
if error is set.- Return type:
Registers an authentication agent.
Note that this should be called by the same effective UID which will be the real UID using the #PolkitAgentSession API or otherwise calling
Polkit.Authority.authentication_agent_response
().The calling thread is blocked until a reply is received. See
Polkit.Authority.register_authentication_agent_with_options
() for the asynchronous version.
- revoke_temporary_authorization_by_id(id, cancellable, callback, *user_data)¶
- Parameters:
id (
str
) – The opaque identifier for the temporary authorization.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously revoke a temporary authorization.
When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.revoke_temporary_authorization_by_id_finish
() to get the result of the operation.
- revoke_temporary_authorization_by_id_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
True
if the temporary authorization was revoked,False
if error is set.- Return type:
Finishes revoking a temporary authorization by id.
- revoke_temporary_authorization_by_id_sync(id, cancellable)¶
- Parameters:
id (
str
) – The opaque identifier for the temporary authorization.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
True
if the temporary authorization was revoked,False
if error is set.- Return type:
Synchronously revokes a temporary authorization.
The calling thread is blocked until a reply is received. See
Polkit.Authority.revoke_temporary_authorization_by_id
() for the asynchronous version.
- revoke_temporary_authorizations(subject, cancellable, callback, *user_data)¶
- Parameters:
subject (
Polkit.Subject
) – The subject to revoke authorizations from, typically aPolkit.UnixSession
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously revokes all temporary authorizations for subject.
When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.revoke_temporary_authorizations_finish
() to get the result of the operation.
- revoke_temporary_authorizations_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
True
if all the temporary authorizations was revoked,False
if error is set.- Return type:
Finishes revoking temporary authorizations.
- revoke_temporary_authorizations_sync(subject, cancellable)¶
- Parameters:
subject (
Polkit.Subject
) – The subject to revoke authorizations from, typically aPolkit.UnixSession
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
True
if the temporary authorization was revoked,False
if error is set.- Return type:
Synchronously revokes all temporary authorization from subject.
The calling thread is blocked until a reply is received. See
Polkit.Authority.revoke_temporary_authorizations
() for the asynchronous version.
- unregister_authentication_agent(subject, object_path, cancellable, callback, *user_data)¶
- Parameters:
subject (
Polkit.Subject
) – The subject the authentication agent is for, typically aPolkit.UnixSession
object.object_path (
str
) – The object path for the authentication agent.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied.
Asynchronously unregisters an authentication agent.
When the operation is finished, callback will be invoked in the
thread-default main loop
of the thread you are calling this method from. You can then callPolkit.Authority.unregister_authentication_agent_finish
() to get the result of the operation.
- unregister_authentication_agent_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from the callback.- Raises:
- Returns:
True
if the authentication agent was successfully unregistered,False
if error is set.- Return type:
Finishes unregistering an authentication agent.
- unregister_authentication_agent_sync(subject, object_path, cancellable)¶
- Parameters:
subject (
Polkit.Subject
) – The subject the authentication agent is for, typically aPolkit.UnixSession
object.object_path (
str
) – The object path for the authentication agent.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
True
if the authentication agent was successfully unregistered,False
if error is set.- Return type:
Unregisters an authentication agent. The calling thread is blocked until a reply is received. See
Polkit.Authority.unregister_authentication_agent
() for the asynchronous version.
Signal Details¶
- Polkit.Authority.signals.changed(authority)¶
- Signal Name:
changed
- Flags:
- Parameters:
authority (
Polkit.Authority
) – The object which received the signal
Emitted when actions and/or authorizations change
Property Details¶
- Polkit.Authority.props.backend_features¶
- Name:
backend-features
- Type:
- Default Value:
- Flags:
The features of the currently used Authority backend.
- Polkit.Authority.props.backend_name¶
-
The name of the currently used Authority backend.
- Polkit.Authority.props.backend_version¶
-
The version of the currently used Authority backend.