diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-04-18 14:56:51 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-04-18 14:56:51 +0200 |
commit | cef9b65376a044309f74b77860ccf3c48a4ae315 (patch) | |
tree | c934a9b57903468b9a2754c1cf8f99f2a94c9269 /shadow | |
parent | Assume that dup3 is available (diff) | |
download | glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.bz2 glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip |
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'shadow')
-rw-r--r-- | shadow/lckpwdf.c | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/shadow/lckpwdf.c b/shadow/lckpwdf.c index 5e9a976560..09427eb233 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 |