~ubuntu-branches/ubuntu/vivid/augeas/vivid-proposed

« back to all changes in this revision

Viewing changes to gnulib/m4/mkstemp.m4

  • Committer: Package Import Robot
  • Author(s): Raphaël Pinson
  • Date: 2014-12-01 10:49:19 UTC
  • mfrom: (1.6.1) (24.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20141201104919-lalkacyk0i5fndg5
Tags: 1.3.0-0ubuntu1
* New upstream version
* Include d/p/0003_Link_pthread.patch again

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#serial 23
 
2
 
 
3
# Copyright (C) 2001, 2003-2007, 2009-2012 Free Software Foundation, Inc.
 
4
# This file is free software; the Free Software Foundation
 
5
# gives unlimited permission to copy and/or distribute it,
 
6
# with or without modifications, as long as this notice is preserved.
 
7
 
 
8
# On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a
 
9
# silly limit that it can create no more than 26 files from a given template.
 
10
# Other systems lack mkstemp altogether.
 
11
# On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create
 
12
# only 32 files per process.
 
13
# On some hosts, mkstemp creates files with mode 0666, which is a security
 
14
# problem and a violation of POSIX 2008.
 
15
# On systems like the above, arrange to use the replacement function.
 
16
AC_DEFUN([gl_FUNC_MKSTEMP],
 
17
[
 
18
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
19
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
20
 
 
21
  AC_CHECK_FUNCS_ONCE([mkstemp])
 
22
  if test $ac_cv_func_mkstemp = yes; then
 
23
    AC_CACHE_CHECK([for working mkstemp],
 
24
      [gl_cv_func_working_mkstemp],
 
25
      [
 
26
        mkdir conftest.mkstemp
 
27
        AC_RUN_IFELSE(
 
28
          [AC_LANG_PROGRAM(
 
29
            [AC_INCLUDES_DEFAULT],
 
30
            [[int result = 0;
 
31
              int i;
 
32
              off_t large = (off_t) 4294967295u;
 
33
              if (large < 0)
 
34
                large = 2147483647;
 
35
              umask (0);
 
36
              for (i = 0; i < 70; i++)
 
37
                {
 
38
                  char templ[] = "conftest.mkstemp/coXXXXXX";
 
39
                  int (*mkstemp_function) (char *) = mkstemp;
 
40
                  int fd = mkstemp_function (templ);
 
41
                  if (fd < 0)
 
42
                    result |= 1;
 
43
                  else
 
44
                    {
 
45
                      struct stat st;
 
46
                      if (lseek (fd, large, SEEK_SET) != large)
 
47
                        result |= 2;
 
48
                      if (fstat (fd, &st) < 0)
 
49
                        result |= 4;
 
50
                      else if (st.st_mode & 0077)
 
51
                        result |= 8;
 
52
                      if (close (fd))
 
53
                        result |= 16;
 
54
                    }
 
55
                }
 
56
              return result;]])],
 
57
          [gl_cv_func_working_mkstemp=yes],
 
58
          [gl_cv_func_working_mkstemp=no],
 
59
          [case "$host_os" in
 
60
                     # Guess yes on glibc systems.
 
61
             *-gnu*) gl_cv_func_working_mkstemp="guessing yes" ;;
 
62
                     # If we don't know, assume the worst.
 
63
             *)      gl_cv_func_working_mkstemp="guessing no" ;;
 
64
           esac
 
65
          ])
 
66
        rm -rf conftest.mkstemp
 
67
      ])
 
68
    case "$gl_cv_func_working_mkstemp" in
 
69
      *yes) ;;
 
70
      *)
 
71
        REPLACE_MKSTEMP=1
 
72
        ;;
 
73
    esac
 
74
  else
 
75
    HAVE_MKSTEMP=0
 
76
  fi
 
77
])
 
78
 
 
79
# Prerequisites of lib/mkstemp.c.
 
80
AC_DEFUN([gl_PREREQ_MKSTEMP],
 
81
[
 
82
])