summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-05-27 19:35:28 +0200
committerBruno Haible <bruno@clisp.org>2020-05-28 21:39:45 +0200
commit2625e7d0916bc035a645c7b0fc697dc6e1c560c1 (patch)
tree715a3a0f93aa6eb43e6891ae79d5127e3d796a1e /lib
parent721e499d98b4237164f0729f120990f0f7b5a98e (diff)
downloadgnulib-2625e7d0916bc035a645c7b0fc697dc6e1c560c1.tar.gz
chown: Make more robust in multithreaded applications.
* lib/chown.c (rpl_chown): Pass an O_CLOEXEC flag to open().
Diffstat (limited to 'lib')
-rw-r--r--lib/chown.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chown.c b/lib/chown.c
index 46e753e0e8..6a8a76c920 100644
--- a/lib/chown.c
+++ b/lib/chown.c
@@ -87,7 +87,7 @@ rpl_chown (const char *file, uid_t uid, gid_t gid)
on the symlink itself. To work around that, we open the
file (but this can fail due to lack of read or write permission) and
use fchown on the resulting descriptor. */
- int open_flags = O_NONBLOCK | O_NOCTTY;
+ int open_flags = O_NONBLOCK | O_NOCTTY | O_CLOEXEC;
int fd = open (file, O_RDONLY | open_flags);
if (0 <= fd
|| (errno == EACCES