bus-dump.c revision 5ce70e5bcd62e89b52485961c3699312ee4a7e0e
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers This file is part of systemd.
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers Copyright 2013 Lennart Poettering
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers systemd is free software; you can redistribute it and/or modify it
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers under the terms of the GNU Lesser General Public License as published by
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers the Free Software Foundation; either version 2.1 of the License, or
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers (at your option) any later version.
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers systemd is distributed in the hope that it will be useful, but
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers Lesser General Public License for more details.
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers You should have received a copy of the GNU Lesser General Public License
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
70d9b9fc0a4fa1698ff00e364c61bb875244efa1Cristian RodrÃguezint bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers "%s%s%sType=%s%s%s Endian=%c Flags=%u Version=%u",
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_highlight_off(),
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers ansi_highlight(), bus_message_type_to_string(m->header->type), ansi_highlight_off(),
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers /* Display synthetic message serial number in a more readable
c51d84dc09476d9c06b8aac726220bf3c7d62e8dKay Sievers * format than (uint32_t) -1 */
if (m->reply_cookie != 0)
if (m->sender)
if (m->destination)
if (m->path)
if (m->interface)
if (m->member)
fprintf(f,
if (m->monotonic != 0)
if (m->realtime != 0)
r = sd_bus_message_rewind(m, true);
char type;
double d64;
const char *string;
} basic;
r = sd_bus_message_exit_container(m);
level--;
if (!prefix)
return log_oom();
if (!prefix)
return log_oom();
level ++;
assert(r > 0);
switch (type) {
case SD_BUS_TYPE_BYTE:
case SD_BUS_TYPE_BOOLEAN:
fprintf(f, "%sBOOLEAN %s%s%s;\n", prefix, ansi_highlight(), true_false(basic.i), ansi_highlight_off());
case SD_BUS_TYPE_INT16:
case SD_BUS_TYPE_UINT16:
case SD_BUS_TYPE_INT32:
case SD_BUS_TYPE_UINT32:
case SD_BUS_TYPE_INT64:
fprintf(f, "%sINT64 %s%lli%s;\n", prefix, ansi_highlight(), (long long) basic.s64, ansi_highlight_off());
case SD_BUS_TYPE_UINT64:
fprintf(f, "%sUINT64 %s%llu%s;\n", prefix, ansi_highlight(), (unsigned long long) basic.u64, ansi_highlight_off());
case SD_BUS_TYPE_DOUBLE:
case SD_BUS_TYPE_STRING:
case SD_BUS_TYPE_OBJECT_PATH:
fprintf(f, "%sOBJECT_PATH \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
case SD_BUS_TYPE_SIGNATURE:
fprintf(f, "%sSIGNATURE \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
case SD_BUS_TYPE_UNIX_FD:
static void dump_capabilities(
sd_bus_creds *c,
FILE *f,
const char *name,
unsigned long i, last_cap;
assert(c);
assert(f);
r = has(c, i);
_cleanup_cap_free_charp_ char *t;
t = cap_to_name(i);
if (i > last_cap)
r = has(c, i);
assert(c);
f = stdout;
if ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID|SD_BUS_CREDS_UID|SD_BUS_CREDS_GID)) || r >= 0)
if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_SELINUX_CONTEXT))
if (i != cmdline)
fputs(*i, f);
sd_bus_creds_get_unit(c, &u);
if (uu)
if (sl)
sd_bus_creds_get_session(c, &s);
audit_loginuid_is_set = true;
audit_sessionid_is_set = true;
if (i != well_known)
fputs(*i, f);