[systemd-commits] 4 commits - TODO src/libsystemd

Lennart Poettering lennart at kemper.freedesktop.org
Tue Nov 25 18:09:38 PST 2014


 TODO                               |    4 +-
 src/libsystemd/sd-bus/bus-kernel.c |   51 ++++++++++++++++++++++++++-----------
 2 files changed, 39 insertions(+), 16 deletions(-)

New commits:
commit 6c78f43c7b0e54e695af49917fda79b584f46830
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Nov 26 02:55:42 2014 +0100

    update TODO

diff --git a/TODO b/TODO
index ab77ebe..5b54d25 100644
--- a/TODO
+++ b/TODO
@@ -35,6 +35,8 @@ External:
 
 Features:
 
+* sd-resolve: drop res_query wrapping, people should call via the bus to resolved instead
+
 * kdbus: peeking is subject to a race when we look at a message while the message is being migrated to the implementor's connection. Needs kernel fix, and then we need to invoke the FREE ioctl in busname_peek_message()
 
 * kdbus: for some reason "busctl monitor" only shows metadata for signal msgs, never method call or method reply msgs
@@ -62,8 +64,6 @@ Features:
 
 * maybe add support for specifier expansion in user.conf, specifically DefaultEnvironment=
 
-* kdbus: set the bus-wide creds sender requirement mask to ANY
-
 * kdbus: busnames.target should get pulled in by basic.target
 
 * code cleanup: retire FOREACH_WORD_QUOTED, port to unquote_first_word() loops instead

commit 38813cc8245e35fc89d3671e4cee031d4b2bf430
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Nov 26 02:54:41 2014 +0100

    bus-kernel: when installing an activator, ask for any kind of metadata to be attached to incoming messages
    
    We don't know what the activated service might want in the end, hence
    enable everything current and future, just to be sure.

diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 6baa84c..2bfce93 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1689,7 +1689,7 @@ int bus_kernel_make_starter(
                 (accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
         hello->pool_size = KDBUS_POOL_SIZE;
         hello->attach_flags_send = _KDBUS_ATTACH_ANY;
-        hello->attach_flags_recv = _KDBUS_ATTACH_ALL;
+        hello->attach_flags_recv = _KDBUS_ATTACH_ANY;
 
         if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0)
                 return -errno;

commit 8aee3fc7eae2e60592bac838bc7268720e1d489c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Nov 26 02:54:11 2014 +0100

    sd-bus: don't clobber return values on failure in bus_kernel_open_bus_fd()

diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index aa4b424..6baa84c 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1514,20 +1514,29 @@ int bus_kernel_open_bus_fd(const char *bus, char **path) {
         int fd;
         size_t len;
 
+        assert(bus);
+
         len = strlen("/sys/fs/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(bus) + strlen("/bus") + 1;
 
         if (path) {
-                p = malloc(len);
+                p = new(char, len);
                 if (!p)
                         return -ENOMEM;
-                *path = p;
         } else
-                p = alloca(len);
+                p = newa(char, len);
+
         sprintf(p, "/sys/fs/kdbus/" UID_FMT "-%s/bus", getuid(), bus);
 
         fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
-        if (fd < 0)
+        if (fd < 0) {
+                if (path)
+                        free(p);
+
                 return -errno;
+        }
+
+        if (path)
+                *path = p;
 
         return fd;
 }

commit fa7796e97b96160a4d78f72d113573770cec18f2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Nov 26 02:50:49 2014 +0100

    sd-bus: set per-bus attach flag requirement mask to ANY
    
    On the system and user busses we create it's the receiver that chooses
    which metadata is attched, not the sender, hence set the requirement
    mask to ANY, to allow any current of future credential bit to be
    attached.

diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index d0cb7ee..aa4b424 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1377,6 +1377,7 @@ uint64_t attach_flags_to_kdbus(uint64_t mask) {
 int bus_kernel_create_bus(const char *name, bool world, char **s) {
         struct kdbus_cmd_make *make;
         struct kdbus_item *n;
+        size_t l;
         int fd;
 
         assert(name);
@@ -1386,19 +1387,20 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
         if (fd < 0)
                 return -errno;
 
-        make = alloca0_align(ALIGN8(offsetof(struct kdbus_cmd_make, items) +
-                                    offsetof(struct kdbus_item, data64) + sizeof(uint64_t) +
-                                    offsetof(struct kdbus_item, str) +
-                                    DECIMAL_STR_MAX(uid_t) + 1 + strlen(name) + 1),
+        l = strlen(name);
+        make = alloca0_align(offsetof(struct kdbus_cmd_make, items) +
+                             ALIGN8(offsetof(struct kdbus_item, bloom_parameter) + sizeof(struct kdbus_bloom_parameter)) +
+                             ALIGN8(offsetof(struct kdbus_item, data64) + sizeof(uint64_t)) +
+                             ALIGN8(offsetof(struct kdbus_item, str) + DECIMAL_STR_MAX(uid_t) + 1 + l + 1),
                              8);
 
         make->size = offsetof(struct kdbus_cmd_make, items);
 
+        /* Set the bloom parameters */
         n = make->items;
         n->size = offsetof(struct kdbus_item, bloom_parameter) +
                   sizeof(struct kdbus_bloom_parameter);
         n->type = KDBUS_ITEM_BLOOM_PARAMETER;
-
         n->bloom_parameter.size = DEFAULT_BLOOM_SIZE;
         n->bloom_parameter.n_hash = DEFAULT_BLOOM_N_HASH;
 
@@ -1407,6 +1409,15 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
 
         make->size += ALIGN8(n->size);
 
+        /* The busses we create make no restrictions on what metadata
+         * peers can read from incoming messages. */
+        n = KDBUS_ITEM_NEXT(n);
+        n->type = KDBUS_ITEM_ATTACH_FLAGS_RECV;
+        n->size = offsetof(struct kdbus_item, data64) + sizeof(uint64_t);
+        n->data64[0] = _KDBUS_ATTACH_ANY;
+        make->size += ALIGN8(n->size);
+
+        /* Set the a good name */
         n = KDBUS_ITEM_NEXT(n);
         sprintf(n->str, UID_FMT "-%s", getuid(), name);
         n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
@@ -1633,7 +1644,7 @@ int bus_kernel_make_starter(
         if (world_policy >= 0)
                 policy_cnt++;
 
-        size = ALIGN8(offsetof(struct kdbus_cmd_hello, items)) +
+        size = offsetof(struct kdbus_cmd_hello, items) +
                ALIGN8(offsetof(struct kdbus_item, str) + strlen(name) + 1) +
                policy_cnt * ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
 
@@ -1715,15 +1726,18 @@ int bus_kernel_realize_attach_flags(sd_bus *bus) {
         assert(bus);
         assert(bus->is_kernel);
 
-        update = alloca0_align(ALIGN8(offsetof(struct kdbus_cmd_update, items) +
-                                      offsetof(struct kdbus_item, data64) + sizeof(uint64_t)), 8);
+        update = alloca0_align(offsetof(struct kdbus_cmd_update, items) +
+                               ALIGN8(offsetof(struct kdbus_item, data64) + sizeof(uint64_t)),
+                               8);
 
         n = update->items;
         n->type = KDBUS_ITEM_ATTACH_FLAGS_RECV;
         n->size = offsetof(struct kdbus_item, data64) + sizeof(uint64_t);
         n->data64[0] = bus->attach_flags;
 
-        update->size = offsetof(struct kdbus_cmd_update, items) + n->size;
+        update->size =
+                offsetof(struct kdbus_cmd_update, items) +
+                ALIGN8(n->size);
 
         if (ioctl(bus->input_fd, KDBUS_CMD_CONN_UPDATE, update) < 0)
                 return -errno;



More information about the systemd-commits mailing list