#include "bus-objects.h"
#include "bus-util.h"
#include "bus-container.h"
+#include "bus-protocol.h"
static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec);
_public_ int sd_bus_negotiate_attach_creds(sd_bus *bus, uint64_t mask) {
assert_return(bus, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_MAX, -EINVAL);
+ assert_return(mask <= _SD_BUS_CREDS_ALL, -EINVAL);
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
if (e)
r = sd_bus_set_address(b, e);
else
+#ifdef ENABLE_KDBUS
r = sd_bus_set_address(b, "kernel:path=/dev/kdbus/0-system/bus;unix:path=/run/dbus/system_bus_socket");
+#else
+ r = sd_bus_set_address(b, "unix:path=/run/dbus/system_bus_socket");
+#endif
if (r < 0)
goto fail;
ee = bus_address_escape(e);
if (!ee) {
- r = -ENOENT;
+ r = -ENOMEM;
goto fail;
}
+#ifdef ENABLE_KDBUS
asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus;unix:path=%s/bus", (unsigned long) getuid(), ee);
- } else
+#else
+ b->address = strjoin("unix:path=", ee, "/bus", NULL);
+#endif
+ } else {
+#ifdef ENABLE_KDBUS
asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus", (unsigned long) getuid());
+#else
+ return -ECONNREFUSED;
+#endif
+ }
if (!b->address) {
r = -ENOMEM;
}
static int bus_write_message(sd_bus *bus, sd_bus_message *message, size_t *idx) {
- int r;
-
assert(bus);
assert(message);
return bus_kernel_write_message(bus, message);
else
return bus_socket_write_message(bus, message, idx);
-
- return r;
}
static int dispatch_wqueue(sd_bus *bus) {
/* If the serial number isn't kept, then we know that no reply
* is expected */
if (!serial && !m->sealed)
- m->header->flags |= SD_BUS_MESSAGE_NO_REPLY_EXPECTED;
+ m->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED;
r = bus_seal_message(bus, m);
if (r < 0)
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(m, -EINVAL);
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
- assert_return(!(m->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL);
+ assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL);
assert_return(callback, -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(m, -EINVAL);
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
- assert_return(!(m->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL);
+ assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL);
assert_return(!bus_error_is_dirty(error), -EINVAL);
assert_return(!bus_pid_changed(bus), -ECHILD);
if (!streq_ptr(m->interface, "org.freedesktop.DBus.Peer"))
return 0;
- if (m->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED)
+ if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
return 1;
if (streq_ptr(m->member, "Ping"))
int r;
assert_return(bus, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_MAX, -ENOTSUP);
+ assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP);
assert_return(ret, -EINVAL);
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);