Blame SOURCES/0624-core-scope-fix-missing-fragment_path.patch

17b0f1
From f838bf376249b68205641d1736da2622c0279ed2 Mon Sep 17 00:00:00 2001
17b0f1
From: chenglin130 <cheng.lin130@zte.com.cn>
17b0f1
Date: Sat, 20 Jan 2018 17:45:27 +0800
17b0f1
Subject: [PATCH] core:scope: fix missing fragment_path
17b0f1
17b0f1
fragment_path in struct unit is a record of unit file, which will
17b0f1
be deleted (unlink) in unit_free().
17b0f1
17b0f1
After a daemon-reload process, the u->fragment_path of scope unit
17b0f1
will be missing (NULL). Then, the discarded session scope unit file
17b0f1
will be redundant until reboot.
17b0f1
17b0f1
Steps to Reproduce problem:
17b0f1
1. ssh access and login
17b0f1
2. systemctl daemon-reload
17b0f1
3. ssh logout
17b0f1
4. discarded session-xxx.scope file will be found in /run/systemd/system/
17b0f1
17b0f1
So in a daemon-reload case, scope_load() need unit_load_fragment() to reload
17b0f1
u->fragment_path.
17b0f1
---
17b0f1
 src/core/load-fragment.c | 5 +++++
17b0f1
 src/core/scope.c         | 4 ++++
17b0f1
 2 files changed, 9 insertions(+)
17b0f1
17b0f1
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
17b0f1
index da58bcc5c9..f3d0851fe2 100644
17b0f1
--- a/src/core/load-fragment.c
17b0f1
+++ b/src/core/load-fragment.c
17b0f1
@@ -3950,6 +3950,11 @@ int unit_load_fragment(Unit *u) {
17b0f1
         assert(u->load_state == UNIT_STUB);
17b0f1
         assert(u->id);
17b0f1
 
17b0f1
+        if (u->transient && u->fragment_path) {
17b0f1
+                u->load_state = UNIT_LOADED;
17b0f1
+                return 0;
17b0f1
+        }
17b0f1
+
17b0f1
         /* First, try to find the unit under its id. We always look
17b0f1
          * for unit files in the default directories, to make it easy
17b0f1
          * to override things by placing things in /etc/systemd/system */
17b0f1
diff --git a/src/core/scope.c b/src/core/scope.c
17b0f1
index ae6614fbf0..29954ba285 100644
17b0f1
--- a/src/core/scope.c
17b0f1
+++ b/src/core/scope.c
17b0f1
@@ -150,6 +150,10 @@ static int scope_load(Unit *u) {
17b0f1
         if (!u->transient && UNIT(s)->manager->n_reloading <= 0)
17b0f1
                 return -ENOENT;
17b0f1
 
17b0f1
+        r = unit_load_fragment(u);
17b0f1
+        if (r < 0)
17b0f1
+                return r;
17b0f1
+
17b0f1
         u->load_state = UNIT_LOADED;
17b0f1
 
17b0f1
         r = unit_load_dropin(u);