2 # See if we need to provide mknod replacement.
4 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Written by Eric Blake.
11 AC_DEFUN([gl_FUNC_MKNOD],
13 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14 AC_REQUIRE([gl_FUNC_MKFIFO])
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 AC_CHECK_FUNCS_ONCE([mknod])
17 if test $ac_cv_func_mknod = no; then
20 dnl Detect BSD bug, where mknod requires root privileges to create fifo.
21 AC_CACHE_CHECK([whether mknod can create fifo without root privileges],
22 [gl_cv_func_mknod_works],
25 [[#include <sys/stat.h>
27 ]], [[/* Indeterminate for super-user, assume no. Why are you running
28 configure as root, anyway? */
29 if (!geteuid ()) return 99;
30 if (mknod ("conftest.fifo", S_IFIFO | 0600, 0)) return 2;]])],
31 [gl_cv_func_mknod_works=yes],
32 [if test $? = 99 && test x"$FORCE_UNSAFE_CONFIGURE" = x; then
33 AC_MSG_FAILURE([you should not run configure as root ]dnl
34 [(set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)])
36 gl_cv_func_mknod_works=no],
37 [gl_cv_func_mknod_works="guessing no"])
39 if test "$gl_cv_func_mknod_works" != yes; then
40 AC_DEFINE([MKNOD_FIFO_BUG], [1], [Define to 1 if mknod cannot create
41 a fifo without super-user privileges])
43 dnl Systems that mishandle trailing slash on mkfifo also goof on mknod.
44 if test $REPLACE_MKFIFO = 1 || test "$gl_cv_func_mknod_works" != yes; then