Skip to content

Commit bbcc372

Browse files
committed
only check crypt algo if we use external libcrypt
1 parent ab1045f commit bbcc372

File tree

1 file changed

+68
-71
lines changed

1 file changed

+68
-71
lines changed

ext/standard/config.m4

Lines changed: 68 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,23 @@ if test "$ac_cv_flush_io" = "yes"; then
5151
AC_DEFINE(HAVE_FLUSHIO, 1, [Define if flush should be called explicitly after a buffered io.])
5252
fi
5353

54-
PHP_CHECK_FUNC(crypt, crypt)
55-
PHP_CHECK_FUNC(crypt_r, crypt)
56-
if test "$ac_cv_func_crypt_r" = "yes"; then
57-
PHP_CRYPT_R_STYLE
58-
fi
54+
PHP_ARG_WITH([external-libcrypt],
55+
[for external libcrypt or libxcrypt],
56+
[AS_HELP_STRING([--with-external-libcrypt],
57+
[Use external libcrypt or libxcrypt])],
58+
[no],
59+
[no])
5960

60-
AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
61-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
61+
if test "$PHP_EXTERNAL_LIBCRYPT" != "no"; then
62+
PHP_CHECK_FUNC(crypt, crypt)
63+
PHP_CHECK_FUNC(crypt_r, crypt)
64+
AC_CHECK_HEADERS(crypt.h)
65+
if test "$ac_cv_func_crypt_r" = "yes"; then
66+
PHP_CRYPT_R_STYLE
67+
fi
68+
69+
AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
70+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
6271
#include <string.h>
6372
6473
#if HAVE_UNISTD_H
@@ -87,8 +96,8 @@ int main() {
8796
ac_cv_crypt_des=yes
8897
])])
8998

90-
AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
91-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
99+
AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
100+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
92101
#include <string.h>
93102
94103
#if HAVE_UNISTD_H
@@ -110,15 +119,15 @@ int main() {
110119
return 1;
111120
#endif
112121
}]])],[
113-
ac_cv_crypt_ext_des=yes
114-
],[
115-
ac_cv_crypt_ext_des=no
116-
],[
117-
ac_cv_crypt_ext_des=no
118-
])])
119-
120-
AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[
121-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
122+
ac_cv_crypt_ext_des=yes
123+
],[
124+
ac_cv_crypt_ext_des=no
125+
],[
126+
ac_cv_crypt_ext_des=no
127+
])])
128+
129+
AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[
130+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
122131
#include <string.h>
123132
124133
#if HAVE_UNISTD_H
@@ -150,15 +159,15 @@ int main() {
150159
return 1;
151160
#endif
152161
}]])],[
153-
ac_cv_crypt_md5=yes
154-
],[
155-
ac_cv_crypt_md5=no
156-
],[
157-
ac_cv_crypt_md5=no
158-
])])
159-
160-
AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[
161-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
162+
ac_cv_crypt_md5=yes
163+
],[
164+
ac_cv_crypt_md5=no
165+
],[
166+
ac_cv_crypt_md5=no
167+
])])
168+
169+
AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[
170+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
162171
#include <string.h>
163172
164173
#if HAVE_UNISTD_H
@@ -187,15 +196,15 @@ int main() {
187196
return 1;
188197
#endif
189198
}]])],[
190-
ac_cv_crypt_blowfish=yes
191-
],[
192-
ac_cv_crypt_blowfish=no
193-
],[
194-
ac_cv_crypt_blowfish=no
195-
])])
196-
197-
AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_sha512,[
198-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
199+
ac_cv_crypt_blowfish=yes
200+
],[
201+
ac_cv_crypt_blowfish=no
202+
],[
203+
ac_cv_crypt_blowfish=no
204+
])])
205+
206+
AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_sha512,[
207+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
199208
#include <string.h>
200209
201210
#if HAVE_UNISTD_H
@@ -222,16 +231,16 @@ int main() {
222231
#else
223232
return 1;
224233
#endif
225-
}]])],[
226-
ac_cv_crypt_sha512=yes
227-
],[
228-
ac_cv_crypt_sha512=no
229-
],[
230-
ac_cv_crypt_sha512=no
231-
])])
232-
233-
AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_sha256,[
234-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
234+
}]])],[
235+
ac_cv_crypt_sha512=yes
236+
],[
237+
ac_cv_crypt_sha512=no
238+
],[
239+
ac_cv_crypt_sha512=no
240+
])])
241+
242+
AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_sha256,[
243+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
235244
#include <string.h>
236245
237246
#if HAVE_UNISTD_H
@@ -259,35 +268,23 @@ int main() {
259268
return 1;
260269
#endif
261270
}]])],[
262-
ac_cv_crypt_sha256=yes
263-
],[
264-
ac_cv_crypt_sha256=no
265-
],[
266-
ac_cv_crypt_sha256=no
267-
])])
268-
271+
ac_cv_crypt_sha256=yes
272+
],[
273+
ac_cv_crypt_sha256=no
274+
],[
275+
ac_cv_crypt_sha256=no
276+
])])
269277

270-
PHP_ARG_WITH([external-libcrypt],
271-
[for external libcrypt or libxcrypt],
272-
[AS_HELP_STRING([--with-external-libcrypt],
273-
[Use external libcrypt or libxcrypt])],
274-
[no],
275-
[no])
276278

277-
dnl
278-
dnl If one of them is missing, use our own implementation, portable code is then possible
279-
dnl
280-
dnl This is currently enabled by default
281-
if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "$ac_cv_crypt_md5" = "no" || test "$ac_cv_crypt_sha512" = "no" || test "$ac_cv_crypt_sha256" = "no" || test "$ac_cv_func_crypt_r" != "yes" || test "$PHP_EXTERNAL_LIBCRYPT" = "no"; then
282-
if test "$PHP_EXTERNAL_LIBCRYPT" = "no"; then
283-
AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r])
284-
285-
PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
286-
else
279+
if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "$ac_cv_crypt_md5" = "no" || test "$ac_cv_crypt_sha512" = "no" || test "$ac_cv_crypt_sha256" = "no" || test "$ac_cv_func_crypt_r" != "yes"; then
287280
AC_MSG_ERROR([Cannot use external libcrypt as some algo are missing])
288-
fi
289-
else
281+
fi
282+
290283
AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r])
284+
else
285+
AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r])
286+
287+
PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
291288
fi
292289

293290
dnl

0 commit comments

Comments
 (0)