X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-bus%2Fbus-dump.c;h=33d0ed2df61cad4f5577a95b53f3cb1bc3e36839;hb=2822da4fb7f891e5320f02f1d00f64b72221ced4;hp=d6e5546053e6181ebb6c4fa7f9e0e2762c42f26b;hpb=705a415f684f8e9ee19983e5859de00bbb1477cb;p=elogind.git diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index d6e554605..33d0ed2df 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -24,6 +24,7 @@ #include "strv.h" #include "audit.h" #include "macro.h" +#include "cap-list.h" #include "bus-message.h" #include "bus-internal.h" @@ -125,10 +126,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)); - if (r < 0) { - log_error("Failed to rewind: %s", strerror(-r)); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to rewind: %m"); if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) fprintf(f, "%sMESSAGE \"%s\" {\n", indent(0, flags), strempty(m->root_container.signature)); @@ -151,20 +150,16 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } 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) + return log_error_errno(r, "Failed to peek type: %m"); 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; - } + if (r < 0) + return log_error_errno(r, "Failed to exit container: %m"); level--; @@ -182,10 +177,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { 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 (r < 0) + return log_error_errno(r, "Failed to enter container: %m"); if (type == SD_BUS_TYPE_ARRAY) fprintf(f, "%sARRAY \"%s\" {\n", prefix, contents); @@ -202,10 +195,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } r = sd_bus_message_read_basic(m, type, &basic); - if (r < 0) { - log_error("Failed to get basic: %s", strerror(-r)); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get basic: %m"); assert(r > 0); @@ -300,15 +291,13 @@ static void dump_capabilities( for (;;) { if (r > 0) { - _cleanup_cap_free_charp_ char *t; if (n > 0) fputc(' ', f); if (n % 4 == 3) fprintf(f, terse ? "\n " : "\n "); - t = cap_to_name(i); - fprintf(f, "%s", t); + fprintf(f, "%s", strna(capability_to_name(i))); n++; } @@ -356,12 +345,10 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) { if (c->mask & SD_BUS_CREDS_PID) fprintf(f, "%sPID=%s"PID_FMT"%s", prefix, color, c->pid, suffix); - if (c->mask & SD_BUS_CREDS_PID_STARTTIME) - fprintf(f, "%sPIDStartTime=%s"USEC_FMT"%s", prefix, color, c->pid_starttime, suffix); if (c->mask & SD_BUS_CREDS_TID) fprintf(f, "%sTID=%s"PID_FMT"%s", prefix, color, c->tid, suffix); - if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID)))) + if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_TID)))) fputs("\n", f); if (c->mask & SD_BUS_CREDS_UID) @@ -384,8 +371,18 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) { if (c->mask & SD_BUS_CREDS_FSGID) fprintf(f, "%sFSGID=%s"GID_FMT"%s", prefix, color, c->fsgid, suffix); + if (c->mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS) { + unsigned i; + + fprintf(f, "%sSupplementaryGIDs=%s", prefix, color); + for (i = 0; i < c->n_supplementary_gids; i++) + fprintf(f, "%s" GID_FMT, i > 0 ? " " : "", c->supplementary_gids[i]); + fprintf(f, "%s", suffix); + } + if (terse && ((c->mask & (SD_BUS_CREDS_UID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID| - SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID)) || r >= 0)) + SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID| + SD_BUS_CREDS_SUPPLEMENTARY_GIDS)) || r >= 0)) fputs("\n", f); if (c->mask & SD_BUS_CREDS_COMM)