mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
pidfile: Use realpath() to figure out of _PATH_VARRUN is a symlink
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+15
-2
@@ -112,10 +112,23 @@ static void pidfile_reconf(void *arg)
|
||||
|
||||
static void pidfile_init(void *arg)
|
||||
{
|
||||
char *path;
|
||||
struct context *ctx = arg;
|
||||
|
||||
ctx->wd = inotify_add_watch(ctx->fd, _PATH_VARRUN,
|
||||
IN_CREATE | IN_ATTRIB | IN_DELETE | IN_MODIFY);
|
||||
/*
|
||||
* The bootmisc plugin is responsible for setting up /var/run.
|
||||
* and/or /run, with proper symlinks etc. We depend on bootmisc
|
||||
* so it's safe here to query realpath() and set up inotify.
|
||||
*/
|
||||
path = realpath(_PATH_VARRUN, NULL);
|
||||
if (!path) {
|
||||
_pe("Failed ");
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->wd = inotify_add_watch(ctx->fd, path, IN_CREATE | IN_ATTRIB | IN_DELETE | IN_MODIFY);
|
||||
free(path);
|
||||
|
||||
if (ctx->wd < 0) {
|
||||
_pe("inotify_add_watch()");
|
||||
close(ctx->fd);
|
||||
|
||||
Reference in New Issue
Block a user