diff --git a/0295-delta-use-same-nomenclature-for-equivalent-and-redir.patch b/0295-delta-use-same-nomenclature-for-equivalent-and-redir.patch new file mode 100644 index 0000000..23876ae --- /dev/null +++ b/0295-delta-use-same-nomenclature-for-equivalent-and-redir.patch @@ -0,0 +1,111 @@ +From d83587514c0453ec5351e47716cd29f058d0f981 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 16 May 2012 18:57:57 +0200 +Subject: [PATCH] delta: use same nomenclature for equivalent and redirected + everywhere (cherry picked from commit + c8021373fb7762183487fde795aa5cb9d5ea5a1c) + +--- + src/delta/delta.c | 32 +++++++++++++++----------------- + 1 file changed, 15 insertions(+), 17 deletions(-) + +diff --git a/src/delta/delta.c b/src/delta/delta.c +index 7b50bce..bf58fc5 100644 +--- a/src/delta/delta.c ++++ b/src/delta/delta.c +@@ -36,14 +36,14 @@ static bool arg_no_pager = false; + + enum { + SHOW_MASKED = 1 << 0, +- SHOW_EQUIV = 1 << 1, +- SHOW_REDIR = 1 << 2, ++ SHOW_EQUIVALENT = 1 << 1, ++ SHOW_REDIRECTED = 1 << 2, + SHOW_OVERRIDEN = 1 << 3, + SHOW_UNCHANGED = 1 << 4, + SHOW_DIFF = 1 << 5, + + SHOW_DEFAULTS = +- (SHOW_MASKED | SHOW_EQUIV | SHOW_REDIR | SHOW_OVERRIDEN | SHOW_DIFF) ++ (SHOW_MASKED | SHOW_EQUIVALENT | SHOW_REDIRECTED | SHOW_OVERRIDEN | SHOW_DIFF) + }; + + static int equivalent(const char *a, const char *b) { +@@ -67,29 +67,27 @@ static int equivalent(const char *a, const char *b) { + return r; + } + +- +- + static int notify_override_masked(int flags, const char *top, const char *bottom) { + if (!(flags & SHOW_MASKED)) + return 0; + +- printf(ANSI_HIGHLIGHT_RED_ON "[MASK]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf(ANSI_HIGHLIGHT_RED_ON "[MASKED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int notify_override_equiv(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_EQUIV)) ++static int notify_override_equivalent(int flags, const char *top, const char *bottom) { ++ if (!(flags & SHOW_EQUIVALENT)) + return 0; + + printf(ANSI_HIGHLIGHT_GREEN_ON "[EQUIVALENT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int notify_override_redir(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_REDIR)) ++static int notify_override_redirirected(int flags, const char *top, const char *bottom) { ++ if (!(flags & SHOW_REDIRECTED)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[REDIRECT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf(ANSI_HIGHLIGHT_ON "[REDIRECTED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +@@ -97,7 +95,7 @@ static int notify_override_overriden(int flags, const char *top, const char *bot + if (!(flags & SHOW_OVERRIDEN)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[OVERRIDE]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf(ANSI_HIGHLIGHT_ON "[OVERRIDEN]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +@@ -105,7 +103,7 @@ static int notify_override_unchanged(int flags, const char *top, const char *bot + if (!(flags & SHOW_UNCHANGED)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[UNCHANGED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf(ANSI_HIGHLIGHT_ON "[UNCHANGED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +@@ -125,9 +123,9 @@ static int found_override(int flags, const char *top, const char *bottom) { + k = readlink_malloc(top, &dest); + if (k >= 0) { + if (equivalent(dest, bottom) > 0) +- notify_override_equiv(flags, top, bottom); ++ notify_override_equivalent(flags, top, bottom); + else +- notify_override_redir(flags, top, bottom); ++ notify_override_redirirected(flags, top, bottom); + + free(dest); + goto finish; +@@ -339,9 +337,9 @@ static int parse_flags(int flags, const char *flag_str) { + if (strncmp("masked", w, l) == 0) { + flags |= SHOW_MASKED; + } else if (strncmp ("equivalent", w, l) == 0) { +- flags |= SHOW_EQUIV; ++ flags |= SHOW_EQUIVALENT; + } else if (strncmp("redirected", w, l) == 0) { +- flags |= SHOW_REDIR; ++ flags |= SHOW_REDIRECTED; + } else if (strncmp("override", w, l) == 0) { + flags |= SHOW_OVERRIDEN; + } else if (strncmp("unchanged", w, l) == 0) { diff --git a/0296-delta-introduce-arg_flags-field-to-follow-our-usual-.patch b/0296-delta-introduce-arg_flags-field-to-follow-our-usual-.patch new file mode 100644 index 0000000..97ce585 --- /dev/null +++ b/0296-delta-introduce-arg_flags-field-to-follow-our-usual-.patch @@ -0,0 +1,289 @@ +From 48302f023e171b2480f366f416bed24cfcc8617e Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 21 May 2012 02:01:52 +0200 +Subject: [PATCH] delta: introduce arg_flags field, to follow our usual scheme + (cherry picked from commit + 866062b152593e1cfd457ddc31a822e136ea3830) + +--- + src/delta/delta.c | 109 +++++++++++++++++++++++++++++------------------------ + 1 file changed, 60 insertions(+), 49 deletions(-) + +diff --git a/src/delta/delta.c b/src/delta/delta.c +index bf58fc5..0a29d32 100644 +--- a/src/delta/delta.c ++++ b/src/delta/delta.c +@@ -33,18 +33,18 @@ + #include "build.h" + + static bool arg_no_pager = false; ++static int arg_diff = -1; + +-enum { ++static enum { + SHOW_MASKED = 1 << 0, + SHOW_EQUIVALENT = 1 << 1, + SHOW_REDIRECTED = 1 << 2, + SHOW_OVERRIDEN = 1 << 3, + SHOW_UNCHANGED = 1 << 4, +- SHOW_DIFF = 1 << 5, + + SHOW_DEFAULTS = +- (SHOW_MASKED | SHOW_EQUIVALENT | SHOW_REDIRECTED | SHOW_OVERRIDEN | SHOW_DIFF) +-}; ++ (SHOW_MASKED | SHOW_EQUIVALENT | SHOW_REDIRECTED | SHOW_OVERRIDEN) ++} arg_flags = 0; + + static int equivalent(const char *a, const char *b) { + char *x, *y; +@@ -67,47 +67,47 @@ static int equivalent(const char *a, const char *b) { + return r; + } + +-static int notify_override_masked(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_MASKED)) ++static int notify_override_masked(const char *top, const char *bottom) { ++ if (!(arg_flags & SHOW_MASKED)) + return 0; + + printf(ANSI_HIGHLIGHT_RED_ON "[MASKED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int notify_override_equivalent(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_EQUIVALENT)) ++static int notify_override_equivalent(const char *top, const char *bottom) { ++ if (!(arg_flags & SHOW_EQUIVALENT)) + return 0; + + printf(ANSI_HIGHLIGHT_GREEN_ON "[EQUIVALENT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int notify_override_redirirected(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_REDIRECTED)) ++static int notify_override_redirected(const char *top, const char *bottom) { ++ if (!(arg_flags & SHOW_REDIRECTED)) + return 0; + + printf(ANSI_HIGHLIGHT_ON "[REDIRECTED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int notify_override_overriden(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_OVERRIDEN)) ++static int notify_override_overriden(const char *top, const char *bottom) { ++ if (!(arg_flags & SHOW_OVERRIDEN)) + return 0; + + printf(ANSI_HIGHLIGHT_ON "[OVERRIDEN]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int notify_override_unchanged(int flags, const char *top, const char *bottom) { +- if (!(flags & SHOW_UNCHANGED)) ++static int notify_override_unchanged(const char *f) { ++ if (!(arg_flags & SHOW_UNCHANGED)) + return 0; + + printf(ANSI_HIGHLIGHT_ON "[UNCHANGED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); + return 1; + } + +-static int found_override(int flags, const char *top, const char *bottom) { ++static int found_override(const char *top, const char *bottom) { + char *dest; + int k; + pid_t pid; +@@ -116,23 +116,23 @@ static int found_override(int flags, const char *top, const char *bottom) { + assert(bottom); + + if (null_or_empty_path(top) > 0) { +- notify_override_masked(flags, top, bottom); ++ notify_override_masked(top, bottom); + goto finish; + } + + k = readlink_malloc(top, &dest); + if (k >= 0) { + if (equivalent(dest, bottom) > 0) +- notify_override_equivalent(flags, top, bottom); ++ notify_override_equivalent(top, bottom); + else +- notify_override_redirirected(flags, top, bottom); ++ notify_override_redirected(top, bottom); + + free(dest); + goto finish; + } + +- notify_override_overriden(flags, top, bottom); +- if (!(flags & SHOW_DIFF)) ++ notify_override_overriden(top, bottom); ++ if (!arg_diff) + goto finish; + + putchar('\n'); +@@ -228,7 +228,7 @@ finish: + return r; + } + +-static int process_suffix(int flags, const char *prefixes, const char *suffix) { ++static int process_suffix(const char *prefixes, const char *suffix) { + const char *p; + char *f; + Hashmap *top, *bottom; +@@ -275,11 +275,11 @@ static int process_suffix(int flags, const char *prefixes, const char *suffix) { + assert(o); + + if (path_equal(o, f)) { +- notify_override_unchanged(flags, f, o); ++ notify_override_unchanged(f); + continue; + } + +- k = found_override(flags, f, o); ++ k = found_override(f, o); + if (k < 0) + r = k; + +@@ -295,21 +295,21 @@ finish: + return r < 0 ? r : n_found; + } + +-static int process_suffix_chop(int flags, const char *prefixes, const char *suffix) { ++static int process_suffix_chop(const char *prefixes, const char *suffix) { + const char *p; + + assert(prefixes); + assert(suffix); + + if (!path_is_absolute(suffix)) +- return process_suffix(flags, prefixes, suffix); ++ return process_suffix(prefixes, suffix); + + /* Strip prefix from the suffix */ + NULSTR_FOREACH(p, prefixes) { + if (startswith(suffix, p)) { + suffix += strlen(p);; + suffix += strspn(suffix, "/"); +- return process_suffix(flags, prefixes, suffix); ++ return process_suffix(prefixes, suffix); + } + } + +@@ -329,7 +329,7 @@ static void help(void) { + program_invocation_short_name); + } + +-static int parse_flags(int flags, const char *flag_str) { ++static int parse_flags(const char *flag_str, int flags) { + char *w, *state; + size_t l; + +@@ -346,15 +346,13 @@ static int parse_flags(int flags, const char *flag_str) { + flags |= SHOW_UNCHANGED; + } else if (strncmp("default", w, l) == 0) { + flags |= SHOW_DEFAULTS; +- } else { +- log_error("Unknown type filter: %s", w); +- return -1; +- } ++ else ++ return -EINVAL; + } + return flags; + } + +-static int parse_argv(int argc, char *argv[], int *flags) { ++static int parse_argv(int argc, char *argv[]) { + + enum { + ARG_NO_PAGER = 0x100, +@@ -397,20 +395,31 @@ static int parse_argv(int argc, char *argv[], int *flags) { + case '?': + return -EINVAL; + +- case 't': +- *flags = parse_flags(*flags, optarg); +- if (*flags < 0) ++ case 't': { ++ int f; ++ f = parse_flags(optarg, arg_flags); ++ if (f < 0) { ++ log_error("Failed to parse flags field."); + return -EINVAL; ++ } ++ arg_flags = f; + break; ++ } + + case ARG_DIFF: +- if (!optarg) { +- *flags |= SHOW_DIFF; +- } else { +- if (parse_boolean(optarg)) +- *flags |= SHOW_DIFF; ++ if (!optarg) ++ arg_diff = 1; ++ else { ++ int b; ++ ++ b = parse_boolean(optarg); ++ if (b < 0) { ++ log_error("Failed to parse diff boolean."); ++ return -EINVAL; ++ } else if (b) ++ arg_diff = 1; + else +- *flags &= ~SHOW_DIFF; ++ arg_diff = 0; + } + break; + +@@ -451,19 +460,21 @@ int main(int argc, char *argv[]) { + + int r = 0, k; + int n_found = 0; +- int flags = 0; + + log_parse_environment(); + log_open(); + +- r = parse_argv(argc, argv, &flags); ++ r = parse_argv(argc, argv); + if (r <= 0) + goto finish; + +- if (flags == 0) +- flags = SHOW_DEFAULTS; +- if (flags == SHOW_DIFF) +- flags |= SHOW_OVERRIDEN; ++ if (arg_flags == 0) ++ arg_flags = SHOW_DEFAULTS; ++ ++ if (arg_diff < 0) ++ arg_diff = !!(arg_flags & SHOW_OVERRIDEN); ++ else if (arg_diff) ++ arg_flags |= SHOW_OVERRIDEN; + + if (!arg_no_pager) + pager_open(); +@@ -472,7 +483,7 @@ int main(int argc, char *argv[]) { + int i; + + for (i = optind; i < argc; i++) { +- k = process_suffix_chop(flags, prefixes, argv[i]); ++ k = process_suffix_chop(prefixes, argv[i]); + if (k < 0) + r = k; + else +@@ -483,7 +494,7 @@ int main(int argc, char *argv[]) { + const char *n; + + NULSTR_FOREACH(n, suffixes) { +- k = process_suffix(flags, prefixes, n); ++ k = process_suffix(prefixes, n); + if (k < 0) + r = k; + else diff --git a/0297-delta-don-t-highlight-unchanged-files.patch b/0297-delta-don-t-highlight-unchanged-files.patch new file mode 100644 index 0000000..40f992c --- /dev/null +++ b/0297-delta-don-t-highlight-unchanged-files.patch @@ -0,0 +1,23 @@ +From f9ac2d3f0d0b6d0781a2d10613bccb58440fa43d Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 21 May 2012 02:02:31 +0200 +Subject: [PATCH] delta: don't highlight unchanged files (cherry picked from + commit 8e812a2301ad9f849f1b09e95d93e55df4557ec6) + +--- + src/delta/delta.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/delta/delta.c b/src/delta/delta.c +index 0a29d32..cb63b4a 100644 +--- a/src/delta/delta.c ++++ b/src/delta/delta.c +@@ -103,7 +103,7 @@ static int notify_override_unchanged(const char *f) { + if (!(arg_flags & SHOW_UNCHANGED)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[UNCHANGED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf("[UNCHANGED] %s\n", f); + return 1; + } + diff --git a/0298-delta-drop-PHP-ism.patch b/0298-delta-drop-PHP-ism.patch new file mode 100644 index 0000000..4c0c778 --- /dev/null +++ b/0298-delta-drop-PHP-ism.patch @@ -0,0 +1,38 @@ +From aecc75d8796f6202fc5e70e356fd18208e7c3301 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 21 May 2012 02:02:40 +0200 +Subject: [PATCH] delta: drop PHP'ism (cherry picked from commit + c0ef53aa5b54e2b1d4abe316ebb12d3e1d0d9250) + +--- + src/delta/delta.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/delta/delta.c b/src/delta/delta.c +index cb63b4a..25c1f96 100644 +--- a/src/delta/delta.c ++++ b/src/delta/delta.c +@@ -334,17 +334,17 @@ static int parse_flags(const char *flag_str, int flags) { + size_t l; + + FOREACH_WORD(w, l, flag_str, state) { +- if (strncmp("masked", w, l) == 0) { ++ if (strncmp("masked", w, l) == 0) + flags |= SHOW_MASKED; +- } else if (strncmp ("equivalent", w, l) == 0) { ++ else if (strncmp ("equivalent", w, l) == 0) + flags |= SHOW_EQUIVALENT; +- } else if (strncmp("redirected", w, l) == 0) { ++ else if (strncmp("redirected", w, l) == 0) + flags |= SHOW_REDIRECTED; +- } else if (strncmp("override", w, l) == 0) { ++ else if (strncmp("overriden", w, l) == 0) + flags |= SHOW_OVERRIDEN; +- } else if (strncmp("unchanged", w, l) == 0) { ++ else if (strncmp("unchanged", w, l) == 0) + flags |= SHOW_UNCHANGED; +- } else if (strncmp("default", w, l) == 0) { ++ else if (strncmp("default", w, l) == 0) + flags |= SHOW_DEFAULTS; + else + return -EINVAL; diff --git a/0299-dbus-unit-always-load-the-unit-before-handling-a-mes.patch b/0299-dbus-unit-always-load-the-unit-before-handling-a-mes.patch new file mode 100644 index 0000000..02323ff --- /dev/null +++ b/0299-dbus-unit-always-load-the-unit-before-handling-a-mes.patch @@ -0,0 +1,128 @@ +From 851cefb19e1364ca14a4b5b2a0fcf75f7aefa673 Mon Sep 17 00:00:00 2001 +From: Michal Schmidt +Date: Mon, 21 May 2012 12:54:34 +0200 +Subject: [PATCH] dbus-unit: always load the unit before handling a message + for it + +We need to be able to show the properties even of inactive units. +systemctl loads the unit before getting its properties, but this is racy +as the garbage collector may kick in right after the loading. + +Fix it by always loading the unit before handling a message for it. + +https://bugzilla.redhat.com/show_bug.cgi?id=814966#c6 +(cherry picked from commit 80fbf05e75b75b7dd342ec844275efae90c479ec) +--- + src/core/dbus-unit.c | 23 ++++++++++------------- + src/core/manager.c | 12 +++++++----- + src/core/manager.h | 2 +- + 3 files changed, 18 insertions(+), 19 deletions(-) + +diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c +index afe146c..62484ba 100644 +--- a/src/core/dbus-unit.c ++++ b/src/core/dbus-unit.c +@@ -558,12 +558,15 @@ static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DB + Manager *m = data; + Unit *u; + int r; +- DBusMessage *reply; ++ DBusMessage *reply = NULL; ++ DBusError error; + + assert(connection); + assert(message); + assert(m); + ++ dbus_error_init(&error); ++ + if (streq(dbus_message_get_path(message), "/org/freedesktop/systemd1/unit")) { + /* Be nice to gdbus and return introspection data for our mid-level paths */ + +@@ -638,20 +641,12 @@ static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DB + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + +- if ((r = manager_get_unit_from_dbus_path(m, dbus_message_get_path(message), &u)) < 0) { +- ++ r = manager_load_unit_from_dbus_path(m, dbus_message_get_path(message), &error, &u); ++ if (r < 0) { + if (r == -ENOMEM) +- return DBUS_HANDLER_RESULT_NEED_MEMORY; +- +- if (r == -ENOENT) { +- DBusError e; +- +- dbus_error_init(&e); +- dbus_set_error_const(&e, DBUS_ERROR_UNKNOWN_OBJECT, "Unknown unit"); +- return bus_send_error_reply(connection, message, &e, r); +- } ++ goto oom; + +- return bus_send_error_reply(connection, message, NULL, r); ++ return bus_send_error_reply(connection, message, &error, r); + } + + return bus_unit_message_dispatch(u, connection, message); +@@ -660,6 +655,8 @@ oom: + if (reply) + dbus_message_unref(reply); + ++ dbus_error_free(&error); ++ + return DBUS_HANDLER_RESULT_NEED_MEMORY; + } + +diff --git a/src/core/manager.c b/src/core/manager.c +index bc09657..13d1ef5 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -1490,9 +1490,10 @@ int manager_loop(Manager *m) { + return m->exit_code; + } + +-int manager_get_unit_from_dbus_path(Manager *m, const char *s, Unit **_u) { ++int manager_load_unit_from_dbus_path(Manager *m, const char *s, DBusError *e, Unit **_u) { + char *n; + Unit *u; ++ int r; + + assert(m); + assert(s); +@@ -1501,14 +1502,15 @@ int manager_get_unit_from_dbus_path(Manager *m, const char *s, Unit **_u) { + if (!startswith(s, "/org/freedesktop/systemd1/unit/")) + return -EINVAL; + +- if (!(n = bus_path_unescape(s+31))) ++ n = bus_path_unescape(s+31); ++ if (!n) + return -ENOMEM; + +- u = manager_get_unit(m, n); ++ r = manager_load_unit(m, n, NULL, e, &u); + free(n); + +- if (!u) +- return -ENOENT; ++ if (r < 0) ++ return r; + + *_u = u; + +diff --git a/src/core/manager.h b/src/core/manager.h +index bb19506..c36131e 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -251,11 +251,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds); + Job *manager_get_job(Manager *m, uint32_t id); + Unit *manager_get_unit(Manager *m, const char *name); + +-int manager_get_unit_from_dbus_path(Manager *m, const char *s, Unit **_u); + int manager_get_job_from_dbus_path(Manager *m, const char *s, Job **_j); + + int manager_load_unit_prepare(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret); + int manager_load_unit(Manager *m, const char *name, const char *path, DBusError *e, Unit **_ret); ++int manager_load_unit_from_dbus_path(Manager *m, const char *s, DBusError *e, Unit **_u); + + int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, DBusError *e, Job **_ret); + int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode mode, bool force, DBusError *e, Job **_ret); diff --git a/0300-systemctl-drop-useless-DBus-calls-from-systemctl-sho.patch b/0300-systemctl-drop-useless-DBus-calls-from-systemctl-sho.patch new file mode 100644 index 0000000..b43d3db --- /dev/null +++ b/0300-systemctl-drop-useless-DBus-calls-from-systemctl-sho.patch @@ -0,0 +1,281 @@ +From 0d84d978df604019c89ea899e62e483f500fedc8 Mon Sep 17 00:00:00 2001 +From: Michal Schmidt +Date: Mon, 21 May 2012 12:54:43 +0200 +Subject: [PATCH] systemctl: drop useless DBus calls from 'systemctl show + foo.service' + +systemctl called LoadUnit, GetUnit, GetAll in this order to get the properties. + +It is useless to load units explicitly, because it won't ensure anything. The +unit may be freed immediately by the garbage collector. + +It is unnecessary to call GetUnit, because systemctl can easily translate the +unit name to DBus path by itself. + +GetAll will load the unit if necessary. +(cherry picked from commit a223b325b409b325f4c2c2e11268596edd842631) +--- + src/systemctl/systemctl.c | 210 +++++++++++++++++---------------------------- + 1 file changed, 80 insertions(+), 130 deletions(-) + +diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c +index 6dad623..484f7c3 100644 +--- a/src/systemctl/systemctl.c ++++ b/src/systemctl/systemctl.c +@@ -2935,18 +2935,70 @@ finish: + return r; + } + +-static int show(DBusConnection *bus, char **args) { ++static int show_one_by_pid(const char *verb, DBusConnection *bus, uint32_t pid, bool *new_line) { + DBusMessage *m = NULL, *reply = NULL; +- int r, ret = 0; ++ const char *path = NULL; + DBusError error; ++ int r; ++ ++ dbus_error_init(&error); ++ ++ m = dbus_message_new_method_call( ++ "org.freedesktop.systemd1", ++ "/org/freedesktop/systemd1", ++ "org.freedesktop.systemd1.Manager", ++ "GetUnitByPID"); ++ if (!m) { ++ log_error("Could not allocate message."); ++ r = -ENOMEM; ++ goto finish; ++ } ++ ++ if (!dbus_message_append_args(m, ++ DBUS_TYPE_UINT32, &pid, ++ DBUS_TYPE_INVALID)) { ++ log_error("Could not append arguments to message."); ++ r = -ENOMEM; ++ goto finish; ++ } ++ ++ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error); ++ if (!reply) { ++ log_error("Failed to issue method call: %s", bus_error_message(&error)); ++ r = -EIO; ++ goto finish; ++ } ++ ++ if (!dbus_message_get_args(reply, &error, ++ DBUS_TYPE_OBJECT_PATH, &path, ++ DBUS_TYPE_INVALID)) { ++ log_error("Failed to parse reply: %s", bus_error_message(&error)); ++ r = -EIO; ++ goto finish; ++ } ++ ++ r = show_one(verb, bus, path, false, new_line); ++ ++finish: ++ if (m) ++ dbus_message_unref(m); ++ ++ if (reply) ++ dbus_message_unref(reply); ++ ++ dbus_error_free(&error); ++ ++ return r; ++} ++ ++static int show(DBusConnection *bus, char **args) { ++ int r, ret = 0; + bool show_properties, new_line = false; + char **name; + + assert(bus); + assert(args); + +- dbus_error_init(&error); +- + show_properties = !streq(args[0], "status"); + + if (show_properties) +@@ -2956,157 +3008,55 @@ static int show(DBusConnection *bus, char **args) { + /* If not argument is specified inspect the manager + * itself */ + +- ret = show_one(args[0], bus, "/org/freedesktop/systemd1", show_properties, &new_line); +- goto finish; ++ return show_one(args[0], bus, "/org/freedesktop/systemd1", show_properties, &new_line); + } + + STRV_FOREACH(name, args+1) { +- const char *path = NULL; + uint32_t id; + + if (safe_atou32(*name, &id) < 0) { + + /* Interpret as unit name */ + +- if (!(m = dbus_message_new_method_call( +- "org.freedesktop.systemd1", +- "/org/freedesktop/systemd1", +- "org.freedesktop.systemd1.Manager", +- "LoadUnit"))) { +- log_error("Could not allocate message."); +- ret = -ENOMEM; +- goto finish; +- } +- +- if (!dbus_message_append_args(m, +- DBUS_TYPE_STRING, name, +- DBUS_TYPE_INVALID)) { +- log_error("Could not append arguments to message."); +- ret = -ENOMEM; +- goto finish; +- } +- +- if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { +- +- if (!dbus_error_has_name(&error, DBUS_ERROR_ACCESS_DENIED)) { +- log_error("Failed to issue method call: %s", bus_error_message(&error)); +- ret = -EIO; +- goto finish; +- } +- +- dbus_error_free(&error); +- +- dbus_message_unref(m); +- if (!(m = dbus_message_new_method_call( +- "org.freedesktop.systemd1", +- "/org/freedesktop/systemd1", +- "org.freedesktop.systemd1.Manager", +- "GetUnit"))) { +- log_error("Could not allocate message."); +- ret = -ENOMEM; +- goto finish; +- } ++ char *e, *p; ++ e = bus_path_escape(*name); ++ if (!e) ++ return -ENOMEM; ++ p = strappend("/org/freedesktop/systemd1/unit/", e); ++ free(e); ++ if (!p) ++ return -ENOMEM; + +- if (!dbus_message_append_args(m, +- DBUS_TYPE_STRING, name, +- DBUS_TYPE_INVALID)) { +- log_error("Could not append arguments to message."); +- ret = -ENOMEM; +- goto finish; +- } ++ r = show_one(args[0], bus, p, show_properties, &new_line); ++ free(p); + +- if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { +- log_error("Failed to issue method call: %s", bus_error_message(&error)); +- +- if (dbus_error_has_name(&error, BUS_ERROR_NO_SUCH_UNIT)) +- ret = 4; /* According to LSB: "program or service status is unknown" */ +- else +- ret = -EIO; +- goto finish; +- } +- } ++ if (r != 0) ++ ret = r; + + } else if (show_properties) { + + /* Interpret as job id */ + +- if (!(m = dbus_message_new_method_call( +- "org.freedesktop.systemd1", +- "/org/freedesktop/systemd1", +- "org.freedesktop.systemd1.Manager", +- "GetJob"))) { +- log_error("Could not allocate message."); +- ret = -ENOMEM; +- goto finish; +- } ++ char *p; ++ if (asprintf(&p, "/org/freedesktop/systemd1/job/%u", id) < 0) ++ return -ENOMEM; + +- if (!dbus_message_append_args(m, +- DBUS_TYPE_UINT32, &id, +- DBUS_TYPE_INVALID)) { +- log_error("Could not append arguments to message."); +- ret = -ENOMEM; +- goto finish; +- } ++ r = show_one(args[0], bus, p, show_properties, &new_line); ++ free(p); ++ ++ if (r != 0) ++ ret = r; + +- if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { +- log_error("Failed to issue method call: %s", bus_error_message(&error)); +- ret = -EIO; +- goto finish; +- } + } else { + + /* Interpret as PID */ + +- if (!(m = dbus_message_new_method_call( +- "org.freedesktop.systemd1", +- "/org/freedesktop/systemd1", +- "org.freedesktop.systemd1.Manager", +- "GetUnitByPID"))) { +- log_error("Could not allocate message."); +- ret = -ENOMEM; +- goto finish; +- } +- +- if (!dbus_message_append_args(m, +- DBUS_TYPE_UINT32, &id, +- DBUS_TYPE_INVALID)) { +- log_error("Could not append arguments to message."); +- ret = -ENOMEM; +- goto finish; +- } +- +- if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { +- log_error("Failed to issue method call: %s", bus_error_message(&error)); +- ret = -EIO; +- goto finish; +- } ++ r = show_one_by_pid(args[0], bus, id, &new_line); ++ if (r != 0) ++ ret = r; + } +- +- if (!dbus_message_get_args(reply, &error, +- DBUS_TYPE_OBJECT_PATH, &path, +- DBUS_TYPE_INVALID)) { +- log_error("Failed to parse reply: %s", bus_error_message(&error)); +- ret = -EIO; +- goto finish; +- } +- +- if ((r = show_one(args[0], bus, path, show_properties, &new_line)) != 0) +- ret = r; +- +- dbus_message_unref(m); +- dbus_message_unref(reply); +- m = reply = NULL; + } + +-finish: +- if (m) +- dbus_message_unref(m); +- +- if (reply) +- dbus_message_unref(reply); +- +- dbus_error_free(&error); +- + return ret; + } + diff --git a/systemd.spec b/systemd.spec index 871cb45..a8b21c9 100644 --- a/systemd.spec +++ b/systemd.spec @@ -3,7 +3,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 44 -Release: 9%{?gitcommit:.git%{gitcommit}}%{?dist} +Release: 10%{?gitcommit:.git%{gitcommit}}%{?dist} License: GPLv2+ Group: System Environment/Base Summary: A System and Service Manager @@ -354,6 +354,12 @@ Patch0291: 0291-delta-add-preset-dirs.patch Patch0292: 0292-delta-Support-filtering-what-type-of-deltas-to-show.patch Patch0293: 0293-delta-enums-are-much-cooler-than-defines.patch Patch0294: 0294-F17-units-do-not-use-Type-idle-yet.patch +Patch0295: 0295-delta-use-same-nomenclature-for-equivalent-and-redir.patch +Patch0296: 0296-delta-introduce-arg_flags-field-to-follow-our-usual-.patch +Patch0297: 0297-delta-don-t-highlight-unchanged-files.patch +Patch0298: 0298-delta-drop-PHP-ism.patch +Patch0299: 0299-dbus-unit-always-load-the-unit-before-handling-a-mes.patch +Patch0300: 0300-systemctl-drop-useless-DBus-calls-from-systemctl-sho.patch # For sysvinit tools Obsoletes: SysVinit < 2.86-24, sysvinit < 2.86-24 @@ -730,6 +736,10 @@ mv /etc/systemd/system/default.target.save /etc/systemd/system/default.target >/ %{_bindir}/systemd-analyze %changelog +* Mon May 21 2012 Michal Schmidt - 44-10 +- Fix another cause of "Failed to issue method call" (#814966) +- minor systemd-delta updates + * Fri May 18 2012 Michal Schmidt - 44-9 - Applied most of the patches from current upstream, while avoiding incompatible changes.