diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-04-06 10:18:41 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-04-06 07:23:35 -0700 |
commit | 4b09a2fc4383f191d96a8d6134b95a4b84aef931 (patch) | |
tree | d1e4d4d29a4e147b296de120aa3ec5ddccd59517 /udev/udev-watch.c | |
parent | 52761bb0a99cb80ccb19c9edf23963fdad67060d (diff) |
avoid leaking netlink socket fd to external programs
The netlink socket is now used by udev event processes. We should take
care not to pass it to the programs they execute. This is the same way
the inotify fd was handled.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Diffstat (limited to 'udev/udev-watch.c')
-rw-r--r-- | udev/udev-watch.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/udev/udev-watch.c b/udev/udev-watch.c index e2c096af0f..d333476346 100644 --- a/udev/udev-watch.c +++ b/udev/udev-watch.c @@ -41,16 +41,9 @@ int inotify_fd = -1; void udev_watch_init(struct udev *udev) { inotify_fd = inotify_init(); - if (inotify_fd >= 0) { - int flags; - - flags = fcntl(inotify_fd, F_GETFD); - if (flags < 0) - flags = FD_CLOEXEC; - else - flags |= FD_CLOEXEC; - fcntl(inotify_fd, F_SETFD, flags); - } else if (errno == ENOSYS) + if (inotify_fd >= 0) + util_set_fd_cloexec(inotify_fd); + else if (errno == ENOSYS) info(udev, "unable to use inotify, udevd will not monitor rule files changes\n"); else err(udev, "inotify_init failed: %m\n"); |