mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
Add support for static services in /lib/finit/system/*.conf
Slowly migrating away from hard-coded services in plugins. This way it's possible for the user to both inspect and override as needed. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile
|
||||
man/Makefile
|
||||
plugins/Makefile
|
||||
src/Makefile
|
||||
system/Makefile
|
||||
tmpfiles.d/Makefile
|
||||
test/test.env test/Makefile
|
||||
test/lib/Makefile test/src/Makefile])
|
||||
@@ -289,6 +290,10 @@ AC_EXPAND_DIR(finit_tmpfiles, "$pkglibdir/tmpfiles.d")
|
||||
AC_SUBST(finit_tmpfiles)
|
||||
AC_DEFINE_UNQUOTED(FINIT_TMPFILES, "$finit_tmpfiles", [Finit tmpfiles.d/ .conf path])
|
||||
|
||||
AC_EXPAND_DIR(system_path, "$pkglibdir/system")
|
||||
AC_SUBST(system_path)
|
||||
AC_DEFINE_UNQUOTED(FINIT_SYSPATH, "$system_path", [Static services, previously generated at runtime by plugins])
|
||||
|
||||
AC_EXPAND_DIR(rescue_conf, "$pkglibdir/rescue.conf")
|
||||
AC_DEFINE_UNQUOTED(RESCUE_CONF, "$rescue_conf", [Finit rescue mode .conf])
|
||||
AC_EXPAND_DIR(sample_conf, "$pkglibdir/sample.conf")
|
||||
|
||||
+23
-2
@@ -941,9 +941,17 @@ int conf_reload(void)
|
||||
rlim2str(i), lim2str(&global_rlimit[i]));
|
||||
}
|
||||
|
||||
/* Next, read all *.conf in /etc/finit.d/ */
|
||||
/*
|
||||
* Next, read all *.conf in /lib/finit/system and /etc/finit.d/
|
||||
* The system files were previously created at runtime by plugins
|
||||
* but are now regular files that can be overridden by files in
|
||||
* /etc/finit.d -- similar to how tmfiles.d(5) work. E.g., add
|
||||
* an override .conf, or an ignore by symlinking to /dev/null
|
||||
*/
|
||||
snprintf(path, sizeof(path), "%s/*.conf", finit_rcsd);
|
||||
glob(path, 0, NULL, &gl);
|
||||
snprintf(path, sizeof(path), "%s/*.conf", FINIT_SYSPATH);
|
||||
glob(path, GLOB_APPEND, NULL, &gl);
|
||||
snprintf(path, sizeof(path), "%s/enabled/*.conf", finit_rcsd);
|
||||
glob(path, GLOB_APPEND, NULL, &gl);
|
||||
|
||||
@@ -951,7 +959,20 @@ int conf_reload(void)
|
||||
char *path = gl.gl_pathv[i];
|
||||
char *rp = NULL;
|
||||
struct stat st;
|
||||
size_t len;
|
||||
size_t j, len;
|
||||
|
||||
/* check for FINIT_SYSPATH overrides */
|
||||
for (j = i + 1; j < gl.gl_pathc; j++) {
|
||||
if (strncmp(path, FINIT_SYSPATH, strlen(FINIT_SYSPATH)))
|
||||
continue;
|
||||
if (strcmp(basename(path), basename(gl.gl_pathv[j])))
|
||||
continue;
|
||||
path = NULL; /* replacement later in list, skip this */
|
||||
break;
|
||||
}
|
||||
|
||||
if (!path)
|
||||
continue; /* skip, override exists */
|
||||
|
||||
/* Check that it's an actual file ... beyond any symlinks */
|
||||
if (lstat(path, &st)) {
|
||||
|
||||
Reference in New Issue
Block a user