[build] check for pipe2() at configure time

Lack of pipe2() on relic Unix as well as missing on Mac OSX is likely
one reason why threaded web servers such as nginx choose not to support
CGI except via an external service to the process.  Without pipe2(),
race conditions exist and it is not safe for a threaded server to use
pipe() and fork() when the server also does not want to potentially leak
open file descriptors to various unrelated CGI scripts.
personal/stbuehler/mod-csrf
Glenn Strauss 2016-12-17 17:58:34 -05:00
parent 9619d643ff
commit 22ca2778a8
4 changed files with 4 additions and 4 deletions

View File

@ -220,7 +220,7 @@ if 1:
gethostbyname poll epoll_ctl getrlimit chroot \
getuid select signal pathconf madvise prctl\
writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton \
memset_s explicit_bzero clock_gettime \
memset_s explicit_bzero clock_gettime pipe2 \
getentropy arc4random_buf jrand48 srandom getloadavg'))
checkFunc(autoconf, 'getrandom', 'linux/random.h')

View File

@ -772,7 +772,7 @@ AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop inet_pton issetugid memset mmap
gethostbyname poll epoll_ctl getrlimit chroot \
getuid select signal pathconf madvise posix_fadvise posix_madvise \
writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
memset_s explicit_bzero clock_gettime \
memset_s explicit_bzero clock_gettime pipe2 \
getentropy arc4random_buf jrand48 srandom getloadavg])
AC_CHECK_HEADERS([linux/random.h],[
AC_CHECK_FUNC([getrandom], AC_DEFINE([HAVE_GETRANDOM], [1], [getrandom]))

View File

@ -148,6 +148,7 @@ check_function_exists(memcpy HAVE_MEMCPY)
check_function_exists(memset HAVE_MEMSET)
check_function_exists(mmap HAVE_MMAP)
check_function_exists(pathconf HAVE_PATHCONF)
check_function_exists(pipe2 HAVE_PIPE2)
check_function_exists(poll HAVE_POLL)
check_function_exists(port_create HAVE_PORT_CREATE)
check_function_exists(prctl HAVE_PRCTL)

View File

@ -35,8 +35,7 @@
#include <stdio.h>
#include <fcntl.h>
#if defined(O_CLOEXEC) && (!defined(__FreeBSD__) || defined(SOCK_CLOEXEC)) \
&& !defined(_AIX) && !(defined(__APPLE__) && defined(__MACH__))
#ifdef HAVE_PIPE2
#define pipe_cloexec(pipefd) pipe2((pipefd), O_CLOEXEC)
#elif defined FD_CLOEXEC
#define pipe_cloexec(pipefd) \