]> granicus.if.org Git - php/commitdiff
MFH: fix #39795 (build fails on AIX because crypt_r() uses different data struct)
authorAntony Dovgal <tony2001@php.net>
Tue, 12 Dec 2006 07:38:04 +0000 (07:38 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 12 Dec 2006 07:38:04 +0000 (07:38 +0000)
NEWS
acinclude.m4
configure.in
ext/standard/crypt.c

diff --git a/NEWS b/NEWS
index 43aacb340150caa5e80ff38e16440ab337be6aae..fa8fd9aa8c45cf133b218767bf20888ce2e1b2f1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@ PHP                                                                        NEWS
 - Fixed FastCGI impersonation for persistent connections on Windows. (Dmitry)
 - Fixed wrong signature initialization in imagepng (Takeshi Abe)
 - Added optimization for imageline with horizontal and vertial lines (Pierre)
+- Fixed bug #39795 (build fails on AIX because crypt_r() uses different data 
+  struct). (Tony)
 - Fixed bug #39791 (Crash in strtotime() on overly long relative date
   multipliers). (Ilia)
 - Fixed bug #39787 (PHP doesn't work with Apache 2.3). (mv at binarysec dot
index efc7ccca0f59cd19d7b9f7646031feff2eab432d..d4af13aabf7c7a4f85c0e4a39761dd71ce44c0b5 100644 (file)
@@ -2590,3 +2590,55 @@ AC_DEFUN([PHP_DETECT_ICC],
   )
 ])
 
+dnl
+dnl PHP_CRYPT_R_STYLE
+dnl detect the style of crypt_r() is any is available
+dnl see APR_CHECK_CRYPT_R_STYLE() for original version
+dnl
+AC_DEFUN([PHP_CRYPT_R_STYLE],
+[
+  AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
+    php_cv_crypt_r_style=none
+    AC_TRY_COMPILE([
+#include <crypt.h>
+],[
+CRYPTD buffer;
+crypt_r("passwd", "hash", &buffer);
+], 
+php_cv_crypt_r_style=cryptd)
+
+    if test "$php_cv_crypt_r_style" = "none"; then
+      AC_TRY_COMPILE([
+#include <crypt.h>
+],[
+struct crypt_data buffer;
+crypt_r("passwd", "hash", &buffer);
+], 
+php_cv_crypt_r_style=struct_crypt_data)
+    fi
+
+    if test "$php_cv_crypt_r_style" = "none"; then
+      AC_TRY_COMPILE([
+#define _GNU_SOURCE
+#include <crypt.h>
+],[
+struct crypt_data buffer;
+crypt_r("passwd", "hash", &buffer);
+], 
+php_cv_crypt_r_style=struct_crypt_data_gnu_source)
+    fi
+    ])
+
+  if test "$php_cv_crypt_r_style" = "cryptd"; then
+    AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
+  fi
+  if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
+    AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
+  fi
+  if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
+    AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
+  fi
+  if test "$php_cv_crypt_r_style" = "none"; then
+    AC_MSG_ERROR([Unable to detect data struct is used by crypt_r])
+  fi
+])
index 1c8621febf876df8de34f2ab5aa4b8af002b3e8e..74fc8804fd868b7010ba33e233772617eb0ffbc5 100644 (file)
@@ -467,7 +467,6 @@ chroot \
 ctime_r \
 cuserid \
 crypt \
-crypt_r \
 flock \
 ftok \
 funopen \
@@ -600,6 +599,11 @@ PHP_TIME_R_TYPE
 PHP_READDIR_R_TYPE
 PHP_CHECK_IN_ADDR_T
 
+AC_CHECK_FUNCS(crypt_r, [ php_crypt_r="1" ], [ php_crypt_r="0" ])
+if test "x$php_crypt_r" = "x1"; then
+  PHP_CRYPT_R_STYLE
+fi
+
 divert(4)
 
 dnl ## In diversion 4 we check user-configurable general settings.
index 1e138c775f49f9aca2c433d786018fb0262fa6c5..e139554d6de869f64ad94ab2cf4fa9899f647666 100644 (file)
@@ -28,6 +28,9 @@
 #include <unistd.h>
 #endif
 #if HAVE_CRYPT_H
+#if defined(CRYPT_R_GNU_SOURCE) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
 #include <crypt.h>
 #endif
 #if TM_IN_SYS_TIME
@@ -147,8 +150,15 @@ PHP_FUNCTION(crypt)
        }
 #ifdef HAVE_CRYPT_R
        {
+#if defined(CRYPT_R_STRUCT_CRYPT_DATA)
                struct crypt_data buffer;
                memset(&buffer, 0, sizeof(buffer));
+#elif defined(CRYPT_R_CRYPTD)
+               CRYPTD buffer;
+#else 
+#error Data struct used by crypt_r() is unknown. Please report.
+#endif
+
                RETURN_STRING(crypt_r(str, salt, &buffer), 1);
        }
 #else