summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/mkstemp.c
diff options
context:
space:
mode:
authorguenther <>2025-08-04 04:59:31 +0000
committerguenther <>2025-08-04 04:59:31 +0000
commitcc34b672c114e027e8e6bdb0c901bb4b2607ff3f (patch)
treed24aa432577a78ea21d815494fb1cda00d6ef8bc /src/lib/libc/stdlib/mkstemp.c
parent97f291299e43eb39dd2ecdc18098d938d467dac6 (diff)
downloadopenbsd-cc34b672c114e027e8e6bdb0c901bb4b2607ff3f.tar.gz
openbsd-cc34b672c114e027e8e6bdb0c901bb4b2607ff3f.tar.bz2
openbsd-cc34b672c114e027e8e6bdb0c901bb4b2607ff3f.zip
Implement the POSIX-2024 close-on-fork flag, but modified to be
reset on exec as preserving it across exec is not necessary for its original purpose and has security and usability concerns. Many thanks to Ricardo Branco (rbranco (at) suse.de) who did an independent implementation, caught that /dev/fd/* needed to be handled, and provided a port of the illumos test suite. Thanks to tb@ for assistance with that. ok deraadt@
Diffstat (limited to 'src/lib/libc/stdlib/mkstemp.c')
-rw-r--r--src/lib/libc/stdlib/mkstemp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/mkstemp.c b/src/lib/libc/stdlib/mkstemp.c
index 75a9d27d1a..760575005f 100644
--- a/src/lib/libc/stdlib/mkstemp.c
+++ b/src/lib/libc/stdlib/mkstemp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mkstemp.c,v 1.1 2024/01/19 19:45:02 millert Exp $ */ 1/* $OpenBSD: mkstemp.c,v 1.2 2025/08/04 04:59:31 guenther Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Todd C. Miller 3 * Copyright (c) 2024 Todd C. Miller
4 * 4 *
@@ -20,7 +20,8 @@
20#include <fcntl.h> 20#include <fcntl.h>
21#include <stdlib.h> 21#include <stdlib.h>
22 22
23#define MKOSTEMP_FLAGS (O_APPEND | O_CLOEXEC | O_DSYNC | O_RSYNC | O_SYNC) 23#define MKOSTEMP_FLAGS \
24 (O_APPEND | O_CLOEXEC | O_CLOFORK | O_DSYNC | O_RSYNC | O_SYNC)
24 25
25static int 26static int
26mkstemp_cb(const char *path, int flags) 27mkstemp_cb(const char *path, int flags)