]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Open more file descriptors with O_CLOEXEC
authorCristian Rodríguez <crrodriguez@opensuse.org>
Fri, 16 Dec 2011 17:46:52 +0000 (14:46 -0300)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Sat, 17 Dec 2011 21:28:10 +0000 (19:28 -0200)
libkmod/libkmod-config.c
libkmod/libkmod-module.c

index 1ba14cc5d8c9c0a9a36566f0fdddba23710a4912..b9ef0cdf3f337c897e2348c8ade481797a53b6b7 100644 (file)
@@ -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)
index 8d7031412e62152e9b44b9bab43a639403f5b292..80da684b015436920ea25252a616e9314f81bbb0 100644 (file)
@@ -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);