[PATCH] Open more file descriptors with O_CLOEXEC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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 1ba14cc..b9ef0cd 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 8d70314..80da684 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);
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux