bus APIs in systemd 221. When I request a name for an object in system bus it prints out an error saying "Permission denied". I am running the output file as root. The line "sd_bus_request_name(bus, "net.poettering.Calculator", 0)" throws an error : "Failed to acquire servie name..: Permission denied"
I think root should have a permission to acquire a name for an object. Does any one know how to solve this?
thank you in advance.
Here is the example code from http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html :
int main(int argc, char *argv[]) {
sd_bus_slot *slot = NULL;
sd_bus *bus = NULL;
int r;
r = sd_bus_default_system(&bus);
if (r < 0) {
fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
goto finish;
}
/* Install the object */
r = sd_bus_add_object_vtable(bus,
&slot,
"/net/poettering/Calculator",
"net.poettering.Calculator", /* interface name */calculator_vtable,
NULL);
if (r < 0) {
fprintf(stderr, "Failed to issue method call: %s\n", strerror(-r));
goto finish;
}
/* Take a well-known service name so that clients can find us */
r = sd_bus_request_name(bus, "net.poettering.Calculator", 0);
if (r < 0) {
fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r));
goto finish;
}