Gio.Credentials¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gio.Credentials(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The
GCredentials
type is a reference-counted wrapper for native credentials.The information in
GCredentials
is typically used for identifying, authenticating and authorizing other processes.Some operating systems supports looking up the credentials of the remote peer of a communication endpoint - see e.g. [method`Gio`.Socket.get_credentials].
Some operating systems supports securely sending and receiving credentials over a Unix Domain Socket, see [class`Gio`.UnixCredentialsMessage], [method`Gio`.UnixConnection.send_credentials] and [method`Gio`.UnixConnection.receive_credentials] for details.
On Linux, the native credential type is a
struct ucred
- see the unix(7) man page) for details. This corresponds toG_CREDENTIALS_TYPE_LINUX_UCRED
.On Apple operating systems (including iOS, tvOS, and macOS), the native credential type is a
struct xucred
. This corresponds toG_CREDENTIALS_TYPE_APPLE_XUCRED
.On FreeBSD, Debian GNU/kFreeBSD, and GNU/Hurd, the native credential type is a
struct cmsgcred
. This corresponds toG_CREDENTIALS_TYPE_FREEBSD_CMSGCRED
.On NetBSD, the native credential type is a
struct unpcbid
. This corresponds toG_CREDENTIALS_TYPE_NETBSD_UNPCBID
.On OpenBSD, the native credential type is a
struct sockpeercred
. This corresponds toG_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED
.On Solaris (including OpenSolaris and its derivatives), the native credential type is a
ucred_t
. This corresponds toG_CREDENTIALS_TYPE_SOLARIS_UCRED
.Since GLib 2.72, on Windows, the native credentials may contain the PID of a process. This corresponds to
G_CREDENTIALS_TYPE_WIN32_PID
.New in version 2.26.
- classmethod new()[source]¶
- Returns:
A
Gio.Credentials
. Free withGObject.Object.unref
().- Return type:
Creates a new
Gio.Credentials
object with credentials matching the the current process.New in version 2.26.
- get_unix_pid()[source]¶
- Raises:
- Returns:
The UNIX process ID, or
-1
if error is set.- Return type:
Tries to get the UNIX process identifier from self. This method is only available on UNIX platforms.
This operation can fail if
Gio.Credentials
is not supported on the OS or if the native credentials type does not contain information about the UNIX process ID.New in version 2.36.
- get_unix_user()[source]¶
- Raises:
- Returns:
The UNIX user identifier or
-1
if error is set.- Return type:
Tries to get the UNIX user identifier from self. This method is only available on UNIX platforms.
This operation can fail if
Gio.Credentials
is not supported on the OS or if the native credentials type does not contain information about the UNIX user.New in version 2.26.
- is_same_user(other_credentials)[source]¶
- Parameters:
other_credentials (
Gio.Credentials
) – AGio.Credentials
.- Raises:
- Returns:
True
if self and other_credentials has the same user,False
otherwise or if error is set.- Return type:
Checks if self and other_credentials is the same user.
This operation can fail if
Gio.Credentials
is not supported on the the OS.New in version 2.26.
- set_native(native_type, native)[source]¶
- Parameters:
native_type (
Gio.CredentialsType
) – The type of native credentials to set.native (
object
) – A pointer to native credentials.
Copies the native credentials of type native_type from native into self.
It is a programming error (which will cause a warning to be logged) to use this method if there is no
Gio.Credentials
support for the OS or if native_type isn’t supported by the OS.New in version 2.26.
- set_unix_user(uid)[source]¶
- Parameters:
uid (
int
) – The UNIX user identifier to set.- Raises:
- Returns:
- Return type:
Tries to set the UNIX user identifier on self. This method is only available on UNIX platforms.
This operation can fail if
Gio.Credentials
is not supported on the OS or if the native credentials type does not contain information about the UNIX user. It can also fail if the OS does not allow the use of “spoofed” credentials.New in version 2.26.