[core] open additional fds O_CLOEXEC

This commit is contained in:
Glenn Strauss 2018-02-03 13:43:59 -05:00
parent b1df38ab6a
commit bd32f67046
2 changed files with 4 additions and 4 deletions

View File

@ -1132,7 +1132,7 @@ static int webdav_parse_chunkqueue(server *srv, connection *con, handler_ctx *hc
data = c->file.mmap.start + c->offset;
} else {
if (-1 == c->file.fd && /* open the file if not already open */
-1 == (c->file.fd = open(c->file.name->ptr, O_RDONLY))) {
-1 == (c->file.fd = fdevent_open_cloexec(c->file.name->ptr, O_RDONLY, 0))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "open failed: ", strerror(errno));
return -1;
@ -1853,7 +1853,7 @@ SUBREQUEST_FUNC(mod_webdav_subrequest_handler_huge) {
data = c->file.mmap.start + c->offset;
} else {
if (-1 == c->file.fd && /* open the file if not already open */
-1 == (c->file.fd = open(c->file.name->ptr, O_RDONLY))) {
-1 == (c->file.fd = fdevent_open_cloexec(c->file.name->ptr, O_RDONLY, 0))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "open failed: ", strerror(errno));
close(fd);
return HANDLER_ERROR;

View File

@ -2,6 +2,7 @@
#include "log.h"
#include "stat_cache.h"
#include "fdevent.h"
#include "etag.h"
#include "splaytree.h"
@ -100,7 +101,6 @@ static uint32_t hashme(buffer *str) {
#ifdef HAVE_FAM_H
#include "fdevent.h"
#include <fam.h>
typedef struct {
@ -797,7 +797,7 @@ int stat_cache_open_rdonly_fstat (server *srv, connection *con, buffer *name, st
#endif
const int oflags = O_BINARY | O_LARGEFILE | O_NOCTTY | O_NONBLOCK
| (con->conf.follow_symlink ? 0 : O_NOFOLLOW);
const int fd = open(name->ptr, O_RDONLY | oflags);
const int fd = fdevent_open_cloexec(name->ptr, O_RDONLY | oflags, 0);
if (fd >= 0) {
if (0 == fstat(fd, st)) {
return fd;