From 8e3e5839a0d65e7a779d4130f9ece02fa88af7e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cristian=20Rodr=C3=ADguez?= Date: Fri, 16 Dec 2011 14:46:52 -0300 Subject: [PATCH] Open more file descriptors with O_CLOEXEC --- libkmod/libkmod-config.c | 4 ++-- libkmod/libkmod-module.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c index 1ba14cc5..b9ef0cdf 100644 --- a/libkmod/libkmod-config.c +++ b/libkmod/libkmod-config.c @@ -548,7 +548,7 @@ int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **p_config, } if (S_ISREG(st.st_mode)) { - int fd = open(path, O_RDONLY); + int fd = open(path, O_RDONLY|O_CLOEXEC); DBG(ctx, "parsing file '%s': %d\n", path, fd); if (fd >= 0) kmod_config_parse(config, fd, path); @@ -562,7 +562,7 @@ int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **p_config, d = conf_files_list(ctx, &list, path); for (; list != NULL; list = kmod_list_remove(list)) { - int fd = openat(dirfd(d), list->data, O_RDONLY); + int fd = openat(dirfd(d), list->data, O_RDONLY|O_CLOEXEC); DBG(ctx, "parsing file '%s/%s': %d\n", path, (const char *) list->data, fd); if (fd >= 0) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 8d703141..80da684b 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -1333,7 +1333,7 @@ KMOD_EXPORT struct kmod_list *kmod_module_get_sections(const struct kmod_module continue; } - fd = openat(dfd, de.d_name, O_RDONLY); + fd = openat(dfd, de.d_name, O_RDONLY|O_CLOEXEC); if (fd < 0) { ERR(mod->ctx, "could not open '%s/%s': %m\n", dname, de.d_name); -- 2.47.3