cond: don't rely on mtime for condition management

TIL, using mtimes for tracking event orderings is a monumentally bad
idea (queue the nodding UNIX-beards). Mtimes are in wallclock time which
is not necessarily monotonically increasing. A user may adjust the time,
an NTP daemon will continously tune the clock and so on.

Instead, store an explicit generation number in each condition file,
which will be monotonically increased by finit on each reconf.
This commit is contained in:
Tobias Waldekranz committed 2017-12-21 11:10:47 +01:00
1 parent d6b2ac94dd
commit b0663d04e4
4 files changed
+76 -18

No files matched your search

+4
View File
@@ -36,6 +36,7 @@
#include <lite/lite.h>
#include "finit.h"
#include "cond.h"
#include "conf.h"
#include "helpers.h"
#include "private.h"
@@ -475,6 +476,9 @@ int main(int argc, char* argv[])
/* Base FS up, enable standard SysV init signals */
sig_setup(&loop);
/* Bootstrap conditions */
cond_init();
/*
* Reload all *.conf in /etc/finit.d, the mount command (above)
* may have brought in new files (overlayfs).