mirror of
https://github.com/troglobit/finit.git
synced 2026-10-18 10:59:34 +00:00
Follow-up to f4a0b99: track modifications of service env: files
Add support for monitoring environment files for services declared with the `env:[-]/path/to/file` option. The default path to such files has been chosen to follow Debian and Buildroot /etc/default/* Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
7ef25abecf
commit
74d3194775
4 files changed
+55
-7
No files matched your search
+14
-6
@@ -772,13 +772,13 @@ static void drop_changes(void)
|
||||
|
||||
static int do_change(char *dir, char *name, uint32_t mask)
|
||||
{
|
||||
char path[strlen(dir) + strlen(name) + 2];
|
||||
char fn[strlen(dir) + strlen(name) + 2];
|
||||
struct conf_change *node;
|
||||
|
||||
snprintf(path, sizeof(path), "%s%s", dir, name);
|
||||
_d("path: %s", path);
|
||||
snprintf(fn, sizeof(fn), "%s%s%s", dir, fisslashdir(dir) ? "" : "/", name);
|
||||
_d("path: %s mask: %08x", fn, mask);
|
||||
|
||||
node = conf_find(path);
|
||||
node = conf_find(fn);
|
||||
if (mask & (IN_DELETE | IN_MOVED_FROM)) {
|
||||
drop_change(node);
|
||||
return 0;
|
||||
@@ -793,13 +793,13 @@ static int do_change(char *dir, char *name, uint32_t mask)
|
||||
if (!node)
|
||||
return 1;
|
||||
|
||||
node->name = strdup(path);
|
||||
node->name = strdup(fn);
|
||||
if (!node->name) {
|
||||
free(node);
|
||||
return 1;
|
||||
}
|
||||
|
||||
_d("Event registered for %s, mask 0x%x", path, mask);
|
||||
_d("Event registered for %s, mask 0x%x", fn, mask);
|
||||
TAILQ_INSERT_HEAD(&conf_change_list, node, link);
|
||||
|
||||
return 0;
|
||||
@@ -881,6 +881,14 @@ int conf_monitor(void)
|
||||
rc += iwatch_add(&iw_conf, FINIT_RCSD "/enabled/", IN_ONLYDIR | IN_DONT_FOLLOW);
|
||||
rc += iwatch_add(&iw_conf, FINIT_CONF, 0);
|
||||
|
||||
/*
|
||||
* Systems with /etc/default, or similar, can also monitor changes
|
||||
* in env files sourced by .conf files (above)
|
||||
*/
|
||||
#ifdef FINIT_SYSCONFIG
|
||||
rc += iwatch_add(&iw_conf, FINIT_SYSCONFIG, IN_ONLYDIR);
|
||||
#endif
|
||||
|
||||
return rc + conf_reload();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1116,7 +1116,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
memcpy(svc->rlimit, rlimit, sizeof(svc->rlimit));
|
||||
|
||||
/* New, recently modified or unchanged ... used on reload. */
|
||||
if (file && conf_changed(file))
|
||||
if ((file && conf_changed(file)) || conf_changed(svc_getenv(svc)))
|
||||
svc_mark_dirty(svc);
|
||||
else
|
||||
svc_mark_clean(svc);
|
||||
|
||||
Reference in new issue
Block a user