diff options
author | guenther <> | 2025-08-04 04:59:31 +0000 |
---|---|---|
committer | guenther <> | 2025-08-04 04:59:31 +0000 |
commit | cc34b672c114e027e8e6bdb0c901bb4b2607ff3f (patch) | |
tree | d24aa432577a78ea21d815494fb1cda00d6ef8bc /src/lib/libc/stdlib/mkstemp.c | |
parent | 97f291299e43eb39dd2ecdc18098d938d467dac6 (diff) | |
download | openbsd-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.c | 5 |
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 | ||
25 | static int | 26 | static int |
26 | mkstemp_cb(const char *path, int flags) | 27 | mkstemp_cb(const char *path, int flags) |