| Top |
| void | gss_peer_manager_ensure_peer_credentials_async () |
| gboolean | gss_peer_manager_ensure_peer_credentials_finish () |
| const gchar * | gss_peer_manager_get_peer_argv0 () |
| int | gss_peer_manager_get_peer_pidfd () |
| uid_t | gss_peer_manager_get_peer_uid () |
A peer manager is an abstraction over the management of peers on a D-Bus connection, monitoring when they disappear, and allowing querying and caching of their credentials.
Currently, the only credential stored is the path to the peer’s executable, which can be used to identify that peer. In future, other credentials may be added (and the API will change accordingly).
The default implementation for production use is GssPeerManagerDBus, which uses the D-Bus daemon to get credentials. Unit tests will use a different implementation, allowing them to provide fake data to the service easily.
void gss_peer_manager_ensure_peer_credentials_async (GssPeerManager *self,const gchar *sender,GCancellable *cancellable,GAsyncReadyCallback callback,gpointer user_data);
Ensure the credentials for a peer are in the peer manager, querying them from the D-Bus daemon if needed.
Also start watching the sender
, so that if it disappears from the bus, a
“peer-vanished” signal will be emitted.
On failure, a GDBusError is returned if querying the D-Bus daemon failed,
or GSS_PEER_MANAGER_ERROR_IDENTIFYING_PEER is returned if interpreting the
information it returned failed.
self |
||
sender |
D-Bus unique name for the peer |
|
cancellable |
a GCancellable, or |
[nullable] |
callback |
callback to call once the asynchronous operation is complete |
|
user_data |
data to pass to |
Since: 0.1.0
gboolean gss_peer_manager_ensure_peer_credentials_finish (GssPeerManager *self,GAsyncResult *result,GError **error);
Finish ensuring the credentials for a peer are in the peer manager. See
gss_peer_manager_ensure_peer_credentials_async().
If this returns TRUE, the credentials can be queried from the cache using
the accessor methods on GssPeerManager.
Since: 0.3.0
const gchar * gss_peer_manager_get_peer_argv0 (GssPeerManager *self,const gchar *sender);
Get the first argument from /proc/${pid}/cmdline for the given peer.
If no credentials are in the cache for sender
, NULL will be returned.
Since: 0.3.0
int gss_peer_manager_get_peer_pidfd (GssPeerManager *self,const gchar *sender);
Get a pidfd which references the given peer’s process.
If no credentials are in the cache for sender
, -1 will be returned.
Since: 0.3.0
uid_t gss_peer_manager_get_peer_uid (GssPeerManager *self,const gchar *sender);
Get the Unix user ID running the given peer’s process.
If no credentials are in the cache for sender
, (uid_t) -1 will be returned.
Since: 0.3.0
typedef struct _GssPeerManager GssPeerManager;
An interface for D-Bus peer management. The typical production implementation of this is GssPeerManagerDBus; other implementations can be written to be used during testing, returning mock results.
Since: 0.1.0
struct GssPeerManagerInterface {
GTypeInterface g_iface;
void (*ensure_peer_credentials_async) (GssPeerManager *manager,
const gchar *sender,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*ensure_peer_credentials_finish) (GssPeerManager *manager,
GAsyncResult *result,
GError **error);
const gchar *(*get_peer_argv0) (GssPeerManager *manager,
const gchar *sender);
int (*get_peer_pidfd) (GssPeerManager *manager,
const gchar *sender);
uid_t (*get_peer_uid) (GssPeerManager *manager,
const gchar *sender);
};
An interface which exposes peers for the service (typically, D-Bus clients which are calling its methods) and allows querying of their credentials, and notification of when they disappear.
All virtual methods in this interface are mandatory to implement if the interface is implemented.
Query for the credentials of the given peer, and ensure they are in the peer manager’s cache. |
||
Finish an asynchronous query operation
started with |
||
Get argv0 credential for a peer out of the peer manager’s
cache. If the peer is not known to the manager, return |
||
Get a pidfd for the peer’s process out of the peer manager’s
cache. If the peer is not known to the manager, return |
||
Get the Unix user ID running the peer’s process out of the
peer manager’s cache. If the peer is not known to the manager, return
|
Since: 0.1.0