From 4e918b7253bd541a76d3d9641d0be86dd8e132d3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 13 Feb 2014 14:59:56 +0100 Subject: everywhere: always use O_CLOEXEC where it makes sense Signed-off-by: Anthony G. Basile --- src/udev/udev-builtin-btrfs.c | 5 ++--- src/udev/udevadm-trigger.c | 2 +- src/udev/udevd.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/udev') diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c index f7bea69b26..2baafe6131 100644 --- a/src/udev/udev-builtin-btrfs.c +++ b/src/udev/udev-builtin-btrfs.c @@ -38,19 +38,18 @@ struct btrfs_ioctl_vol_args { static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) { struct btrfs_ioctl_vol_args args; - int fd; + _cleanup_close_ int fd = -1; int err; if (argc != 3 || !streq(argv[1], "ready")) return EXIT_FAILURE; - fd = open("/dev/btrfs-control", O_RDWR); + fd = open("/dev/btrfs-control", O_RDWR|O_CLOEXEC); if (fd < 0) return EXIT_FAILURE; strscpy(args.name, sizeof(args.name), argv[2]); err = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args); - close(fd); if (err < 0) return EXIT_FAILURE; diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 087ee4bfae..0ee27bb408 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -51,7 +51,7 @@ static void exec_list(struct udev_enumerate *udev_enumerate, const char *action) if (dry_run) continue; strscpyl(filename, sizeof(filename), udev_list_entry_get_name(entry), "/uevent", NULL); - fd = open(filename, O_WRONLY); + fd = open(filename, O_WRONLY|O_CLOEXEC); if (fd < 0) continue; if (write(fd, action, strlen(action)) < 0) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index d9d3d85f8b..850e4f5ef6 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -734,7 +734,7 @@ static int handle_inotify(struct udev *udev) log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev)); strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL); - fd = open(filename, O_WRONLY); + fd = open(filename, O_WRONLY|O_CLOEXEC); if (fd >= 0) { if (write(fd, "change", 6) < 0) log_debug("error writing uevent: %m"); -- cgit v1.2.3-54-g00ecf