Skip to content

Commit 1b0081e

Browse files
committed
Add --with-external-libcrypt build option
display an error message if some algo not available in external libcrypt
1 parent 1f19401 commit 1b0081e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

ext/standard/config.m4

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,25 @@ int main() {
267267
])])
268268

269269

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])
276+
270277
dnl
271278
dnl If one of them is missing, use our own implementation, portable code is then possible
272279
dnl
273-
dnl TODO This is currently always enabled
274-
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" || true; then
275-
AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r for blowfish, des, ext des and md5])
276-
277-
PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
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
287+
AC_MSG_ERROR([Cannot use external libcrypt as some algo are missing])
288+
fi
278289
else
279290
AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
280291
fi

0 commit comments

Comments
 (0)