dryang / rpms / systemd

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