summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-17 10:16:44 -0400
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:57 +0200
commitb95d5ee7e9a86cd3cd93ae2be366ddc64299f043 (patch)
treec515fd8d7cfdeeba1a4784d6bb2ac88cd8db0954 /src/shared
parenta2b4b715bfdf3b64037a1a34f6682c7575e6aeca (diff)
shared/install,systemctl,core: report offending file on installation error
Fixes #2191: $ systemctl --root=/ enable sddm Created symlink /etc/elogind/system/display-manager.service, pointing to /usr/lib/elogind/system/sddm.service. $ sudo build/systemctl --root=/ enable gdm Failed to enable unit, file /etc/elogind/system/display-manager.service already exists and is a symlink to /usr/lib/elogind/system/sddm.service. $ sudo build/systemctl --root= enable sddm $ sudo build/systemctl --root= enable gdm Failed to enable unit: File /etc/elogind/system/display-manager.service already exists and is a symlink to /usr/lib/elogind/system/sddm.service. (I tried a few different approaches to pass the error information back to the caller. Adding a new parameter to hold the error results in a gigantic patch and a lot of hassle to pass the args arounds. Adding this information to the changes array is straightforward and can be more easily extended in the future.) In case local installation is performed, the full set of errors can be reported and we do that. When running over dbus, only the first error is reported.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-util.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 800657ccd..0ab575506 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -2203,20 +2203,16 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un
return bus_log_parse_error(r);
while ((r = sd_bus_message_read(m, "(sss)", &type, &path, &source)) > 0) {
- if (!quiet) {
- if (streq(type, "symlink"))
- log_info("Created symlink from %s to %s.", path, source);
- else if (streq(type, "unlink"))
- log_info("Removed symlink %s.", path);
- else if (streq(type, "masked"))
- log_info("Unit %s is masked, ignoring.", path);
- else
- log_notice("Manager reported unknown change type \"%s\" for %s.", type, path);
+ /* We expect only "success" changes to be sent over the bus.
+ Hence, reject anything negative. */
+ UnitFileChangeType ch = unit_file_change_type_from_string(type);
+
+ if (ch < 0) {
+ log_notice("Manager reported unknown change type \"%s\" for path \"%s\", ignoring.", type, path);
+ continue;
}
- r = unit_file_changes_add(changes, n_changes,
- unit_file_change_type_from_string(type),
- path, source);
+ r = unit_file_changes_add(changes, n_changes, ch, path, source);
if (r < 0)
return r;
}
@@ -2227,6 +2223,7 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un
if (r < 0)
return bus_log_parse_error(r);
+ unit_file_dump_changes(0, NULL, *changes, *n_changes, false);
return 0;
}