summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c266
1 files changed, 0 insertions, 266 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index d7774db09a..4f21db56e2 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -4205,272 +4205,6 @@ _public_ int sd_bus_message_set_destination(sd_bus_message *m, const char *desti
return message_append_field_string(m, SD_BUS_MESSAGE_HEADER_DESTINATION, SD_BUS_TYPE_STRING, destination, &m->destination);
}
-int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
- const char *u = NULL, *uu = NULL, *s = NULL;
- char **cmdline = NULL;
- unsigned level = 1;
- int r;
- uid_t owner, audit_loginuid;
- uint32_t audit_sessionid;
-
- assert(m);
-
- if (!f)
- f = stdout;
-
- if (with_header) {
- fprintf(f,
- "Message %p\n"
- "\tn_ref=%u\n"
- "\tendian=%c\n"
- "\ttype=%i\n"
- "\tflags=%u\n"
- "\tversion=%u\n"
- "\tserial=%u\n"
- "\tfields_size=%u\n"
- "\tbody_size=%u\n"
- "\tpath=%s\n"
- "\tinterface=%s\n"
- "\tmember=%s\n"
- "\tdestination=%s\n"
- "\tsender=%s\n"
- "\tsignature=%s\n"
- "\treply_serial=%u\n"
- "\tsealed=%s\n"
- "\tn_body_parts=%u\n",
- m,
- m->n_ref,
- m->header->endian,
- m->header->type,
- m->header->flags,
- m->header->version,
- BUS_MESSAGE_SERIAL(m),
- BUS_MESSAGE_FIELDS_SIZE(m),
- BUS_MESSAGE_BODY_SIZE(m),
- strna(m->path),
- strna(m->interface),
- strna(m->member),
- strna(m->destination),
- strna(m->sender),
- strna(m->root_container.signature),
- m->reply_serial,
- yes_no(m->sealed),
- m->n_body_parts);
-
- if (sd_bus_error_is_set(&m->error))
- fprintf(f,
- "\terror.name=%s\n"
- "\terror.message=%s\n",
- strna(m->error.name),
- strna(m->error.message));
-
- if (m->pid != 0)
- fprintf(f, "\tpid=%lu\n", (unsigned long) m->pid);
- if (m->tid != 0)
- fprintf(f, "\ttid=%lu\n", (unsigned long) m->tid);
- if (m->uid_valid)
- fprintf(f, "\tuid=%lu\n", (unsigned long) m->uid);
- if (m->gid_valid)
- fprintf(f, "\tgid=%lu\n", (unsigned long) m->gid);
- if (m->pid_starttime != 0)
- fprintf(f, "\tpid_starttime=%llu\n", (unsigned long long) m->pid_starttime);
- if (m->monotonic != 0)
- fprintf(f, "\tmonotonic=%llu\n", (unsigned long long) m->monotonic);
- if (m->realtime != 0)
- fprintf(f, "\trealtime=%llu\n", (unsigned long long) m->realtime);
- if (m->exe)
- fprintf(f, "\texe=[%s]\n", m->exe);
- if (m->comm)
- fprintf(f, "\tcomm=[%s]\n", m->comm);
- if (m->tid_comm)
- fprintf(f, "\ttid_comm=[%s]\n", m->tid_comm);
- if (m->label)
- fprintf(f, "\tlabel=[%s]\n", m->label);
- if (m->cgroup)
- fprintf(f, "\tcgroup=[%s]\n", m->cgroup);
-
- sd_bus_message_get_unit(m, &u);
- if (u)
- fprintf(f, "\tunit=[%s]\n", u);
- sd_bus_message_get_user_unit(m, &uu);
- if (uu)
- fprintf(f, "\tuser_unit=[%s]\n", uu);
- sd_bus_message_get_session(m, &s);
- if (s)
- fprintf(f, "\tsession=[%s]\n", s);
- if (sd_bus_message_get_owner_uid(m, &owner) >= 0)
- fprintf(f, "\towner_uid=%lu\n", (unsigned long) owner);
- if (sd_bus_message_get_audit_loginuid(m, &audit_loginuid) >= 0)
- fprintf(f, "\taudit_loginuid=%lu\n", (unsigned long) audit_loginuid);
- if (sd_bus_message_get_audit_sessionid(m, &audit_sessionid) >= 0)
- fprintf(f, "\taudit_sessionid=%lu\n", (unsigned long) audit_sessionid);
-
- r = sd_bus_message_has_effective_cap(m, 5);
- if (r >= 0)
- fprintf(f, "\tCAP_KILL=%s\n", yes_no(r));
-
- if (sd_bus_message_get_cmdline(m, &cmdline) >= 0) {
- char **c;
-
- fputs("\tcmdline=[", f);
- STRV_FOREACH(c, cmdline) {
- if (c != cmdline)
- fputc(' ', f);
-
- fputs(*c, f);
- }
-
- fputs("]\n", f);
- }
- }
-
- r = sd_bus_message_rewind(m, true);
- if (r < 0) {
- log_error("Failed to rewind: %s", strerror(-r));
- return r;
- }
-
- fprintf(f, "MESSAGE \"%s\" {\n", strempty(m->root_container.signature));
-
- for(;;) {
- _cleanup_free_ char *prefix = NULL;
- const char *contents = NULL;
- char type;
- union {
- uint8_t u8;
- uint16_t u16;
- int16_t s16;
- uint32_t u32;
- int32_t s32;
- uint64_t u64;
- int64_t s64;
- double d64;
- const char *string;
- int i;
- } basic;
-
- r = sd_bus_message_peek_type(m, &type, &contents);
- if (r < 0) {
- log_error("Failed to peek type: %s", strerror(-r));
- return r;
- }
-
- if (r == 0) {
- if (level <= 1)
- break;
-
- r = sd_bus_message_exit_container(m);
- if (r < 0) {
- log_error("Failed to exit container: %s", strerror(-r));
- return r;
- }
-
- level--;
-
- prefix = strrep("\t", level);
- if (!prefix)
- return log_oom();
-
- fprintf(f, "%s};\n", prefix);
- continue;
- }
-
- prefix = strrep("\t", level);
- if (!prefix)
- return log_oom();
-
- if (bus_type_is_container(type) > 0) {
- r = sd_bus_message_enter_container(m, type, contents);
- if (r < 0) {
- log_error("Failed to enter container: %s", strerror(-r));
- return r;
- }
-
- if (type == SD_BUS_TYPE_ARRAY)
- fprintf(f, "%sARRAY \"%s\" {\n", prefix, contents);
- else if (type == SD_BUS_TYPE_VARIANT)
- fprintf(f, "%sVARIANT \"%s\" {\n", prefix, contents);
- else if (type == SD_BUS_TYPE_STRUCT)
- fprintf(f, "%sSTRUCT \"%s\" {\n", prefix, contents);
- else if (type == SD_BUS_TYPE_DICT_ENTRY)
- fprintf(f, "%sDICT_ENTRY \"%s\" {\n", prefix, contents);
-
- level ++;
-
- continue;
- }
-
- r = sd_bus_message_read_basic(m, type, &basic);
- if (r < 0) {
- log_error("Failed to get basic: %s", strerror(-r));
- return r;
- }
-
- assert(r > 0);
-
- switch (type) {
-
- case SD_BUS_TYPE_BYTE:
- fprintf(f, "%sBYTE %u;\n", prefix, basic.u8);
- break;
-
- case SD_BUS_TYPE_BOOLEAN:
- fprintf(f, "%sBOOLEAN %s;\n", prefix, yes_no(basic.i));
- break;
-
- case SD_BUS_TYPE_INT16:
- fprintf(f, "%sINT16 %i;\n", prefix, basic.s16);
- break;
-
- case SD_BUS_TYPE_UINT16:
- fprintf(f, "%sUINT16 %u;\n", prefix, basic.u16);
- break;
-
- case SD_BUS_TYPE_INT32:
- fprintf(f, "%sINT32 %i;\n", prefix, basic.s32);
- break;
-
- case SD_BUS_TYPE_UINT32:
- fprintf(f, "%sUINT32 %u;\n", prefix, basic.u32);
- break;
-
- case SD_BUS_TYPE_INT64:
- fprintf(f, "%sINT64 %lli;\n", prefix, (long long) basic.s64);
- break;
-
- case SD_BUS_TYPE_UINT64:
- fprintf(f, "%sUINT64 %llu;\n", prefix, (unsigned long long) basic.u64);
- break;
-
- case SD_BUS_TYPE_DOUBLE:
- fprintf(f, "%sDOUBLE %g;\n", prefix, basic.d64);
- break;
-
- case SD_BUS_TYPE_STRING:
- fprintf(f, "%sSTRING \"%s\";\n", prefix, basic.string);
- break;
-
- case SD_BUS_TYPE_OBJECT_PATH:
- fprintf(f, "%sOBJECT_PATH \"%s\";\n", prefix, basic.string);
- break;
-
- case SD_BUS_TYPE_SIGNATURE:
- fprintf(f, "%sSIGNATURE \"%s\";\n", prefix, basic.string);
- break;
-
- case SD_BUS_TYPE_UNIX_FD:
- fprintf(f, "%sUNIX_FD %i;\n", prefix, basic.i);
- break;
-
- default:
- assert_not_reached("Unknown basic type.");
- }
- }
-
- fprintf(f, "};\n");
- return 0;
-}
-
int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) {
size_t total;
void *p, *e;