aboutsummaryrefslogtreecommitdiff
path: root/login
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-18 14:56:51 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-18 14:56:51 +0200
commitcef9b65376a044309f74b77860ccf3c48a4ae315 (patch)
treec934a9b57903468b9a2754c1cf8f99f2a94c9269 /login
parentAssume that dup3 is available (diff)
downloadglibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.bz2
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'login')
-rw-r--r--login/utmp_file.c65
1 files changed, 4 insertions, 61 deletions
diff --git a/login/utmp_file.c b/login/utmp_file.c
index b1dfb3f644..6ebe1ef123 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -141,42 +141,11 @@ setutent_file (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
-#ifdef O_CLOEXEC
-# define O_flags O_LARGEFILE | O_CLOEXEC
-#else
-# define O_flags O_LARGEFILE
-#endif
file_writable = false;
- file_fd = open_not_cancel_2 (file_name, O_RDONLY | O_flags);
+ file_fd = open_not_cancel_2
+ (file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
-
-#ifndef __ASSUME_O_CLOEXEC
-# ifdef O_CLOEXEC
- if (__have_o_cloexec <= 0)
-# endif
- {
- /* We have to make sure the file is `closed on exec'. */
- int result = fcntl_not_cancel (file_fd, F_GETFD, 0);
- if (result >= 0)
- {
-# ifdef O_CLOEXEC
- if (__have_o_cloexec == 0)
- __have_o_cloexec = (result & FD_CLOEXEC) ? 1 : -1;
-
- if (__have_o_cloexec < 0)
-# endif
- result = fcntl_not_cancel (file_fd, F_SETFD,
- result | FD_CLOEXEC);
- }
-
- if (result == -1)
- {
- close_not_cancel_no_status (file_fd);
- return 0;
- }
- }
-#endif
}
__lseek64 (file_fd, 0, SEEK_SET);
@@ -404,37 +373,11 @@ pututline_file (const struct utmp *data)
/* We must make the file descriptor writable before going on. */
const char *file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
- int new_fd = open_not_cancel_2 (file_name, O_RDWR | O_flags);
+ int new_fd = open_not_cancel_2
+ (file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
-#ifndef __ASSUME_O_CLOEXEC
-# ifdef O_CLOEXEC
- if (__have_o_cloexec <= 0)
-# endif
- {
- /* We have to make sure the file is `closed on exec'. */
- int result = fcntl_not_cancel (file_fd, F_GETFD, 0);
- if (result >= 0)
- {
-# ifdef O_CLOEXEC
- if (__have_o_cloexec == 0)
- __have_o_cloexec = (result & FD_CLOEXEC) ? 1 : -1;
-
- if (__have_o_cloexec < 0)
-# endif
- result = fcntl_not_cancel (file_fd, F_SETFD,
- result | FD_CLOEXEC);
- }
-
- if (result == -1)
- {
- close_not_cancel_no_status (file_fd);
- return NULL;
- }
- }
-#endif
-
if (__lseek64 (new_fd, __lseek64 (file_fd, 0, SEEK_CUR), SEEK_SET) == -1
|| __dup2 (new_fd, file_fd) < 0)
{