[systemd-commits] 2 commits - src/libsystemd-bus src/systemd
Lennart Poettering
lennart at kemper.freedesktop.org
Sat Apr 13 18:21:18 PDT 2013
src/libsystemd-bus/bus-control.c | 11 ++++++++
src/libsystemd-bus/bus-kernel.c | 5 +++
src/libsystemd-bus/bus-message.c | 49 +++++++++++++++++++++++++++++++++++++++
src/libsystemd-bus/bus-message.h | 5 +++
src/systemd/sd-bus.h | 1
5 files changed, 71 insertions(+)
New commits:
commit 77930f11207ef6ec1f9284a1179fdd78c3364cba
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Apr 14 03:20:12 2013 +0200
kdbus: also parse cmdline message attribute
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index ca47ea2..6105a02 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -371,6 +371,11 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
m->tid_comm = d->str;
else if (d->type == KDBUS_MSG_SRC_EXE)
m->exe = d->str;
+ else if (d->type == KDBUS_MSG_SRC_CMDLINE) {
+ m->cmdline = d->str;
+ m->cmdline_length = l;
+ } else
+ log_debug("Got unknown field from kernel %llu", d->type);
}
r = bus_message_parse_fields(m);
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index bae0812..e970d09 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -70,6 +70,8 @@ static void message_free(sd_bus_message *m) {
free(m->fds);
}
+ free(m->cmdline_array);
+
reset_containers(m);
free(m->root_container.signature);
@@ -752,6 +754,38 @@ const char *sd_bus_message_get_exe(sd_bus_message *m) {
return m->exe;
}
+int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline) {
+ size_t n, i;
+ const char *p;
+ bool first;
+
+ if (!m)
+ return -EINVAL;
+
+ if (!m->cmdline)
+ return -ENOENT;
+
+ for (p = m->cmdline, n = 0; p < m->cmdline + m->cmdline_length; p++)
+ if (*p == 0)
+ n++;
+
+ m->cmdline_array = new(char*, n + 1);
+ if (!m->cmdline_array)
+ return -ENOMEM;
+
+ for (p = m->cmdline, i = 0, first = true; p < m->cmdline + m->cmdline_length; p++) {
+ if (first)
+ m->cmdline_array[i++] = (char*) p;
+
+ first = *p == 0;
+ }
+
+ m->cmdline_array[i] = NULL;
+ *cmdline = m->cmdline_array;
+
+ return 0;
+}
+
int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member) {
if (!m)
return -EINVAL;
@@ -2928,6 +2962,7 @@ int sd_bus_message_set_destination(sd_bus_message *m, const char *destination) {
}
int bus_message_dump(sd_bus_message *m) {
+ char **cmdline = NULL;
unsigned level = 1;
int r;
@@ -2995,6 +3030,20 @@ int bus_message_dump(sd_bus_message *m) {
if (m->label)
printf("\tlabel=[%s]\n", m->label);
+ if (sd_bus_message_get_cmdline(m, &cmdline) >= 0) {
+ char **c;
+
+ fputs("\tcmdline=[", stdout);
+ STRV_FOREACH(c, cmdline) {
+ if (c != cmdline)
+ putchar(' ');
+
+ fputs(*c, stdout);
+ }
+
+ fputs("]\n", stdout);
+ }
+
r = sd_bus_message_rewind(m, true);
if (r < 0) {
log_error("Failed to rewind: %s", strerror(-r));
diff --git a/src/libsystemd-bus/bus-message.h b/src/libsystemd-bus/bus-message.h
index 1c40377..60fc3fc 100644
--- a/src/libsystemd-bus/bus-message.h
+++ b/src/libsystemd-bus/bus-message.h
@@ -110,6 +110,11 @@ struct sd_bus_message {
const char *exe;
const char *comm;
const char *tid_comm;
+
+ const char *cmdline;
+ size_t cmdline_length;
+
+ char **cmdline_array;
};
#define BUS_MESSAGE_NEED_BSWAP(m) ((m)->header->endian != SD_BUS_NATIVE_ENDIAN)
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 70d41eb..7413d87 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -134,6 +134,7 @@ const char *sd_bus_message_get_selinux_context(sd_bus_message *m);
const char *sd_bus_message_get_comm(sd_bus_message *m);
const char *sd_bus_message_get_tid_comm(sd_bus_message *m);
const char *sd_bus_message_get_exe(sd_bus_message *m);
+int sd_bus_message_get_cmdline(sd_bus_message *m, char ***cmdline);
int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);
commit 75722f1d48cf1a93cc4a24e332c9871808c0e641
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Apr 14 03:19:51 2013 +0200
kdbus: make name acquirement ioctls valgrind clean
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
index 185f77c..5296029 100644
--- a/src/libsystemd-bus/bus-control.c
+++ b/src/libsystemd-bus/bus-control.c
@@ -19,6 +19,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
#include <stddef.h>
#include <errno.h>
@@ -68,6 +72,10 @@ int sd_bus_request_name(sd_bus *bus, const char *name, int flags) {
n->id = 0;
memcpy(n->name, name, l+1);
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED(n, n->size);
+#endif
+
r = ioctl(bus->input_fd, KDBUS_CMD_NAME_ACQUIRE, n);
if (r < 0)
return -errno;
@@ -119,6 +127,9 @@ int sd_bus_release_name(sd_bus *bus, const char *name) {
n->id = 0;
memcpy(n->name, name, l+1);
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED(n, n->size);
+#endif
r = ioctl(bus->input_fd, KDBUS_CMD_NAME_RELEASE, n);
if (r < 0)
return -errno;
More information about the systemd-commits
mailing list