aboutsummaryrefslogtreecommitdiff
path: root/shadow
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 /shadow
parentb48061e1a534a2421c65e4258418d41a5335ba32 (diff)
downloadglibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.bz2
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'shadow')
-rw-r--r--shadow/lckpwdf.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/shadow/lckpwdf.c b/shadow/lckpwdf.c
index 5e9a976..09427eb 100644
--- a/shadow/lckpwdf.c
+++ b/shadow/lckpwdf.c
@@ -96,39 +96,12 @@ __lckpwdf (void)
/* Prevent problems caused by multiple threads. */
__libc_lock_lock (lock);
- int oflags = O_WRONLY | O_CREAT;
-#ifdef O_CLOEXEC
- oflags |= O_CLOEXEC;
-#endif
+ int oflags = O_WRONLY | O_CREAT | O_CLOEXEC;
lock_fd = __open (PWD_LOCKFILE, oflags, 0600);
if (lock_fd == -1)
/* Cannot create lock file. */
RETURN_CLOSE_FD (-1);
-#ifndef __ASSUME_O_CLOEXEC
-# ifdef O_CLOEXEC
- if (__have_o_cloexec <= 0)
-# endif
- {
- /* Make sure file gets correctly closed when process finished. */
- int flags = __fcntl (lock_fd, F_GETFD, 0);
- if (flags == -1)
- /* Cannot get file flags. */
- RETURN_CLOSE_FD (-1);
-# ifdef O_CLOEXEC
- if (__have_o_cloexec == 0)
- __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
- if (__have_o_cloexec < 0)
-# endif
- {
- flags |= FD_CLOEXEC; /* Close on exit. */
- if (__fcntl (lock_fd, F_SETFD, flags) < 0)
- /* Cannot set new flags. */
- RETURN_CLOSE_FD (-1);
- }
- }
-#endif
-
/* Now we have to get exclusive write access. Since multiple
process could try this we won't stop when it first fails.
Instead we set a timeout for the system call. Once the timer