[systemd-devel] First steps with sd-bus

Iñigo Martínez inigomartinez at gmail.com
Mon Oct 5 05:24:56 PDT 2015


I was missing the XML policy file. After creating one, it worked
flawlessly. Thank you very much Daniel,

One more question, I have been looking at systemd public man pages[0]
as the sd-bus API reference, but I can't find documentation about some
functions. For example information regarding vtable handling
(sd_bus_add_object_vtable for and it's sd_bus_table fields...)

In this case, I have found some information after looking to
examples[1] and to the source code[2], but I'm missing some bits
(flags meanings).

Is there any more information anywhere ?

Thanks again,

Best regards,

[0] http://www.freedesktop.org/software/systemd/man/
[1] https://github.com/systemd/systemd/blob/master/src/libsystemd/sd-bus/test-bus-objects.c
[2] https://github.com/systemdaemon/systemd/blob/master/src/systemd/sd-bus-vtable.h

2015-10-05 13:06 GMT+02:00 Daniel Mack <daniel at zonque.org>:
> 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