mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00: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:
1 parent
32d9afc7bb
commit
f9783b4b41
1 file changed
+15
-2
+15
-2
@@ -112,10 +112,23 @@ static void pidfile_reconf(void *arg)
|
|||||||
|
|
||||||
static void pidfile_init(void *arg)
|
static void pidfile_init(void *arg)
|
||||||
{
|
{
|
||||||
|
char *path;
|
||||||
struct context *ctx = arg;
|
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) {
|
if (ctx->wd < 0) {
|
||||||
_pe("inotify_add_watch()");
|
_pe("inotify_add_watch()");
|
||||||
close(ctx->fd);
|
close(ctx->fd);
|
||||||
|
|||||||
Reference in new issue
Block a user