summaryrefslogtreecommitdiff
path: root/src/fdevent.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-09-21 06:32:48 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2021-09-30 17:34:03 -0400
commit9f62f1b19672f156891138cbdd8f3398388d4a84 (patch)
tree6583292a4c31ce2738d90c58a7880fff09368c4c /src/fdevent.c
parent2e60c4e0b25fa3d55213a6e6b4a67028b2b1f517 (diff)
downloadlighttpd-git-9f62f1b19672f156891138cbdd8f3398388d4a84.tar.gz
[multiple] fdevent_mkostemp()
fdevent_mkostemp() with flags arg so that caller can pass O_APPEND renamed from fdevent_mkstemp_append(), previously always O_APPEND
Diffstat (limited to 'src/fdevent.c')
-rw-r--r--src/fdevent.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/fdevent.c b/src/fdevent.c
index 4aa2d963..4635922c 100644
--- a/src/fdevent.c
+++ b/src/fdevent.c
@@ -609,7 +609,10 @@ int fdevent_open_dirname(char *path, int symlinks) {
}
-int fdevent_mkstemp_append(char *path) {
+int fdevent_mkostemp(char *path, int flags) {
+ #if defined(HAVE_MKOSTEMP)
+ return mkostemp(path, O_CLOEXEC | flags);
+ #else
#ifdef __COVERITY__
/* POSIX-2008 requires mkstemp create file with 0600 perms */
umask(0600);
@@ -618,7 +621,7 @@ int fdevent_mkstemp_append(char *path) {
const int fd = mkstemp(path);
if (fd < 0) return fd;
- if (0 != fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_APPEND)) {
+ if (flags && 0 != fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | flags)) {
/* (should not happen; fd is regular file) */
int errnum = errno;
close(fd);