diff options
author | Colin Walters <walters@verbum.org> | 2015-01-07 08:12:25 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-01-07 08:12:25 -0500 |
commit | b7a7c839965c1bb6d8436129c3e3b9d564d885a3 (patch) | |
tree | d8719ef258bd1440d584257554164cba5fd4913b | |
parent | df3dd55ff0a596b5245620856d3433d45505fddc (diff) | |
download | libgsystem-b7a7c839965c1bb6d8436129c3e3b9d564d885a3.tar.gz |
fileutils: Consistently use O_CLOEXEC
For the standard thread+fork safety reasons.
-rw-r--r-- | src/gsystem-file-utils.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gsystem-file-utils.c b/src/gsystem-file-utils.c index bbb6b75..5c1b251 100644 --- a/src/gsystem-file-utils.c +++ b/src/gsystem-file-utils.c @@ -92,7 +92,7 @@ gs_file_openat_noatime (int dfd, #ifdef O_NOATIME do - fd = openat (dfd, name, O_RDONLY | O_NOATIME, 0); + fd = openat (dfd, name, O_RDONLY | O_NOATIME | O_CLOEXEC, 0); while (G_UNLIKELY (fd == -1 && errno == EINTR)); /* Only the owner or superuser may use O_NOATIME; so we may get * EPERM. EINVAL may happen if the kernel is really old... @@ -100,7 +100,7 @@ gs_file_openat_noatime (int dfd, if (fd == -1 && (errno == EPERM || errno == EINVAL)) #endif do - fd = openat (dfd, name, O_RDONLY, 0); + fd = openat (dfd, name, O_RDONLY | O_CLOEXEC, 0); while (G_UNLIKELY (fd == -1 && errno == EINTR)); if (fd == -1) @@ -562,7 +562,7 @@ gs_file_open_in_tmpdir_at (int tmpdir_fd, tmp_name = gs_fileutil_gen_tmp_name (NULL, NULL); do - fd = openat (tmpdir_fd, tmp_name, O_WRONLY | O_CREAT | O_EXCL, mode); + fd = openat (tmpdir_fd, tmp_name, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, mode); while (fd == -1 && errno == EINTR); if (fd < 0 && errno != EEXIST) { |