summaryrefslogtreecommitdiffstats
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-10-17 07:15:03 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2016-10-17 07:15:03 +0200
commitba25d39e449347952522162c3fa110b04308e28c (patch)
tree4462c55b45f8b7e36248cf14e550c6e5f58b0a6e /src/core/unit.c
parentMerge pull request #4391 from keszybz/treewide-macros (diff)
downloadsystemd-ba25d39e449347952522162c3fa110b04308e28c.tar.xz
systemd-ba25d39e449347952522162c3fa110b04308e28c.zip
pid1: do not use mtime==0 as sign of masking (#4388)
It is allowed for unit files to have an mtime==0, so instead of assuming that any file that had mtime==0 was masked, use the load_state to filter masked units. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1384150.
Diffstat (limited to '')
-rw-r--r--src/core/unit.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index a6b8ecdcb7..b24ca5aed8 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3053,7 +3053,7 @@ int unit_coldplug(Unit *u) {
return r;
}
-static bool fragment_mtime_newer(const char *path, usec_t mtime) {
+static bool fragment_mtime_newer(const char *path, usec_t mtime, bool path_masked) {
struct stat st;
if (!path)
@@ -3063,12 +3063,12 @@ static bool fragment_mtime_newer(const char *path, usec_t mtime) {
/* What, cannot access this anymore? */
return true;
- if (mtime > 0)
+ if (path_masked)
+ /* For masked files check if they are still so */
+ return !null_or_empty(&st);
+ else
/* For non-empty files check the mtime */
return timespec_load(&st.st_mtim) > mtime;
- else if (!null_or_empty(&st))
- /* For masked files check if they are still so */
- return true;
return false;
}
@@ -3079,18 +3079,22 @@ bool unit_need_daemon_reload(Unit *u) {
assert(u);
- if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime))
+ /* For unit files, we allow masking… */
+ if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime,
+ u->load_state == UNIT_MASKED))
return true;
- if (fragment_mtime_newer(u->source_path, u->source_mtime))
+ /* Source paths should not be masked… */
+ if (fragment_mtime_newer(u->source_path, u->source_mtime, false))
return true;
(void) unit_find_dropin_paths(u, &t);
if (!strv_equal(u->dropin_paths, t))
return true;
+ /* … any drop-ins that are masked are simply omitted from the list. */
STRV_FOREACH(path, u->dropin_paths)
- if (fragment_mtime_newer(*path, u->dropin_mtime))
+ if (fragment_mtime_newer(*path, u->dropin_mtime, false))
return true;
return false;