From 964918fa571fd7266c950f9f46c83420c8a75e0a Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Thu, 30 Sep 2021 12:48:59 -0400 Subject: [PATCH 1/3] Revert "Use pkg-config for libargon2" This reverts commit 7965bc3656eff9753f45037b2d343017855591ee. --- UPGRADING | 5 ----- ext/standard/config.m4 | 31 ++++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/UPGRADING b/UPGRADING index 35875a4a04e56..0932091e48fa5 100644 --- a/UPGRADING +++ b/UPGRADING @@ -590,11 +590,6 @@ PHP 8.1 UPGRADE NOTES - SNMP: . add SHA256 and SHA512 for security protocol. -- Standard: - . --with-password-argon2 now uses pkg-config to detect libargon2. As such, - an alternative libargon2 location should now be specified using - PKG_CONFIG_PATH. - ======================================== 10. New Global Constants ======================================== diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index 4b687b3df5f29..9c6e731c5d127 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -400,13 +400,34 @@ dnl Check for argon2 dnl PHP_ARG_WITH([password-argon2], [for Argon2 support], - [AS_HELP_STRING([[--with-password-argon2]], - [Include Argon2 support in password_*])]) + [AS_HELP_STRING([[--with-password-argon2[=DIR]]], + [Include Argon2 support in password_*. DIR is the Argon2 shared library + path])]) if test "$PHP_PASSWORD_ARGON2" != "no"; then - PKG_CHECK_MODULES([ARGON2], [libargon2]) - PHP_EVAL_INCLINE($ARGON2_CFLAGS) - PHP_EVAL_LIBLINE($ARGON2_LIBS) + AC_MSG_CHECKING([for Argon2 library]) + for i in $PHP_PASSWORD_ARGON2 /usr /usr/local ; do + if test -r $i/include/argon2.h; then + ARGON2_DIR=$i; + AC_MSG_RESULT(found in $i) + break + fi + done + + if test -z "$ARGON2_DIR"; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([Please ensure the argon2 header and library are installed]) + fi + + PHP_ADD_LIBRARY_WITH_PATH(argon2, $ARGON2_DIR/$PHP_LIBDIR) + PHP_ADD_INCLUDE($ARGON2_DIR/include) + + AC_CHECK_LIB(argon2, argon2id_hash_raw, [ + LIBS="$LIBS -largon2" + AC_DEFINE(HAVE_ARGON2LIB, 1, [ Define to 1 if you have the header file ]) + ], [ + AC_MSG_ERROR([Problem with libargon2.(a|so). Please verify that Argon2 header and libraries >= 20161029 are installed]) + ]) fi dnl From 206a369c1be81c4265f8cb3dc7be6d132cf86e4e Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Thu, 30 Sep 2021 13:51:47 -0400 Subject: [PATCH 2/3] Revert "Revert "Use pkg-config for libargon2"" This reverts commit 964918fa571fd7266c950f9f46c83420c8a75e0a. --- UPGRADING | 5 +++++ ext/standard/config.m4 | 31 +++++-------------------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/UPGRADING b/UPGRADING index 0932091e48fa5..35875a4a04e56 100644 --- a/UPGRADING +++ b/UPGRADING @@ -590,6 +590,11 @@ PHP 8.1 UPGRADE NOTES - SNMP: . add SHA256 and SHA512 for security protocol. +- Standard: + . --with-password-argon2 now uses pkg-config to detect libargon2. As such, + an alternative libargon2 location should now be specified using + PKG_CONFIG_PATH. + ======================================== 10. New Global Constants ======================================== diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index 9c6e731c5d127..4b687b3df5f29 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -400,34 +400,13 @@ dnl Check for argon2 dnl PHP_ARG_WITH([password-argon2], [for Argon2 support], - [AS_HELP_STRING([[--with-password-argon2[=DIR]]], - [Include Argon2 support in password_*. DIR is the Argon2 shared library - path])]) + [AS_HELP_STRING([[--with-password-argon2]], + [Include Argon2 support in password_*])]) if test "$PHP_PASSWORD_ARGON2" != "no"; then - AC_MSG_CHECKING([for Argon2 library]) - for i in $PHP_PASSWORD_ARGON2 /usr /usr/local ; do - if test -r $i/include/argon2.h; then - ARGON2_DIR=$i; - AC_MSG_RESULT(found in $i) - break - fi - done - - if test -z "$ARGON2_DIR"; then - AC_MSG_RESULT([not found]) - AC_MSG_ERROR([Please ensure the argon2 header and library are installed]) - fi - - PHP_ADD_LIBRARY_WITH_PATH(argon2, $ARGON2_DIR/$PHP_LIBDIR) - PHP_ADD_INCLUDE($ARGON2_DIR/include) - - AC_CHECK_LIB(argon2, argon2id_hash_raw, [ - LIBS="$LIBS -largon2" - AC_DEFINE(HAVE_ARGON2LIB, 1, [ Define to 1 if you have the header file ]) - ], [ - AC_MSG_ERROR([Problem with libargon2.(a|so). Please verify that Argon2 header and libraries >= 20161029 are installed]) - ]) + PKG_CHECK_MODULES([ARGON2], [libargon2]) + PHP_EVAL_INCLINE($ARGON2_CFLAGS) + PHP_EVAL_LIBLINE($ARGON2_LIBS) fi dnl From aaced32758892834728a8b6c515bd88340c81704 Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Thu, 30 Sep 2021 13:58:39 -0400 Subject: [PATCH 3/3] Ensure HAVE_ARGON2LIB is set when compiling using libargon2 --- ext/standard/config.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index 4b687b3df5f29..58b9c5e658a41 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -407,6 +407,8 @@ if test "$PHP_PASSWORD_ARGON2" != "no"; then PKG_CHECK_MODULES([ARGON2], [libargon2]) PHP_EVAL_INCLINE($ARGON2_CFLAGS) PHP_EVAL_LIBLINE($ARGON2_LIBS) + + AC_DEFINE(HAVE_ARGON2LIB, 1, [ ]) fi dnl