Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Credentials

[36:7] extends: object

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 to G_CREDENTIALS_TYPE_LINUX_UCRED. On Apple operating systems (including iOS, tvOS, and macOS), the native credential type is a struct xucred. This corresponds to G_CREDENTIALS_TYPE_APPLE_XUCRED. 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. Since GLib 2.72, on Windows, the native credentials may contain the PID of a process. This corresponds to G_CREDENTIALS_TYPE_WIN32_PID.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • Credentials ()

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

  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • get_native (string native_type)

    Gets a pointer to native credentials of type @native_type from

    • @credentials. It is a programming error (which will cause a warning to be logged) to use this method if there is no #GCredentials support for the OS or if @native_type isn't supported by the OS.
    • @p native_type is The type of native credentials to get..
  • is_same_user (object other_credentials)

    Checks if @credentials and @other_credentials is the same user. This operation can fail if #GCredentials is not supported on the the OS.

    • @p other_credentials is A #GCredentials..
  • set_native (string native_type, native)

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

    • @credentials. It is a programming error (which will cause a warning to be logged) to use this method if there is no #GCredentials support for the OS or if @native_type isn't supported by the OS.
    • @p native_type is The type of native credentials to set..
    • @p native is A pointer to native credentials..
    • @r None.
  • to_string ()

    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.