~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to m4/mknod.m4

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# serial 5
 
2
# See if we need to provide mknod replacement.
 
3
 
 
4
dnl Copyright (C) 2009-2012 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.
 
8
 
 
9
# Written by Eric Blake.
 
10
 
 
11
AC_DEFUN([gl_FUNC_MKNOD],
 
12
[
 
13
  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
 
14
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
15
  AC_REQUIRE([gl_FUNC_MKFIFO])
 
16
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
17
  AC_CHECK_FUNCS_ONCE([mknod])
 
18
  if test $ac_cv_func_mknod = no; then
 
19
    HAVE_MKNOD=0
 
20
  else
 
21
    dnl Detect BSD bug, where mknod requires root privileges to create fifo.
 
22
    AC_CACHE_CHECK([whether mknod can create fifo without root privileges],
 
23
      [gl_cv_func_mknod_works],
 
24
      [AC_RUN_IFELSE(
 
25
         [AC_LANG_PROGRAM(
 
26
           [[#include <sys/stat.h>
 
27
             #include <unistd.h>
 
28
 
 
29
             /* Copied from root-uid.h.  FIXME: Just use root-uid.h.  */
 
30
             #ifdef __TANDEM
 
31
             # define ROOT_UID 65535
 
32
             #else
 
33
             # define ROOT_UID 0
 
34
             #endif
 
35
]], [[/* Indeterminate for super-user, assume no.  Why are you running
 
36
         configure as root, anyway?  */
 
37
      if (geteuid () == ROOT_UID) return 99;
 
38
      if (mknod ("conftest.fifo", S_IFIFO | 0600, 0)) return 2;]])],
 
39
         [gl_cv_func_mknod_works=yes],
 
40
         [if test $? = 99 && test x"$FORCE_UNSAFE_CONFIGURE" = x; then
 
41
            AC_MSG_FAILURE([you should not run configure as root ]dnl
 
42
[(set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)])
 
43
          fi
 
44
          gl_cv_func_mknod_works=no],
 
45
         [case "$host_os" in
 
46
                    # Guess yes on glibc systems.
 
47
            *-gnu*) gl_cv_func_mknod_works="guessing yes" ;;
 
48
                    # If we don't know, assume the worst.
 
49
            *)      gl_cv_func_mknod_works="guessing no" ;;
 
50
          esac
 
51
         ])
 
52
       rm -f conftest.fifo])
 
53
    case "$gl_cv_func_mknod_works" in
 
54
      *yes) ;;
 
55
      *)
 
56
        REPLACE_MKNOD=1
 
57
        AC_DEFINE([MKNOD_FIFO_BUG], [1], [Define to 1 if mknod cannot create
 
58
          a fifo without super-user privileges])
 
59
        ;;
 
60
    esac
 
61
    dnl Systems that mishandle trailing slash on mkfifo also goof on mknod.
 
62
    if test $REPLACE_MKFIFO = 1; then
 
63
      REPLACE_MKNOD=1
 
64
    fi
 
65
  fi
 
66
])