diff --git a/src/core/unit.c b/src/core/unit.c index 5494d718e6..535839e15c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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); diff --git a/test/units/TEST-15-DROPIN.sh b/test/units/TEST-15-DROPIN.sh index dd850f41e1..e056786910 100755 --- a/test/units/TEST-15-DROPIN.sh +++ b/test/units/TEST-15-DROPIN.sh @@ -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