From cef9b65376a044309f74b77860ccf3c48a4ae315 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 18 Apr 2017 14:56:51 +0200 Subject: Assume that O_CLOEXEC is always defined and works --- shadow/lckpwdf.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'shadow') 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 -- cgit v1.2.3