[systemd-commits] 10 commits - TODO src/bus-proxyd src/journal src/libsystemd src/systemd

Lennart Poettering lennart at kemper.freedesktop.org
Fri Nov 28 11:29:54 PST 2014


 TODO                                          |    7 -
 src/bus-proxyd/bus-proxyd.c                   |    4 
 src/journal/coredump.c                        |  131 +++++++++++++-------------
 src/libsystemd/libsystemd.sym.m4              |    2 
 src/libsystemd/sd-bus/bus-kernel.c            |   77 ++++++++++-----
 src/libsystemd/sd-bus/bus-match.c             |   67 ++++++++++---
 src/libsystemd/sd-bus/bus-message.c           |   77 +++++++++++----
 src/libsystemd/sd-bus/bus-message.h           |    2 
 src/libsystemd/sd-bus/busctl.c                |   13 ++
 src/libsystemd/sd-bus/sd-bus.c                |   68 ++++++++++++-
 src/libsystemd/sd-bus/test-bus-chat.c         |    2 
 src/libsystemd/sd-bus/test-bus-kernel-bloom.c |   51 +++++-----
 src/libsystemd/sd-bus/test-bus-match.c        |   19 ++-
 src/systemd/sd-bus.h                          |   22 +++-
 14 files changed, 375 insertions(+), 167 deletions(-)

New commits:
commit 8c8549db376ce9325e5a7547959ab7d9218505b7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 20:29:24 2014 +0100

    coredump: simplify a few things by allocating small fields on the stack rather than heap

diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 5040206..d889ed1 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -530,13 +530,20 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
 
 int main(int argc, char* argv[]) {
 
-        _cleanup_free_ char *core_pid = NULL, *core_uid = NULL, *core_gid = NULL, *core_signal = NULL,
-                *core_timestamp = NULL, *core_comm = NULL, *core_exe = NULL, *core_unit = NULL,
-                *core_session = NULL, *core_message = NULL, *core_cmdline = NULL, *coredump_data = NULL,
-                *core_slice = NULL, *core_cgroup = NULL, *core_owner_uid = NULL, *core_open_fds = NULL,
-                *core_proc_status = NULL, *core_proc_maps = NULL, *core_proc_limits = NULL, *core_proc_cgroup = NULL,
-                *core_cwd = NULL, *core_root = NULL, *core_environ = NULL,
-                *exe = NULL, *comm = NULL, *filename = NULL;
+        /* The small core field we allocate on the stack, to keep things simple */
+        char
+                *core_pid = NULL, *core_uid = NULL, *core_gid = NULL, *core_signal = NULL,
+                *core_session = NULL, *core_exe = NULL, *core_comm = NULL, *core_cmdline = NULL,
+                *core_cgroup = NULL, *core_cwd = NULL, *core_root = NULL, *core_unit = NULL,
+                *core_slice = NULL;
+
+        /* The larger ones we allocate on the heap */
+        _cleanup_free_ char
+                *core_timestamp = NULL,  *core_message = NULL, *coredump_data = NULL, *core_owner_uid = NULL,
+                *core_open_fds = NULL, *core_proc_status = NULL, *core_proc_maps = NULL, *core_proc_limits = NULL,
+                *core_proc_cgroup = NULL, *core_environ = NULL;
+
+        _cleanup_free_ char *exe = NULL, *comm = NULL, *filename = NULL;
         const char *info[_INFO_LEN];
 
         _cleanup_close_ int coredump_fd = -1;
@@ -609,6 +616,7 @@ int main(int argc, char* argv[]) {
         if (cg_pid_get_unit(pid, &t) >= 0) {
 
                 if (streq(t, SPECIAL_JOURNALD_SERVICE)) {
+                        free(t);
 
                         /* If we are journald, we cut things short,
                          * don't write to the journal, but still
@@ -629,9 +637,13 @@ int main(int argc, char* argv[]) {
                         goto finish;
                 }
 
-                core_unit = strappend("COREDUMP_UNIT=", t);
-        } else if (cg_pid_get_user_unit(pid, &t) >= 0)
-                core_unit = strappend("COREDUMP_USER_UNIT=", t);
+                core_unit = strappenda("COREDUMP_UNIT=", t);
+                free(t);
+
+        } else if (cg_pid_get_user_unit(pid, &t) >= 0) {
+                core_unit = strappenda("COREDUMP_USER_UNIT=", t);
+                free(t);
+        }
 
         if (core_unit)
                 IOVEC_SET_STRING(iovec[j++], core_unit);
@@ -641,28 +653,23 @@ int main(int argc, char* argv[]) {
         log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
         log_open();
 
-        core_pid = strappend("COREDUMP_PID=", info[INFO_PID]);
-        if (core_pid)
-                IOVEC_SET_STRING(iovec[j++], core_pid);
+        core_pid = strappenda("COREDUMP_PID=", info[INFO_PID]);
+        IOVEC_SET_STRING(iovec[j++], core_pid);
 
-        core_uid = strappend("COREDUMP_UID=", info[INFO_UID]);
-        if (core_uid)
-                IOVEC_SET_STRING(iovec[j++], core_uid);
+        core_uid = strappenda("COREDUMP_UID=", info[INFO_UID]);
+        IOVEC_SET_STRING(iovec[j++], core_uid);
 
-        core_gid = strappend("COREDUMP_GID=", info[INFO_GID]);
-        if (core_gid)
-                IOVEC_SET_STRING(iovec[j++], core_gid);
+        core_gid = strappenda("COREDUMP_GID=", info[INFO_GID]);
+        IOVEC_SET_STRING(iovec[j++], core_gid);
 
-        core_signal = strappend("COREDUMP_SIGNAL=", info[INFO_SIGNAL]);
-        if (core_signal)
-                IOVEC_SET_STRING(iovec[j++], core_signal);
+        core_signal = strappenda("COREDUMP_SIGNAL=", info[INFO_SIGNAL]);
+        IOVEC_SET_STRING(iovec[j++], core_signal);
 
         if (sd_pid_get_session(pid, &t) >= 0) {
-                core_session = strappend("COREDUMP_SESSION=", t);
+                core_session = strappenda("COREDUMP_SESSION=", t);
                 free(t);
 
-                if (core_session)
-                        IOVEC_SET_STRING(iovec[j++], core_session);
+                IOVEC_SET_STRING(iovec[j++], core_session);
         }
 
         if (sd_pid_get_owner_uid(pid, &owner_uid) >= 0) {
@@ -673,39 +680,34 @@ int main(int argc, char* argv[]) {
         }
 
         if (sd_pid_get_slice(pid, &t) >= 0) {
-                core_slice = strappend("COREDUMP_SLICE=", t);
+                core_slice = strappenda("COREDUMP_SLICE=", t);
                 free(t);
 
-                if (core_slice)
-                        IOVEC_SET_STRING(iovec[j++], core_slice);
+                IOVEC_SET_STRING(iovec[j++], core_slice);
         }
 
         if (comm) {
-                core_comm = strappend("COREDUMP_COMM=", comm);
-                if (core_comm)
-                        IOVEC_SET_STRING(iovec[j++], core_comm);
+                core_comm = strappenda("COREDUMP_COMM=", comm);
+                IOVEC_SET_STRING(iovec[j++], core_comm);
         }
 
         if (exe) {
-                core_exe = strappend("COREDUMP_EXE=", exe);
-                if (core_exe)
-                        IOVEC_SET_STRING(iovec[j++], core_exe);
+                core_exe = strappenda("COREDUMP_EXE=", exe);
+                IOVEC_SET_STRING(iovec[j++], core_exe);
         }
 
         if (get_process_cmdline(pid, 0, false, &t) >= 0) {
-                core_cmdline = strappend("COREDUMP_CMDLINE=", t);
+                core_cmdline = strappenda("COREDUMP_CMDLINE=", t);
                 free(t);
 
-                if (core_cmdline)
-                        IOVEC_SET_STRING(iovec[j++], core_cmdline);
+                IOVEC_SET_STRING(iovec[j++], core_cmdline);
         }
 
         if (cg_pid_get_path_shifted(pid, NULL, &t) >= 0) {
-                core_cgroup = strappend("COREDUMP_CGROUP=", t);
+                core_cgroup = strappenda("COREDUMP_CGROUP=", t);
                 free(t);
 
-                if (core_cgroup)
-                        IOVEC_SET_STRING(iovec[j++], core_cgroup);
+                IOVEC_SET_STRING(iovec[j++], core_cgroup);
         }
 
         if (compose_open_fds(pid, &t) >= 0) {
@@ -753,19 +755,17 @@ int main(int argc, char* argv[]) {
         }
 
         if (get_process_cwd(pid, &t) >= 0) {
-                core_cwd = strappend("COREDUMP_CWD=", t);
+                core_cwd = strappenda("COREDUMP_CWD=", t);
                 free(t);
 
-                if (core_cwd)
-                        IOVEC_SET_STRING(iovec[j++], core_cwd);
+                IOVEC_SET_STRING(iovec[j++], core_cwd);
         }
 
         if (get_process_root(pid, &t) >= 0) {
-                core_root = strappend("COREDUMP_ROOT=", t);
+                core_root = strappenda("COREDUMP_ROOT=", t);
                 free(t);
 
-                if (core_root)
-                        IOVEC_SET_STRING(iovec[j++], core_root);
+                IOVEC_SET_STRING(iovec[j++], core_root);
         }
 
         if (get_process_environ(pid, &t) >= 0) {

commit 4d84bc2f5fd9134f13614add5e6b05732aba44ca
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 20:15:18 2014 +0100

    coredump: rework compose_open_fds()
    
    Use FOREACH_DIRENT() and FOREACH_LINE() macros instead of manual loops.
    
    Don't clobber return parameters on failure.
    
    Simplify some other things.

diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 26953cc..5040206 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -459,12 +459,13 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
  * EOF
  */
 static int compose_open_fds(pid_t pid, char **open_fds) {
+        _cleanup_closedir_ DIR *proc_fd_dir = NULL;
+        _cleanup_close_ int proc_fdinfo_fd = -1;
+        _cleanup_free_ char *buffer = NULL;
         _cleanup_fclose_ FILE *stream = NULL;
-        size_t ignored_size;
         const char *fddelim = "", *path;
         struct dirent *dent = NULL;
-        _cleanup_closedir_ DIR *proc_fd_dir = NULL;
-        _cleanup_close_ int proc_fdinfo_fd = -1;
+        size_t size = 0;
         int r = 0;
 
         assert(pid >= 0);
@@ -475,23 +476,19 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
         if (!proc_fd_dir)
                 return -errno;
 
-        proc_fdinfo_fd = openat(dirfd(proc_fd_dir), "../fdinfo",
-                                O_DIRECTORY|O_NOFOLLOW|O_CLOEXEC|O_PATH);
+        proc_fdinfo_fd = openat(dirfd(proc_fd_dir), "../fdinfo", O_DIRECTORY|O_NOFOLLOW|O_CLOEXEC|O_PATH);
         if (proc_fdinfo_fd < 0)
                 return -errno;
 
-        stream = open_memstream(open_fds, &ignored_size);
+        stream = open_memstream(&buffer, &size);
         if (!stream)
                 return -ENOMEM;
 
-        for (dent = readdir(proc_fd_dir); dent != NULL; dent = readdir(proc_fd_dir)) {
-                _cleanup_free_ char *fdname = NULL;
-                int fd;
+        FOREACH_DIRENT(dent, proc_fd_dir, return -errno) {
                 _cleanup_fclose_ FILE *fdinfo = NULL;
+                _cleanup_free_ char *fdname = NULL;
                 char line[LINE_MAX];
-
-                if (dent->d_name[0] == '.' || strcmp(dent->d_name, "..") == 0)
-                        continue;
+                int fd;
 
                 r = readlinkat_malloc(dirfd(proc_fd_dir), dent->d_name, &fdname);
                 if (r < 0)
@@ -511,11 +508,23 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
                         continue;
                 }
 
-                while(fgets(line, sizeof(line), fdinfo) != NULL)
-                        fprintf(stream, "%s%s",
-                                line, strchr(line, '\n') == NULL ? "\n" : "");
+                FOREACH_LINE(line, fdinfo, break) {
+                        fputs(line, stream);
+                        if (!endswith(line, "\n"))
+                                fputc('\n', stream);
+                }
         }
 
+        errno = 0;
+        fclose(stream);
+        stream = NULL;
+
+        if (errno != 0)
+                return -errno;
+
+        *open_fds = buffer;
+        buffer = NULL;
+
         return 0;
 }
 

commit cb2264aa0dcd5bb67338d25ee797ebec50ac7530
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 19:17:27 2014 +0100

    update TODO

diff --git a/TODO b/TODO
index 1433a22..2311153 100644
--- a/TODO
+++ b/TODO
@@ -257,9 +257,9 @@ Features:
   ReadOnlyDirectories=... for whitelisting files for a service.
 
 * sd-bus:
+  - xml policy inforcement and bus activated services is broken?
   - rework errno registration logic
   - how can we make the xml enforcement for native clients unnecessary?
-  - add "as" (array of strings) support to bloom filter
   - kdbus: the kernel should not allow messages to be delivered that have a reply serial != 0, reply-expect unset, but no appropriate window
   - kdbus: when we fake creds euid being (uint32_t) -1 is weirdly translated
   - kdbus: timestamps on kernel's NameOwnerChanged messages?

commit 198b158f4941b817f26f8eb0ff75809bf5436496
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 19:16:37 2014 +0100

    sd-bus: add support for matches against arrays of strings in messages

diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
index 0e92a85..3a31aa0 100644
--- a/src/libsystemd/sd-bus/bus-match.c
+++ b/src/libsystemd/sd-bus/bus-match.c
@@ -134,6 +134,7 @@ static bool value_node_test(
                 enum bus_match_node_type parent_type,
                 uint8_t value_u8,
                 const char *value_str,
+                char **value_strv,
                 sd_bus_message *m) {
 
         assert(node);
@@ -179,17 +180,46 @@ static bool value_node_test(
         case BUS_MATCH_INTERFACE:
         case BUS_MATCH_MEMBER:
         case BUS_MATCH_PATH:
-        case BUS_MATCH_ARG ... BUS_MATCH_ARG_LAST:
-                return streq_ptr(node->value.str, value_str);
+        case BUS_MATCH_ARG ... BUS_MATCH_ARG_LAST: {
+                char **i;
 
-        case BUS_MATCH_ARG_NAMESPACE ... BUS_MATCH_ARG_NAMESPACE_LAST:
-                return namespace_simple_pattern(node->value.str, value_str);
+                if (value_str)
+                        return streq_ptr(node->value.str, value_str);
+
+                STRV_FOREACH(i, value_strv)
+                        if (streq_ptr(node->value.str, *i))
+                                return true;
+
+                return false;
+        }
+
+        case BUS_MATCH_ARG_NAMESPACE ... BUS_MATCH_ARG_NAMESPACE_LAST: {
+                char **i;
+
+                if (value_str)
+                        return namespace_simple_pattern(node->value.str, value_str);
+
+                STRV_FOREACH(i, value_strv)
+                        if (namespace_simple_pattern(node->value.str, *i))
+                                return true;
+                return false;
+        }
 
         case BUS_MATCH_PATH_NAMESPACE:
                 return path_simple_pattern(node->value.str, value_str);
 
-        case BUS_MATCH_ARG_PATH ... BUS_MATCH_ARG_PATH_LAST:
-                return path_complex_pattern(node->value.str, value_str);
+        case BUS_MATCH_ARG_PATH ... BUS_MATCH_ARG_PATH_LAST: {
+                char **i;
+
+                if (value_str)
+                        return path_complex_pattern(node->value.str, value_str);
+
+                STRV_FOREACH(i, value_strv)
+                        if (path_complex_pattern(node->value.str, *i))
+                                return true;
+
+                return false;
+        }
 
         default:
                 assert_not_reached("Invalid node type");
@@ -235,7 +265,7 @@ int bus_match_run(
                 struct bus_match_node *node,
                 sd_bus_message *m) {
 
-
+        _cleanup_strv_free_ char **test_strv = NULL;
         const char *test_str = NULL;
         uint8_t test_u8 = 0;
         int r;
@@ -343,15 +373,15 @@ int bus_match_run(
                 break;
 
         case BUS_MATCH_ARG ... BUS_MATCH_ARG_LAST:
-                test_str = bus_message_get_arg(m, node->type - BUS_MATCH_ARG);
+                (void) bus_message_get_arg(m, node->type - BUS_MATCH_ARG, &test_str, &test_strv);
                 break;
 
         case BUS_MATCH_ARG_PATH ... BUS_MATCH_ARG_PATH_LAST:
-                test_str = bus_message_get_arg(m, node->type - BUS_MATCH_ARG_PATH);
+                (void) bus_message_get_arg(m, node->type - BUS_MATCH_ARG_PATH, &test_str, &test_strv);
                 break;
 
         case BUS_MATCH_ARG_NAMESPACE ... BUS_MATCH_ARG_NAMESPACE_LAST:
-                test_str = bus_message_get_arg(m, node->type - BUS_MATCH_ARG_NAMESPACE);
+                (void) bus_message_get_arg(m, node->type - BUS_MATCH_ARG_NAMESPACE, &test_str, &test_strv);
                 break;
 
         default:
@@ -365,7 +395,20 @@ int bus_match_run(
 
                 if (test_str)
                         found = hashmap_get(node->compare.children, test_str);
-                else if (node->type == BUS_MATCH_MESSAGE_TYPE)
+                else if (test_strv) {
+                        char **i;
+
+                        STRV_FOREACH(i, test_strv) {
+                                found = hashmap_get(node->compare.children, *i);
+                                if (found) {
+                                        r = bus_match_run(bus, found, m);
+                                        if (r != 0)
+                                                return r;
+                                }
+                        }
+
+                        found = NULL;
+                } else if (node->type == BUS_MATCH_MESSAGE_TYPE)
                         found = hashmap_get(node->compare.children, UINT_TO_PTR(test_u8));
                 else
                         found = NULL;
@@ -381,7 +424,7 @@ int bus_match_run(
                 /* No hash table, so let's iterate manually... */
 
                 for (c = node->child; c; c = c->next) {
-                        if (!value_node_test(c, node->type, test_u8, test_str, m))
+                        if (!value_node_test(c, node->type, test_u8, test_str, test_strv, m))
                                 continue;
 
                         r = bus_match_run(bus, c, m);
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 9fdf0d7..05015a4 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5333,35 +5333,57 @@ _public_ int sd_bus_message_read_strv(sd_bus_message *m, char ***l) {
         return 1;
 }
 
-const char* bus_message_get_arg(sd_bus_message *m, unsigned i) {
-        int r;
-        const char *t = NULL;
+int bus_message_get_arg(sd_bus_message *m, unsigned i, const char **str, char ***strv) {
+        const char *contents;
         unsigned j;
+        char type;
+        int r;
 
         assert(m);
+        assert(str);
+        assert(strv);
 
         r = sd_bus_message_rewind(m, true);
         if (r < 0)
-                return NULL;
+                return r;
 
-        for (j = 0; j <= i; j++) {
-                char type;
+        for (j = 0;; j++) {
+                r = sd_bus_message_peek_type(m, &type, &contents);
+                if (r < 0)
+                        return r;
+                if (r == 0)
+                        return -ENXIO;
+
+                /* Don't match against arguments after the first one we don't understand */
+                if (!IN_SET(type, SD_BUS_TYPE_STRING, SD_BUS_TYPE_OBJECT_PATH, SD_BUS_TYPE_SIGNATURE) &&
+                    !(type == SD_BUS_TYPE_ARRAY && STR_IN_SET(contents, "s", "o", "g")))
+                        return -ENXIO;
+
+                if (j >= i)
+                        break;
 
-                r = sd_bus_message_peek_type(m, &type, NULL);
+                r = sd_bus_message_skip(m, NULL);
                 if (r < 0)
-                        return NULL;
+                        return r;
+        }
 
-                if (type != SD_BUS_TYPE_STRING &&
-                    type != SD_BUS_TYPE_OBJECT_PATH &&
-                    type != SD_BUS_TYPE_SIGNATURE)
-                        return NULL;
+        if (type == SD_BUS_TYPE_ARRAY) {
 
-                r = sd_bus_message_read_basic(m, type, &t);
+                r = sd_bus_message_read_strv(m, strv);
                 if (r < 0)
-                        return NULL;
+                        return r;
+
+                *str = NULL;
+
+        } else {
+                r = sd_bus_message_read_basic(m, type, str);
+                if (r < 0)
+                        return r;
+
+                *strv = NULL;
         }
 
-        return t;
+        return 0;
 }
 
 bool bus_header_is_complete(struct bus_header *h, size_t size) {
diff --git a/src/libsystemd/sd-bus/bus-message.h b/src/libsystemd/sd-bus/bus-message.h
index 8aa71fa..e54543a 100644
--- a/src/libsystemd/sd-bus/bus-message.h
+++ b/src/libsystemd/sd-bus/bus-message.h
@@ -223,7 +223,7 @@ int bus_message_from_malloc(
                 const char *label,
                 sd_bus_message **ret);
 
-const char* bus_message_get_arg(sd_bus_message *m, unsigned i);
+int bus_message_get_arg(sd_bus_message *m, unsigned i, const char **str, char ***strv);
 
 int bus_message_append_ap(sd_bus_message *m, const char *types, va_list ap);
 
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 6c5d35b..7133117 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -33,8 +33,9 @@
 static bool mask[32];
 
 static int filter(sd_bus *b, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
-        log_info("Ran %i", PTR_TO_INT(userdata));
-        mask[PTR_TO_INT(userdata)] = true;
+        log_info("Ran %u", PTR_TO_UINT(userdata));
+        assert(PTR_TO_UINT(userdata) < ELEMENTSOF(mask));
+        mask[PTR_TO_UINT(userdata)] = true;
         return 0;
 }
 
@@ -85,9 +86,9 @@ int main(int argc, char *argv[]) {
         };
 
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
-        _cleanup_bus_unref_ sd_bus *bus = NULL;
+        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
         enum bus_match_node_type i;
-        sd_bus_slot slots[15];
+        sd_bus_slot slots[19];
         int r;
 
         r = sd_bus_open_system(&bus);
@@ -108,16 +109,20 @@ int main(int argc, char *argv[]) {
         assert_se(match_add(slots, &root, "arg1='two'", 12) >= 0);
         assert_se(match_add(slots, &root, "member='waldo',arg2path='/prefix/'", 13) >= 0);
         assert_se(match_add(slots, &root, "member=waldo,path='/foo/bar',arg3namespace='prefix'", 14) >= 0);
+        assert_se(match_add(slots, &root, "arg4='pi'", 15) >= 0);
+        assert_se(match_add(slots, &root, "arg4='pa'", 16) >= 0);
+        assert_se(match_add(slots, &root, "arg4='po'", 17) >= 0);
+        assert_se(match_add(slots, &root, "arg4='pu'", 18) >= 0);
 
         bus_match_dump(&root, 0);
 
         assert_se(sd_bus_message_new_signal(bus, &m, "/foo/bar", "bar.x", "waldo") >= 0);
-        assert_se(sd_bus_message_append(m, "ssss", "one", "two", "/prefix/three", "prefix.four") >= 0);
+        assert_se(sd_bus_message_append(m, "ssssas", "one", "two", "/prefix/three", "prefix.four", 3, "pi", "pa", "po") >= 0);
         assert_se(bus_message_seal(m, 1, 0) >= 0);
 
         zero(mask);
         assert_se(bus_match_run(NULL, &root, m) == 0);
-        assert_se(mask_contains((unsigned[]) { 9, 8, 7, 5, 10, 12, 13, 14 }, 8));
+        assert_se(mask_contains((unsigned[]) { 9, 8, 7, 5, 10, 12, 13, 14, 15, 16, 17 }, 11));
 
         assert_se(bus_match_remove(&root, &slots[8].match_callback) >= 0);
         assert_se(bus_match_remove(&root, &slots[13].match_callback) >= 0);
@@ -126,7 +131,7 @@ int main(int argc, char *argv[]) {
 
         zero(mask);
         assert_se(bus_match_run(NULL, &root, m) == 0);
-        assert_se(mask_contains((unsigned[]) { 9, 5, 10, 12, 14, 7 }, 6));
+        assert_se(mask_contains((unsigned[]) { 9, 5, 10, 12, 14, 7, 15, 16, 17 }, 9));
 
         for (i = 0; i < _BUS_MATCH_NODE_TYPE_MAX; i++) {
                 char buf[32];

commit d9fba533169b271d0e803016fea86fb57bc3f5ca
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 19:16:25 2014 +0100

    sd-bus: if a NULL signatures is passed to sd_bus_message_skip(), make it skip a single element of any type

diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index a4939b4..9fdf0d7 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -4450,13 +4450,32 @@ _public_ int sd_bus_message_skip(sd_bus_message *m, const char *types) {
 
         assert_return(m, -EINVAL);
         assert_return(m->sealed, -EPERM);
-        assert_return(types, -EINVAL);
 
-        if (isempty(types))
-                return 0;
+        /* If types is NULL, read exactly one element */
+        if (!types) {
+                struct bus_container *c;
+                size_t l;
+
+                if (message_end_of_signature(m))
+                        return -ENXIO;
+
+                if (message_end_of_array(m, m->rindex))
+                        return 0;
+
+                c = message_get_container(m);
+
+                r = signature_element_length(c->signature + c->index, &l);
+                if (r < 0)
+                        return r;
+
+                types = strndupa(c->signature + c->index, l);
+        }
 
         switch (*types) {
 
+        case 0: /* Nothing to drop */
+                return 0;
+
         case SD_BUS_TYPE_BYTE:
         case SD_BUS_TYPE_BOOLEAN:
         case SD_BUS_TYPE_INT16:

commit 1abe54d9a9292d746e5990843bbbc509984b7f2c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 17:44:05 2014 +0100

    sd-bus: add arrays of strings in the bloom filter
    
    Let's do this right from the beginning, to prepare ground for udev
    messages that most likely want to store list of strings (for device
    tags) in messages, and filter on them.

diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 58f011f..aaf44e3 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -135,6 +135,32 @@ static void append_fds(struct kdbus_item **d, const int fds[], unsigned n_fds) {
         *d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
 }
 
+static void add_bloom_arg(void *data, size_t size, unsigned n_hash, unsigned i, const char *t) {
+        char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")];
+        char *e;
+
+        assert(data);
+        assert(size > 0);
+        assert(i < 64);
+        assert(t);
+
+        e = stpcpy(buf, "arg");
+        if (i < 10)
+                *(e++) = '0' + (char) i;
+        else {
+                *(e++) = '0' + (char) (i / 10);
+                *(e++) = '0' + (char) (i % 10);
+        }
+
+        *e = 0;
+        bloom_add_pair(data, size, n_hash, buf, t);
+
+        strcpy(e, "-dot-prefix");
+        bloom_add_prefixes(data, size, n_hash, buf, t, '.');
+        strcpy(e, "-slash-prefix");
+        bloom_add_prefixes(data, size, n_hash, buf, t, '/');
+}
+
 static int bus_message_setup_bloom(sd_bus_message *m, struct kdbus_bloom_filter *bloom) {
         void *data;
         unsigned i;
@@ -164,39 +190,42 @@ static int bus_message_setup_bloom(sd_bus_message *m, struct kdbus_bloom_filter
                 return r;
 
         for (i = 0; i < 64; i++) {
+                const char *t, *contents;
                 char type;
-                const char *t;
-                char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")];
-                char *e;
 
-                r = sd_bus_message_peek_type(m, &type, NULL);
+                r = sd_bus_message_peek_type(m, &type, &contents);
                 if (r < 0)
                         return r;
 
-                if (type != SD_BUS_TYPE_STRING &&
-                    type != SD_BUS_TYPE_OBJECT_PATH &&
-                    type != SD_BUS_TYPE_SIGNATURE)
-                        break;
+                if (IN_SET(type, SD_BUS_TYPE_STRING, SD_BUS_TYPE_OBJECT_PATH, SD_BUS_TYPE_SIGNATURE)) {
 
-                r = sd_bus_message_read_basic(m, type, &t);
-                if (r < 0)
-                        return r;
+                        /* The bloom filter includes simple strings of any kind */
+                        r = sd_bus_message_read_basic(m, type, &t);
+                        if (r < 0)
+                                return r;
 
-                e = stpcpy(buf, "arg");
-                if (i < 10)
-                        *(e++) = '0' + (char) i;
-                else {
-                        *(e++) = '0' + (char) (i / 10);
-                        *(e++) = '0' + (char) (i % 10);
-                }
+                        add_bloom_arg(data, m->bus->bloom_size, m->bus->bloom_n_hash, i, t);
+                } if (type == SD_BUS_TYPE_ARRAY && STR_IN_SET(contents, "s", "o", "g")) {
 
-                *e = 0;
-                bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, buf, t);
+                        /* As well as array of simple strings of any kinds */
+                        r = sd_bus_message_enter_container(m, type, contents);
+                        if (r < 0)
+                                return r;
+
+                        while ((r = sd_bus_message_read_basic(m, contents[0], &t)) > 0)
+                                add_bloom_arg(data, m->bus->bloom_size, m->bus->bloom_n_hash, i, t);
+                        if (r < 0)
+                                return r;
 
-                strcpy(e, "-dot-prefix");
-                bloom_add_prefixes(data, m->bus->bloom_size, m->bus->bloom_n_hash, buf, t, '.');
-                strcpy(e, "-slash-prefix");
-                bloom_add_prefixes(data, m->bus->bloom_size, m->bus->bloom_n_hash, buf, t, '/');
+                        r = sd_bus_message_exit_container(m);
+                        if (r < 0)
+                                return r;
+
+                } else
+                        /* Stop adding to bloom filter as soon as we
+                         * run into the first argument we cannot add
+                         * to it. */
+                        break;
         }
 
         return 0;
diff --git a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c
index 5ee6eea..071b7e0 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel-bloom.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel-bloom.c
@@ -32,6 +32,7 @@ static void test_one(
                 const char *path,
                 const char *interface,
                 const char *member,
+                bool as_list,
                 const char *arg0,
                 const char *match,
                 bool good) {
@@ -76,7 +77,11 @@ static void test_one(
         assert_se(r >= 0);
 
         log_debug("signal");
-        r = sd_bus_emit_signal(a, path, interface, member, "s", arg0);
+
+        if (as_list)
+                r = sd_bus_emit_signal(a, path, interface, member, "as", 1, arg0);
+        else
+                r = sd_bus_emit_signal(a, path, interface, member, "s", arg0);
         assert_se(r >= 0);
 
         r = sd_bus_process(b, &m);
@@ -89,27 +94,29 @@ static void test_one(
 int main(int argc, char *argv[]) {
         log_set_max_level(LOG_DEBUG);
 
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo/tuut'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "interface='waldo.com'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "member='Piep'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "member='Pi_ep'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "arg0='foobar'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "arg0='foo_bar'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar2'", false);
-
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo/quux'", false);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo/bar/waldo'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo/bar'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/'", true);
-        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/quux'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar/waldo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar/waldo/tuut'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "interface='waldo.com'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "member='Piep'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "member='Pi_ep'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "arg0='foobar'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "arg0='foo_bar'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", true, "foobar", "arg0='foobar'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", true, "foobar", "arg0='foo_bar'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar2'", false);
+
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar/waldo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path='/foo/bar/waldo/quux'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path_namespace='/foo/bar/waldo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path_namespace='/foo/bar'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path_namespace='/foo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path_namespace='/'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", false, "foobar", "path_namespace='/quux'", false);
 
         return 0;
 }

commit a6a6ac16030ea8683dfb1916d13a0b577bf3b512
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 17:03:48 2014 +0100

    update TODO

diff --git a/TODO b/TODO
index 5baf812..1433a22 100644
--- a/TODO
+++ b/TODO
@@ -257,12 +257,9 @@ Features:
   ReadOnlyDirectories=... for whitelisting files for a service.
 
 * sd-bus:
-  - add sd_bus_get_address() call
-  - s/owner_id/bus_id/?
+  - rework errno registration logic
   - how can we make the xml enforcement for native clients unnecessary?
-  - replace "container" by "machine" in sd_bus_open_system_container()
   - add "as" (array of strings) support to bloom filter
-  - bus-proxy: fix how we detect whether we are connected to a system bus
   - kdbus: the kernel should not allow messages to be delivered that have a reply serial != 0, reply-expect unset, but no appropriate window
   - kdbus: when we fake creds euid being (uint32_t) -1 is weirdly translated
   - kdbus: timestamps on kernel's NameOwnerChanged messages?

commit 224b3787679a7dc57732d29c5b0cbec7b14e0c10
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 17:03:35 2014 +0100

    sd-bus: make more connection properties readable

diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 6b35036..ff01d60 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3432,3 +3432,47 @@ _public_ int sd_bus_get_address(sd_bus *bus, const char **address) {
 
         return -ENODATA;
 }
+
+int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *mask) {
+        assert_return(bus, -EINVAL);
+        assert_return(mask, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        *mask = bus->creds_mask;
+        return 0;
+}
+
+int sd_bus_is_bus_client(sd_bus *bus) {
+        assert_return(bus, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        return bus->bus_client;
+}
+
+int sd_bus_is_server(sd_bus *bus) {
+        assert_return(bus, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        return bus->is_server;
+}
+
+int sd_bus_is_anonymous(sd_bus *bus) {
+        assert_return(bus, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        return bus->anonymous_auth;
+}
+
+int sd_bus_is_trusted(sd_bus *bus) {
+        assert_return(bus, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        return bus->trusted;
+}
+
+int sd_bus_is_monitor(sd_bus *bus) {
+        assert_return(bus, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        return !!(bus->hello_flags & KDBUS_HELLO_MONITOR);
+}
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index daa3484..3ad3db5 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -116,18 +116,29 @@ int sd_bus_open_system_remote(sd_bus **ret, const char *host);
 int sd_bus_open_system_container(sd_bus **ret, const char *machine);
 
 int sd_bus_new(sd_bus **ret);
+
 int sd_bus_set_address(sd_bus *bus, const char *address);
 int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd);
 int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
+int sd_bus_get_address(sd_bus *bus, const char **address);
 int sd_bus_set_bus_client(sd_bus *bus, int b);
+int sd_bus_is_bus_client(sd_bus *bus);
 int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t bus_id);
+int sd_bus_is_server(sd_bus *bus);
 int sd_bus_set_anonymous(sd_bus *bus, int b);
+int sd_bus_is_anonymous(sd_bus *bus);
 int sd_bus_set_trusted(sd_bus *bus, int b);
-int sd_bus_set_description(sd_bus *bus, const char *description);
+int sd_bus_is_trusted(sd_bus *bus);
 int sd_bus_set_monitor(sd_bus *bus, int b);
+int sd_bus_is_monitor(sd_bus *bus);
+int sd_bus_set_description(sd_bus *bus, const char *description);
+int sd_bus_get_description(sd_bus *bus, const char **description);
 int sd_bus_negotiate_fds(sd_bus *bus, int b);
+int sd_bus_can_send(sd_bus *bus, char type);
 int sd_bus_negotiate_timestamp(sd_bus *bus, int b);
 int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t creds_mask);
+int sd_bus_get_creds_mask(sd_bus *bus, uint64_t *creds_mask);
+
 int sd_bus_start(sd_bus *ret);
 
 int sd_bus_try_close(sd_bus *bus);
@@ -137,13 +148,11 @@ sd_bus *sd_bus_ref(sd_bus *bus);
 sd_bus *sd_bus_unref(sd_bus *bus);
 
 int sd_bus_is_open(sd_bus *bus);
-int sd_bus_can_send(sd_bus *bus, char type);
-int sd_bus_get_address(sd_bus *bus, const char **address);
+
 int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
-int sd_bus_get_owner_creds(sd_bus *bus, uint64_t creds_mask, sd_bus_creds **ret);
 int sd_bus_get_scope(sd_bus *bus, const char **scope);
-int sd_bus_get_description(sd_bus *bus, const char **description);
 int sd_bus_get_tid(sd_bus *bus, pid_t *tid);
+int sd_bus_get_owner_creds(sd_bus *bus, uint64_t creds_mask, sd_bus_creds **ret);
 
 int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *cookie);
 int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *cookie);

commit 5b820358cf2a5cb6d67cc0b1faaaca3b0171f1ac
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 16:51:45 2014 +0100

    sd-bus: add new sd_bus_get_address() for querying the current bus address
    
    Also, update "busctl" to show this in its output.

diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index f75a9dc..1ba4e8a 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -1176,12 +1176,16 @@ static int status(sd_bus *bus, char *argv[]) {
                                         pid,
                                         _SD_BUS_CREDS_ALL);
         } else {
-                const char *scope;
+                const char *scope, *address;
                 sd_id128_t bus_id;
 
+                r = sd_bus_get_address(bus, &address);
+                if (r >= 0)
+                        printf("BusAddress=%s%s%s\n", ansi_highlight(), address, ansi_highlight_off());
+
                 r = sd_bus_get_scope(bus, &scope);
                 if (r >= 0)
-                        printf("Scope=%s%s%s\n", ansi_highlight(), scope, ansi_highlight_off());
+                        printf("BusScope=%s%s%s\n", ansi_highlight(), scope, ansi_highlight_off());
 
                 r = sd_bus_get_bus_id(bus, &bus_id);
                 if (r >= 0)
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 5947cd7..6b35036 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3396,24 +3396,38 @@ _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
 
                 if (streq(n, "0-system")) {
                         *scope = "system";
-                        return 1;
+                        return 0;
                 }
 
                 dash = strchr(n, '-');
                 if (streq(dash, "-user")) {
                         *scope = "user";
-                        return 1;
+                        return 0;
                 }
         }
 
         if (bus->is_user) {
                 *scope = "user";
-                return 1;
+                return 0;
         }
 
         if (bus->is_system) {
                 *scope = "system";
-                return 1;
+                return 0;
+        }
+
+        return -ENODATA;
+}
+
+_public_ int sd_bus_get_address(sd_bus *bus, const char **address) {
+
+        assert_return(bus, -EINVAL);
+        assert_return(address, -EINVAL);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        if (bus->address) {
+                *address = bus->address;
+                return 0;
         }
 
         return -ENODATA;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 78a81a9..daa3484 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -120,7 +120,7 @@ int sd_bus_set_address(sd_bus *bus, const char *address);
 int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd);
 int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
 int sd_bus_set_bus_client(sd_bus *bus, int b);
-int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t owner_id);
+int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t bus_id);
 int sd_bus_set_anonymous(sd_bus *bus, int b);
 int sd_bus_set_trusted(sd_bus *bus, int b);
 int sd_bus_set_description(sd_bus *bus, const char *description);
@@ -138,6 +138,7 @@ sd_bus *sd_bus_unref(sd_bus *bus);
 
 int sd_bus_is_open(sd_bus *bus);
 int sd_bus_can_send(sd_bus *bus, char type);
+int sd_bus_get_address(sd_bus *bus, const char **address);
 int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
 int sd_bus_get_owner_creds(sd_bus *bus, uint64_t creds_mask, sd_bus_creds **ret);
 int sd_bus_get_scope(sd_bus *bus, const char **scope);

commit 5c3026927de9dfa60ad6ae8326fef5d7824e723e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 28 16:38:47 2014 +0100

    sd-bus: rename sd_bus_get_owner_id() → sd_bus_get_bus_id()
    
    The ID returned really doesn't identify the owner, but the bus instance,
    hence fix this misnaming.
    
    Also, update "busctl status" to show the ID in its output.

diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 6b15e7d..6dfba14 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -625,7 +625,7 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
                 if (!sd_bus_message_has_signature(m, ""))
                         return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
 
-                r = sd_bus_get_owner_id(a, &server_id);
+                r = sd_bus_get_bus_id(a, &server_id);
                 if (r < 0)
                         return synthetic_reply_method_errno(m, r, NULL);
 
@@ -1354,7 +1354,7 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        r = sd_bus_get_owner_id(a, &server_id);
+        r = sd_bus_get_bus_id(a, &server_id);
         if (r < 0) {
                 log_error_errno(r, "Failed to get server ID: %m");
                 goto finish;
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
index 7632942..baa1a6f 100644
--- a/src/libsystemd/libsystemd.sym.m4
+++ b/src/libsystemd/libsystemd.sym.m4
@@ -190,7 +190,7 @@ global:
         sd_bus_unref;
         sd_bus_is_open;
         sd_bus_can_send;
-        sd_bus_get_owner_id;
+        sd_bus_get_bus_id;
         sd_bus_get_owner_creds;
         sd_bus_get_description;
         sd_bus_send;
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index 229a1cf..f75a9dc 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -1177,11 +1177,16 @@ static int status(sd_bus *bus, char *argv[]) {
                                         _SD_BUS_CREDS_ALL);
         } else {
                 const char *scope;
+                sd_id128_t bus_id;
 
                 r = sd_bus_get_scope(bus, &scope);
                 if (r >= 0)
                         printf("Scope=%s%s%s\n", ansi_highlight(), scope, ansi_highlight_off());
 
+                r = sd_bus_get_bus_id(bus, &bus_id);
+                if (r >= 0)
+                        printf("BusID=%s" SD_ID128_FORMAT_STR "%s\n", ansi_highlight(), SD_ID128_FORMAT_VAL(bus_id), ansi_highlight_off());
+
                 r = sd_bus_get_owner_creds(
                                 bus,
                                 (arg_augment_creds ? SD_BUS_CREDS_AUGMENT : 0) | _SD_BUS_CREDS_ALL,
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 70dabcc..5947cd7 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -1442,7 +1442,7 @@ _public_ int sd_bus_can_send(sd_bus *bus, char type) {
         return bus_type_is_valid(type);
 }
 
-_public_ int sd_bus_get_owner_id(sd_bus *bus, sd_id128_t *id) {
+_public_ int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id) {
         int r;
 
         assert_return(bus, -EINVAL);
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 4a025d6..06edd62 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -76,7 +76,7 @@ static int server_init(sd_bus **_bus) {
                 goto fail;
         }
 
-        r = sd_bus_get_owner_id(bus, &id);
+        r = sd_bus_get_bus_id(bus, &id);
         if (r < 0) {
                 log_error_errno(r, "Failed to get server ID: %m");
                 goto fail;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index b245833..78a81a9 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -138,7 +138,7 @@ sd_bus *sd_bus_unref(sd_bus *bus);
 
 int sd_bus_is_open(sd_bus *bus);
 int sd_bus_can_send(sd_bus *bus, char type);
-int sd_bus_get_owner_id(sd_bus *bus, sd_id128_t *id);
+int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
 int sd_bus_get_owner_creds(sd_bus *bus, uint64_t creds_mask, sd_bus_creds **ret);
 int sd_bus_get_scope(sd_bus *bus, const char **scope);
 int sd_bus_get_description(sd_bus *bus, const char **description);



More information about the systemd-commits mailing list