]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/unit: re-find dropin paths of a unit after writting settings
authorHeran Yang <heran55@126.com>
Fri, 16 Jan 2026 12:27:19 +0000 (20:27 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 18 Jan 2026 05:14:24 +0000 (14:14 +0900)
Fixes: ab932a622d57 ("core: simplify unit_need_daemon_reload() a bit")
Fixes #35710

Co-authored-by: Jian Wen <wenjianhn@gmail.com>
src/core/unit.c
test/units/TEST-15-DROPIN.sh

index 5494d718e65b6d6e8c06d1aa9d7bb96a5ac00acc..535839e15c42242cb7f4302dc7bfa13e371c317b 100644 (file)
@@ -4748,12 +4748,11 @@ int unit_write_setting(Unit *u, UnitWriteFlags flags, const char *name, const ch
         if (r < 0)
                 return r;
 
-        r = strv_push(&u->dropin_paths, q);
+        _cleanup_strv_free_ char **dropins = NULL;
+        r = unit_find_dropin_paths(u, /* use_unit_path_cache= */ true, &dropins);
         if (r < 0)
                 return r;
-        q = NULL;
-
-        strv_uniq(u->dropin_paths);
+        strv_free_and_replace(u->dropin_paths, dropins);
 
         u->dropin_mtime = now(CLOCK_REALTIME);
 
index dd850f41e1f95d00b10af0035857a6d925b4fa32..e056786910d860e0c14054aa8fd4247665728abb 100755 (executable)
@@ -712,6 +712,17 @@ EOF
     clear_units test15-a.service
 }
 
+testcase_order_dropin_paths_set_property() {
+    # For issue #35710.
+    echo "Testing the order of dropin paths that are created by set-property"
+
+    create_service test15-a
+    systemctl set-property test15-a DevicePolicy=strict DeviceAllow="char-* m"
+    check_ok test15-a NeedDaemonReload no
+
+    clear_units test15-a.service
+}
+
 run_testcases
 
 touch /testok