chiark / gitweb /
bus: make system bus kdbus node world-accessible
authorLennart Poettering <lennart@poettering.net>
Thu, 26 Dec 2013 02:08:15 +0000 (03:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 Dec 2013 02:08:15 +0000 (03:08 +0100)
src/core/manager.c
src/libsystemd-bus/bus-kernel.c
src/libsystemd-bus/bus-kernel.h
src/libsystemd-bus/test-bus-kernel-benchmark.c
src/libsystemd-bus/test-bus-kernel-bloom.c
src/libsystemd-bus/test-bus-kernel.c
src/libsystemd-bus/test-bus-zero-copy.c

index c26dcaa..6b33c18 100644 (file)
@@ -542,7 +542,7 @@ static int manager_setup_kdbus(Manager *m) {
         if (m->running_as == SYSTEMD_USER && getenv("DBUS_SESSION_BUS_ADDRESS"))
                 return 0;
 
-        m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", &p);
+        m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p);
         if (m->kdbus_fd < 0) {
                 log_debug("Failed to set up kdbus: %s", strerror(-m->kdbus_fd));
                 return m->kdbus_fd;
index fadb683..d752d1f 100644 (file)
@@ -1131,7 +1131,7 @@ int kdbus_translate_attach_flags(uint64_t mask, uint64_t *kdbus_mask) {
         return 0;
 }
 
-int bus_kernel_create_bus(const char *name, char **s) {
+int bus_kernel_create_bus(const char *name, bool world, char **s) {
         struct kdbus_cmd_make *make;
         struct kdbus_item *n;
         int fd;
@@ -1163,7 +1163,7 @@ int bus_kernel_create_bus(const char *name, char **s) {
         n->type = KDBUS_ITEM_MAKE_NAME;
         make->size += ALIGN8(n->size);
 
-        make->flags = KDBUS_MAKE_POLICY_OPEN;
+        make->flags = KDBUS_MAKE_POLICY_OPEN | (world ? KDBUS_MAKE_ACCESS_WORLD : 0);
 
         if (ioctl(fd, KDBUS_CMD_BUS_MAKE, make) < 0) {
                 close_nointr_nofail(fd);
index 67690f8..2aba0bb 100644 (file)
@@ -21,6 +21,8 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <stdbool.h>
+
 #include "sd-bus.h"
 
 #define KDBUS_ITEM_NEXT(item) \
@@ -61,7 +63,7 @@ int bus_kernel_take_fd(sd_bus *b);
 int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m);
 int bus_kernel_read_message(sd_bus *bus);
 
-int bus_kernel_create_bus(const char *name, char **s);
+int bus_kernel_create_bus(const char *name, bool world, char **s);
 int bus_kernel_create_namespace(const char *name, char **s);
 int bus_kernel_create_starter(const char *bus, const char *name);
 int bus_kernel_create_monitor(const char *bus);
index 010a161..70f4fcd 100644 (file)
@@ -239,7 +239,7 @@ int main(int argc, char *argv[]) {
 
         assert_se(arg_loop_usec > 0);
 
-        bus_ref = bus_kernel_create_bus("deine-mutter", &bus_name);
+        bus_ref = bus_kernel_create_bus("deine-mutter", false, &bus_name);
         if (bus_ref == -ENOENT)
                 exit(EXIT_TEST_SKIP);
 
index 62983ea..772831b 100644 (file)
@@ -42,7 +42,7 @@ static void test_one(
         sd_bus *a, *b;
         int r;
 
-        bus_ref = bus_kernel_create_bus("deine-mutter", &bus_name);
+        bus_ref = bus_kernel_create_bus("deine-mutter", false, &bus_name);
         if (bus_ref == -ENOENT)
                 exit(EXIT_TEST_SKIP);
 
index 8380b2c..c78c6d4 100644 (file)
@@ -42,7 +42,7 @@ int main(int argc, char *argv[]) {
 
         log_set_max_level(LOG_DEBUG);
 
-        bus_ref = bus_kernel_create_bus("deine-mutter", &bus_name);
+        bus_ref = bus_kernel_create_bus("deine-mutter", false, &bus_name);
         if (bus_ref == -ENOENT)
                 return EXIT_TEST_SKIP;
 
index 054c4c7..dff3692 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, char *argv[]) {
 
         log_set_max_level(LOG_DEBUG);
 
-        bus_ref = bus_kernel_create_bus("deine-mutter", &bus_name);
+        bus_ref = bus_kernel_create_bus("deine-mutter", false, &bus_name);
         if (bus_ref == -ENOENT)
                 return EXIT_TEST_SKIP;