Credentials

The GCredentials type is a reference-counted wrapper for native credentials. This information 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. g_socket_get_credentials().

Some operating systems supports securely sending and receiving credentials over a Unix Domain Socket, see GUnixCredentialsMessage, g_unix_connection_send_credentials() and g_unix_connection_receive_credentials() for details.

On Linux, the native credential type is a struct ucred - see the unix(7) man page for details. This corresponds to G_CREDENTIALS_TYPE_LINUX_UCRED.

On FreeBSD, Debian GNU/kFreeBSD, and GNU/Hurd, the native credential type is a struct cmsgcred. This corresponds to G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED.

On NetBSD, the native credential type is a struct unpcbid. This corresponds to G_CREDENTIALS_TYPE_NETBSD_UNPCBID.

On OpenBSD, the native credential type is a struct sockpeercred. This corresponds to G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED.

On Solaris (including OpenSolaris and its derivatives), the native credential type is a ucred_t. This corresponds to G_CREDENTIALS_TYPE_SOLARIS_UCRED.

Constructors

this
this(GCredentials* gCredentials, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new GCredentials object with credentials matching the the current process.

Members

Functions

getCredentialsStruct
GCredentials* getCredentialsStruct(bool transferOwnership = false)

Get the main Gtk struct

getNative
void* getNative(GCredentialsType nativeType)

Gets a pointer to native credentials of type native_type from credentials.

getStruct
void* getStruct()

the main Gtk struct as a void*

getUnixPid
pid_t getUnixPid()

Tries to get the UNIX process identifier from credentials. This method is only available on UNIX platforms.

getUnixUser
uid_t getUnixUser()

Tries to get the UNIX user identifier from credentials. This method is only available on UNIX platforms.

isSameUser
bool isSameUser(Credentials otherCredentials)

Checks if credentials and other_credentials is the same user.

setNative
void setNative(GCredentialsType nativeType, void* native)

Copies the native credentials of type native_type from native into credentials.

setUnixUser
bool setUnixUser(uid_t uid)

Tries to set the UNIX user identifier on credentials. This method is only available on UNIX platforms.

toString
string toString()

Creates a human-readable textual representation of credentials that can be used in logging and debug messages. The format of the returned string may change in future GLib release.

Static functions

getType
GType getType()

Variables

gCredentials
GCredentials* gCredentials;

the main Gtk struct

Meta

Since

2.26