SD_BUS_SET_SENDER(3)

πŸ’… SD_BUS_SET_SENDER(3) β€” like, the sd_bus_set_sender manual, bestie

okay so this whole page lives in section 3 of the manual, and the star of the show is sd_bus_set_sender (with sd_bus_get_sender riding shotgun). Let's get into it ✨


🌸 NAME 🌸

sd_bus_set_sender, sd_bus_get_sender β€” configure the default sender for outgoing messages 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <systemd/sd-bus.h>

int sd_bus_set_sender(sd_bus *bus, const char* name);

int sd_bus_get_sender(sd_bus *bus, const char** name);

✨ DESCRIPTION ✨

So sd_bus_set_sender() is the one that sets up your default sender service name for outgoing messages. Like, it configures the vibe of who's sending. πŸ’Œ

The service name you pass in the name parameter gets stamped onto all outgoing messages that get sent on the connection and that don't already have a sender set β€” for example, ones that were set through sd_bus_message_set_sender(3).

⚠️ Heads up, bestie: this function is only supported on direct connections, i.e. not on connections to a bus broker. Because the broker is gonna fill in the sender service name automatically anyway, so like… it's already handled. πŸ’…

By default, no sender name is configured, and hence messages are sent without the sender field set. That's the default state, no cap.

If name is passed as NULL, the default sender service name gets cleared, returning to the default state (if a default sender service name was set before). If you pass it as non-NULL, the name you give has to be a valid unique or well-known service name. No fake ones. 🚫

And sd_bus_get_sender()? That's your girl for querying the current default service name for outgoing messages. Peek at the current setting, iconic. πŸ‘‘


πŸ”₯ RETURN VALUE πŸ”₯

On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style error code. That's it, that's the deal. 😌

πŸ’€ Errors πŸ’€

Returned errors may indicate the following problems:

  • -ECHILD β€” the bus connection has been created in a different process, library or module instance. so like, not your connection to touch, respectfully πŸ™ˆ
  • -EPERM β€” the specified bus connection object is not a direct connection but a brokered connection. wrong kind of connection, bestie. 😭

🌈 NOTES 🌈

The 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. Basically: share nicely, don't all grab the same object at once. βœ‹

⚠️ 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. like, do the env stuff before the party starts, fr fr 🧚

πŸ‘‘ HISTORY πŸ‘‘

sd_bus_set_sender() and sd_bus_get_sender() were added in version 237. vintage but still slaying πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹

systemd(1), sd-bus(3), sd_bus_message_set_sender(3)


that's the whole page, periodt πŸ“ and just so you know, this came from the systemd 261.3 source β€” mwah, go read sd-bus(3) next, iykyk πŸ’–

πŸ“¦ where this page comes from