Skip to content

Commit

Permalink
Fix #37: Use _PATH_VARDB for genid, unless old compat exists
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Sep 29, 2020
1 parent d3e9e66 commit 5438ff3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,22 @@ static void do_randomize(void)
srandom(seed);
}

/*
* _PATH_MROUTED_GENID is the configurable fallback and old default used
* by mrouted, which does not comply with FHS. We only read that, if it
* exists, otherwise we use the system _PATH_VARDB, which works on all
* *BSD and GLIBC based Linux systems. Some Linux systms don't have the
* correct FHS /var/lib/misc for that define, so we check for that too.
*/
static FILE *fopen_genid(char *mode)
{
char fn[80];

snprintf(fn, sizeof(fn), _PATH_MROUTED_GENID);
if (access(fn, R_OK | W_OK)) {
if (!access(_PATH_VARDB, W_OK))
snprintf(fn, sizeof(fn), "%s/mrouted.genid", _PATH_VARDB);
}

return fopen(fn, mode);
}
Expand Down

0 comments on commit 5438ff3

Please sign in to comment.