[systemd-devel] First steps with sd-bus

Daniel Mack daniel at zonque.org
Mon Oct 5 04:06:05 PDT 2015


On 10/05/2015 12:59 PM, Iñigo Martínez wrote:
> In a home made daemon, I needed to change some variables while
> running, so I though about D-Bus as IPC and gived a chance to sd-bus.
> 
> Let's say that I'm trying it on a development system (currently a
> debian jessie) without any users on it, just root, and some basic
> libraries and configuration.
> 
> After reading Lennarts article[0] I tried to compile the bus-service.c
> example. Here came the first problem:
> 
>    Failed to connect to system bus: No such file or directory
> 
> Obviously, as the system isn't executing a user bus, the service can't
> find it, so I fixed it by changing:
> 
>   r = sd_bus_open_user(&bus);
> 
> to:
> 
>   r = sd_bus_open_system(&bus);

Which is probably what you want to do anyway in case your daemon is
supposed to be accessible system-wide.

> This way it uses a new connection to the system bus instead of the
> nonexistent user bus, but it doesn't work either with a new problem
> when requesting the name:
> 
>   Failed to acquire service name: Permission denied

Owning a name is something the D-Bus daemon has to explicitly allow your
code to do, through an XML policy file. See /etc/dbus-1/system.d/* for
examples, and the dbus-daemon(1) man page for details.


HTH,
Daniel


More information about the systemd-devel mailing list