mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +00:00
Fix bad string pointer arithmetic in condition reassert
On `initctl reload` we reassert conditions, i.e. bring each still viable condition back in sync with the new reconf generation. This patch fixes an assumption in the reassert() callback that caused the following nasty transformation: /run/finit/cond/net/lo/up --> /run/finit/cond/lo/up The transformation was caused by the reassert() code assuming a /var/run prefix rather than /run. We must check the actual runpath, or like this patch does, use a path neutral way to find the base condition string. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
5f818f917e
commit
6e017025aa
2 files changed
+9
-2
No files matched your search
+7
-1
@@ -206,7 +206,13 @@ static int reassert(const char *fpath, const struct stat *sb, int tflg, struct F
|
||||
if (tflg != FTW_F)
|
||||
return 0;
|
||||
|
||||
nm = (char *)fpath + sizeof(COND_PATH);
|
||||
nm = strstr((char *)fpath, COND_DIR);
|
||||
if (!nm) {
|
||||
_e("Incorrect condtion path %s, cannot reassert", fpath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
nm += sizeof(COND_DIR) + 1;
|
||||
_d("Reasserting %s => %s", fpath, nm);
|
||||
cond_set(nm);
|
||||
|
||||
|
||||
+2
-1
@@ -3,7 +3,8 @@
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#define COND_PATH _PATH_VARRUN "finit/cond"
|
||||
#define COND_DIR "finit/cond"
|
||||
#define COND_PATH _PATH_VARRUN COND_DIR
|
||||
#define COND_RECONF COND_PATH "/reconf"
|
||||
|
||||
typedef enum cond_state {
|
||||
|
||||
Reference in new issue
Block a user