SD_BUS_NEGOTIATE_FDS(3)

🌸 NAME 🌸

okay so this is the SD_BUS_NEGOTIATE_FDS(3) manual page, and it's literally all about controlling feature negotiation on bus connections, bestie. The main characters are sd_bus_negotiate_fds, sd_bus_negotiate_timestamp, sd_bus_negotiate_creds, and sd_bus_get_creds_mask β€” they handle whether extra message metadata gets negotiated on a bus connection. πŸ’…


✨ SYNOPSIS ✨

#include <systemd/sd-bus.h>

int sd_bus_negotiate_fds(sd_bus *bus, int b);

int sd_bus_negotiate_timestamp(sd_bus *bus, int b);

int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask);

int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask);

πŸ¦‹ DESCRIPTION πŸ¦‹

So sd_bus_negotiate_fds() is the one that controls whether file descriptor passing gets negotiated for the specified bus connection. You hand it a bus object and a boolean: when true it enables file descriptor passing, when false it disables it. Big caveat, bestie: not all transports and servers support file descriptor passing. Networked transports generally do not support it β€” no cap. To find out whether file descriptor passing is actually available after negotiation, use sd_bus_can_send(3) and pass SD_BUS_TYPE_UNIX_FD. Also important: file descriptor passing is always enabled for both sending and receiving, or for neither β€” it's never only one direction. By default, file descriptor passing is negotiated for all connections. πŸ’–

sd_bus_negotiate_timestamp() controls whether implicit sender timestamps get attached automatically to all incoming messages. It takes a bus object and a boolean: true enables timestamping, false disables it. To query timestamps on incoming messages, use sd_bus_message_get_monotonic_usec(3), sd_bus_message_get_realtime_usec(3), and sd_bus_message_get_seqnum(3). If negotiation is disabled or not supported, those calls will fail with -ENODATA. And heads up: currently no transports support timestamping of messages. By default, message timestamping is not negotiated for connections. 😭

sd_bus_negotiate_creds() controls whether β€” and which β€” implicit sender credentials get attached automatically to all incoming messages. It takes a bus object and a boolean indicating whether to enable or disable the credential parts encoded in the bit mask value argument. Note that not all transports support attaching sender credentials to messages, or don't support all types of sender credential parameters, or might suppress them under certain circumstances for individual messages. Specifically, dbus1 only supports SD_BUS_CREDS_UNIQUE_NAME. Sender credentials are suitable for authorization decisions. By default, only SD_BUS_CREDS_WELL_KNOWN_NAMES and SD_BUS_CREDS_UNIQUE_NAME are enabled. In fact, those two credential fields are always sent along and cannot be turned off. periodt. πŸ‘‘

sd_bus_get_creds_mask() returns the set of sender credentials that was negotiated to be attached to all incoming messages in mask. This value is an upper boundary only β€” so always make sure to explicitly check which credentials are attached to a specific message before using it. Don't skip that check, bestie. πŸ™ˆ

The sd_bus_negotiate_fds() function may be called only before the connection has been started with sd_bus_start(3). Both sd_bus_negotiate_timestamp() and sd_bus_negotiate_creds() may also be called after a connection has been set up. One more thing: when you're operating on a connection that is shared between multiple components of the same program β€” for example via sd_bus_default(3) β€” it is highly recommended to only enable additional per message metadata fields, but never disable them again, in order not to disable functionality needed by other components. Shared connection etiquette, iykyk. πŸ’€


πŸ”₯ RETURN VALUE πŸ”₯

On success, these functions return a non-negative integer. On failure, they return a negative errno-style error code. That's the whole vibe check. 🌈

😭 Errors 😭

Returned errors may indicate the following problems:

  • -EPERM β€” The bus connection has already been started.
  • -EINVAL β€” An argument is invalid.

Added in version 246.

  • -ENOPKG β€” The bus cannot be resolved.

Added in version 246.

  • -ECHILD β€” The bus was created in a different process, library or module instance.

Added in version 246.


πŸŽ€ NOTES πŸŽ€

Functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file. 🫢

All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel. So like, don't gang up on one object at the same time, bestie. ✨

The code described here uses getenv(3), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call setenv(3) from a parallel thread. It is recommended to only do calls to setenv() from an early phase of the program when no other threads have been started. Early-phase setenv() only β€” that's the rule. 🌸


⭐ HISTORY ⭐

sd_bus_negotiate_fds(), sd_bus_negotiate_timestamp(), and sd_bus_negotiate_creds() were added in version 212.

sd_bus_get_creds_mask() was added in version 246.


πŸ’œ SEE ALSO πŸ’œ


okay bestie, cute little sign-off time πŸŽ€ source/version: systemd 261.3; footer page name: SD_BUS_NEGOTIATE_FDS(3); date: not shown in this footer, so no fake date energy from me β€” literally just the version tag and the page name, and that's the tea πŸ’–βœ¨

πŸ“¦ where this page comes from