[systemd-commits] 4 commits - TODO src/libsystemd src/shared src/test
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Mar 14 13:17:28 PDT 2014
TODO | 2 +
src/libsystemd/sd-bus/bus-match.c | 3 ++
src/libsystemd/sd-bus/bus-message.c | 7 ++---
src/shared/util.c | 43 ++++++++++++++++++++++++++++++++++++
src/shared/util.h | 2 +
src/test/test-util.c | 20 ++++++++++++++++
6 files changed, 73 insertions(+), 4 deletions(-)
New commits:
commit 5a4d665ad679a8436f1210ba67d713a8f0b91b96
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Mar 14 21:15:32 2014 +0100
sd-bus: don't choke if somebody sends us a message with a unix fd count of 0
It's kinda pointless to include a unix fd header field in messages if it
carries the value 0, but let's do this anyway...
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 97ab0e3..b9d7f6d 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -4885,6 +4885,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
size_t ri;
int r;
uint32_t unix_fds = 0;
+ bool unix_fds_set = false;
void *offsets = NULL;
unsigned n_offsets = 0;
size_t sz = 0;
@@ -5097,7 +5098,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
}
case BUS_MESSAGE_HEADER_UNIX_FDS:
- if (unix_fds != 0)
+ if (unix_fds_set)
return -EBADMSG;
if (!streq(signature, "u"))
@@ -5107,9 +5108,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
if (r < 0)
return -EBADMSG;
- if (unix_fds == 0)
- return -EBADMSG;
-
+ unix_fds_set = true;
break;
default:
commit bbb6ff0216a7c081a2e63e01b1f121592b0165bb
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Mar 14 21:12:36 2014 +0100
sd-bus: don't access invalid memory if a signal matcher was freed from its own callback
diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
index 8280488..c54ca8d 100644
--- a/src/libsystemd/sd-bus/bus-match.c
+++ b/src/libsystemd/sd-bus/bus-match.c
@@ -293,6 +293,9 @@ int bus_match_run(
r = bus_maybe_reply_error(m, r, &error_buffer);
if (r != 0)
return r;
+
+ if (bus && bus->match_callbacks_modified)
+ return 0;
}
return bus_match_run(bus, node->next, m);
commit 29bfbcd675d750c0af4d7dae217722932249e435
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Mar 14 21:11:31 2014 +0100
util: add hexdump() call to create pretty hexdumps of data
This is very useful when debugging sd-bus to look at messages.
diff --git a/src/shared/util.c b/src/shared/util.c
index 8b8d2fb..7e17851 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6347,3 +6347,46 @@ char* mount_test_option(const char *haystack, const char *needle) {
return hasmntopt(&me, needle);
}
+
+void hexdump(FILE *f, const void *p, size_t s) {
+ const uint8_t *b = p;
+ unsigned n = 0;
+
+ assert(s == 0 || b);
+
+ while (s > 0) {
+ size_t i;
+
+ fprintf(f, "%04x ", n);
+
+ for (i = 0; i < 16; i++) {
+
+ if (i >= s)
+ fputs(" ", f);
+ else
+ fprintf(f, "%02x ", b[i]);
+
+ if (i == 7)
+ fputc(' ', f);
+ }
+
+ fputc(' ', f);
+
+ for (i = 0; i < 16; i++) {
+
+ if (i >= s)
+ fputc(' ', f);
+ else
+ fputc(isprint(b[i]) ? (char) b[i] : '.', f);
+ }
+
+ fputc('\n', f);
+
+ if (s < 16)
+ break;
+
+ n += 16;
+ b += 16;
+ s -= 16;
+ }
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index e99f8d1..c596d79 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -914,3 +914,5 @@ const char *personality_to_string(unsigned long);
uint64_t physical_memory(void);
char* mount_test_option(const char *haystack, const char *needle);
+
+void hexdump(FILE *f, const void *p, size_t s);
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 229f492..6297182 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -626,6 +626,25 @@ static void test_writing_tmpfile(void) {
assert(streq(contents, "abc\n" ALPHANUMERICAL "\n"));
}
+static void test_hexdump(void) {
+ uint8_t data[146];
+ unsigned i;
+
+ hexdump(stdout, NULL, 0);
+ hexdump(stdout, "", 0);
+ hexdump(stdout, "", 1);
+ hexdump(stdout, "x", 1);
+ hexdump(stdout, "x", 2);
+ hexdump(stdout, "foobar", 7);
+ hexdump(stdout, "f\nobar", 7);
+ hexdump(stdout, "xxxxxxxxxxxxxxxxxxxxyz", 23);
+
+ for (i = 0; i < ELEMENTSOF(data); i++)
+ data[i] = i*2;
+
+ hexdump(stdout, data, sizeof(data));
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -667,6 +686,7 @@ int main(int argc, char *argv[]) {
test_get_files_in_directory();
test_in_set();
test_writing_tmpfile();
+ test_hexdump();
return 0;
}
commit edb2935c5c5b95c42b8679086f60da5eafad74cb
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Mar 14 21:10:55 2014 +0100
update TODO
diff --git a/TODO b/TODO
index 11aee34..e823f0a 100644
--- a/TODO
+++ b/TODO
@@ -27,6 +27,8 @@ External:
Features:
+* add bus api to query unit file's X fields.
+
* consider adding RuntimeDirectoryUser= + RuntimeDirectoryGroup=
* sd-event: define more intervals where we will shift wakeup intervals around in, 1h, 6h, 24h, ...
More information about the systemd-commits
mailing list