Pablo Greco 48fc63
From 50a411f4b70ea27e2fd33c19394030e57a4a1280 Mon Sep 17 00:00:00 2001
Pablo Greco 48fc63
From: Jan Synacek <jsynacek@redhat.com>
Pablo Greco 48fc63
Date: Tue, 11 Dec 2018 13:11:25 +0100
Pablo Greco 48fc63
Subject: [PATCH] systemctl: Allow 'edit' and 'cat' on unloaded units
Pablo Greco 48fc63
Pablo Greco 48fc63
Don't fail if the unit has a LoadError; otherwise `systemctl edit` cannot be
Pablo Greco 48fc63
used to correct the error (e.g. multiple "ExecStart=" lines).
Pablo Greco 48fc63
Pablo Greco 48fc63
Remove file changed warning so cat output isn't interspersed with log messages.
Pablo Greco 48fc63
Pablo Greco 48fc63
Fixes #829
Pablo Greco 48fc63
Pablo Greco 48fc63
(cherry picked from commit 1e524ec6e2031629fec27906423619e3403b2f3e)
Pablo Greco 48fc63
Pablo Greco 48fc63
Resolves: #1649518
Pablo Greco 48fc63
---
Pablo Greco 48fc63
 src/systemctl/systemctl.c | 30 ------------------------------
Pablo Greco 48fc63
 1 file changed, 30 deletions(-)
Pablo Greco 48fc63
Pablo Greco 48fc63
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
Pablo Greco 48fc63
index b1862b5676..f31137787a 100644
Pablo Greco 48fc63
--- a/src/systemctl/systemctl.c
Pablo Greco 48fc63
+++ b/src/systemctl/systemctl.c
Pablo Greco 48fc63
@@ -2311,42 +2311,12 @@ static int unit_find_paths(sd_bus *bus,
Pablo Greco 48fc63
 
Pablo Greco 48fc63
         if (!avoid_bus_cache && !unit_name_is_template(unit_name)) {
Pablo Greco 48fc63
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
Pablo Greco 48fc63
-                _cleanup_bus_message_unref_ sd_bus_message *unit_load_error = NULL;
Pablo Greco 48fc63
                 _cleanup_free_ char *unit = NULL;
Pablo Greco 48fc63
-                char *unit_load_error_name, *unit_load_error_message;
Pablo Greco 48fc63
 
Pablo Greco 48fc63
                 unit = unit_dbus_path_from_name(unit_name);
Pablo Greco 48fc63
                 if (!unit)
Pablo Greco 48fc63
                         return log_oom();
Pablo Greco 48fc63
 
Pablo Greco 48fc63
-                if (need_daemon_reload(bus, unit_name) > 0)
Pablo Greco 48fc63
-                        warn_unit_file_changed(unit_name);
Pablo Greco 48fc63
-
Pablo Greco 48fc63
-                r = sd_bus_get_property(
Pablo Greco 48fc63
-                                bus,
Pablo Greco 48fc63
-                                "org.freedesktop.systemd1",
Pablo Greco 48fc63
-                                unit,
Pablo Greco 48fc63
-                                "org.freedesktop.systemd1.Unit",
Pablo Greco 48fc63
-                                "LoadError",
Pablo Greco 48fc63
-                                &error,
Pablo Greco 48fc63
-                                &unit_load_error,
Pablo Greco 48fc63
-                                "(ss)");
Pablo Greco 48fc63
-                if (r < 0)
Pablo Greco 48fc63
-                        return log_error_errno(r, "Failed to get LoadError: %s", bus_error_message(&error, r));
Pablo Greco 48fc63
-
Pablo Greco 48fc63
-                r = sd_bus_message_read(
Pablo Greco 48fc63
-                                unit_load_error,
Pablo Greco 48fc63
-                                "(ss)",
Pablo Greco 48fc63
-                                &unit_load_error_name,
Pablo Greco 48fc63
-                                &unit_load_error_message);
Pablo Greco 48fc63
-                if (r < 0)
Pablo Greco 48fc63
-                        return bus_log_parse_error(r);
Pablo Greco 48fc63
-
Pablo Greco 48fc63
-                if (!isempty(unit_load_error_name)) {
Pablo Greco 48fc63
-                        log_error("Unit %s is not loaded: %s", unit_name, unit_load_error_message);
Pablo Greco 48fc63
-                        return 0;
Pablo Greco 48fc63
-                }
Pablo Greco 48fc63
-
Pablo Greco 48fc63
                 r = sd_bus_get_property_string(
Pablo Greco 48fc63
                                 bus,
Pablo Greco 48fc63
                                 "org.freedesktop.systemd1",