mirror of
https://github.com/troglobit/finit.git
synced 2026-10-22 11:36:07 +00:00
Fix #61: Reassert net/* conditions after initctl reload
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
0cccc629bf
commit
044ded3045
3 files changed
+38
No files matched your search
@@ -21,6 +21,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ftw.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <lite/lite.h>
|
#include <lite/lite.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -124,6 +125,34 @@ void cond_reload(void)
|
|||||||
cond_update(NULL);
|
cond_update(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int reassert(const char *fpath, const struct stat *UNUSED(sb), int tflg, struct FTW *ftw)
|
||||||
|
{
|
||||||
|
char *nm;
|
||||||
|
|
||||||
|
if (ftw->level == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (tflg != FTW_F)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
nm = (char *)fpath + sizeof(COND_PATH);
|
||||||
|
_d("Reasserting %s => %s", fpath, nm);
|
||||||
|
cond_set(nm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Used only by netlink plugin atm.
|
||||||
|
* type: is a one of svc/, net/, etc.
|
||||||
|
*/
|
||||||
|
void cond_reassert(const char *type)
|
||||||
|
{
|
||||||
|
_d("%s", type);
|
||||||
|
nftw(cond_path(type), reassert, 20, FTW_DEPTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ int cond_set_path(const char *path, enum cond_state new);
|
|||||||
void cond_set (const char *name);
|
void cond_set (const char *name);
|
||||||
void cond_clear (const char *name);
|
void cond_clear (const char *name);
|
||||||
void cond_reload (void);
|
void cond_reload (void);
|
||||||
|
void cond_reassert(const char *pat);
|
||||||
|
|
||||||
#endif /* FINIT_COND_H_ */
|
#endif /* FINIT_COND_H_ */
|
||||||
|
|
||||||
|
|||||||
@@ -186,8 +186,16 @@ static void nl_callback(void *UNUSED(arg), int sd, int UNUSED(events))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nl_reconf(void *_null)
|
||||||
|
{
|
||||||
|
(void)_null;
|
||||||
|
|
||||||
|
cond_reassert("net/");
|
||||||
|
}
|
||||||
|
|
||||||
static plugin_t plugin = {
|
static plugin_t plugin = {
|
||||||
.name = __FILE__,
|
.name = __FILE__,
|
||||||
|
.hook[HOOK_SVC_RECONF] = { .cb = nl_reconf },
|
||||||
.io = {
|
.io = {
|
||||||
.cb = nl_callback,
|
.cb = nl_callback,
|
||||||
.flags = PLUGIN_IO_READ,
|
.flags = PLUGIN_IO_READ,
|
||||||
|
|||||||
Reference in new issue
Block a user