mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00:00
plugins: sys: drop conditions not affecting any svc_t
- Fix bug when calling sys_update_conds() when dir already exists and we're not being called from the scandir() handler. I.e., every time but the first for each new condition sub-family - Drop sys conditions that don't affect any svc_t. This may seem counterintuitive, and we should probably not use oneshot conds, but if we leave these conds asserted they may cause inadvertent trigger if a finit.conf is loaded which ha this sys cond. E.g., if ctrlaltdel is asserted and we enable a task in finit.conf and call `initctl reload`, the task would start immediately, even though ctrl-alt-del may have been pressed a week ago Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
cdc8873f5b
commit
e2ef6e9c34
1 file changed
+16
-2
+16
-2
@@ -41,17 +41,31 @@ static int sys_add_path(struct iwatch *iw, char *path)
|
|||||||
return iwatch_add(iw, path, IN_ONLYDIR | IN_CLOSE_WRITE);
|
return iwatch_add(iw, path, IN_ONLYDIR | IN_CLOSE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* unlink conditions with no active task/service, otherwise they may
|
||||||
|
* trigger inadvertently when calling `initctl reload` to activate
|
||||||
|
* a new configuration.
|
||||||
|
*/
|
||||||
static void sys_update_conds(char *dir, char *name, uint32_t mask)
|
static void sys_update_conds(char *dir, char *name, uint32_t mask)
|
||||||
{
|
{
|
||||||
|
char path[256];
|
||||||
char *cond;
|
char *cond;
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
cond = strstr(name, COND_BASE);
|
ptr = strrchr(name, '/');
|
||||||
|
if (ptr)
|
||||||
|
snprintf(path, sizeof(path), "%s/%s", dir, ++ptr);
|
||||||
|
else
|
||||||
|
snprintf(path, sizeof(path), "%s/%s", dir, name);
|
||||||
|
|
||||||
|
cond = strstr(path, COND_BASE);
|
||||||
if (!cond)
|
if (!cond)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cond += strlen(COND_BASE) + 1;
|
cond += strlen(COND_BASE) + 1;
|
||||||
_d("cond: %s set: %d", cond, mask & IN_CREATE ? 1 : 0);
|
_d("cond: %s set: %d", cond, mask & IN_CREATE ? 1 : 0);
|
||||||
cond_update(cond);
|
if (!cond_update(cond))
|
||||||
|
unlink(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* synthesize events in case of new run dirs */
|
/* synthesize events in case of new run dirs */
|
||||||
|
|||||||
Reference in new issue
Block a user