Skip to content

Commit

Permalink
update PHP 7.2 libzip, libsodium & argon2 route
Browse files Browse the repository at this point in the history
- For Centmin Mod 123.09beta01 and newer branches, fix PHP 7.2 compiles for libzip + libsodium + argon2 support https://community.centminmod.com/threads/update-php-7-2-add-argon2-password-libsodium-support.13294/
- Support is disabled by default as PHP uses embedded libzip zip version. To enable libsodium and argon2 you need to use a newer version of libzip zip library. So to enable set in persistent config file /etc/centminmod/custom_config.inc the variable PHP_LIBZIP='y' and then recompile PHP 7.2 version i.e. 7.2.3 or newer via centmin.sh menu option 5
  • Loading branch information
centminmod committed Mar 16, 2018
1 parent 8f0aeb7 commit d29b3c3
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
3 changes: 3 additions & 0 deletions centmin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ PHPMONGODB='n' # MongoDB PHP extension install
MONGODBPHP_VER='1.4.0' # MongoDB PHP version
MONGODB_SASL='n' # SASL not working yet leave = n
PDOPGSQL_PHPVER='9.6' # pdo-pgsql PHP extension version for postgresql
PHP_LIBZIP='n' # use newer libzip instead of PHP embedded zip
LIBZIP_VER='1.5.0' # required for PHP 7.2 + with libsodium & argon2
LIBSODIUM_VER='1.0.16' # https://github.com/jedisct1/libsodium/releases
LIBSODIUM_NATIVE='n' # optimise for specific cpu not portable between different cpu modules
LIBARGON_VER='20171227' # https://github.com/P-H-C/phc-winner-argon2
Expand Down Expand Up @@ -789,6 +791,7 @@ source "inc/downloads_centosfive.inc"
source "inc/downloads_centossix.inc"
source "inc/downloads_centosseven.inc"
source "inc/downloadlinks.inc"
source "inc/libzip.inc"
source "inc/downloads.inc"
source "inc/yumpriorities.inc"
source "inc/yuminstall.inc"
Expand Down
2 changes: 2 additions & 0 deletions example/custom_config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ PHPMONGODB='n' # MongoDB PHP extension install
MONGODBPHP_VER='1.4.0' # MongoDB PHP version
MONGODB_SASL='n' # SASL not working yet leave = n
PDOPGSQL_PHPVER='9.6' # pdo-pgsql PHP extension version for postgresql
PHP_LIBZIP='n' # use newer libzip instead of PHP embedded zip
LIBZIP_VER='1.5.0' # required for PHP 7.2 + with libsodium & argon2
LIBSODIUM_VER='1.0.16' # https://github.com/jedisct1/libsodium/releases
LIBSODIUM_NATIVE='n' # optimise for specific cpu not portable between different cpu modules
LIBARGON_VER='20171227' # https://github.com/P-H-C/phc-winner-argon2
Expand Down
5 changes: 4 additions & 1 deletion inc/downloadlinks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,7 @@ LIBUNWIND_LINKLOCAL="${LOCALCENTMINMOD_MIRROR}/centminmodparts/gperf/${LIBUNWIND
GPERFTOOL_LINKFILE="gperftools-${GPERFTOOLS_VERSION}.tar.gz"
GPERFTOOL_LINKDIR="gperftools-${GPERFTOOLS_VERSION}"
GPERFTOOL_LINK="https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/${GPERFTOOL_LINKFILE}"
GPERFTOOL_LINKLOCAL="${LOCALCENTMINMOD_MIRROR}/centminmodparts/gperf/${GPERFTOOL_LINKFILE}"
GPERFTOOL_LINKLOCAL="${LOCALCENTMINMOD_MIRROR}/centminmodparts/gperf/${GPERFTOOL_LINKFILE}"

LIBZIP_LINKFILE="libzip-${LIBZIP_VER}.tar.gz"
LIBZIP_LINK="https://libzip.org/download/${LIBZIP_LINKFILE}"
24 changes: 24 additions & 0 deletions inc/libzip.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
libzip_install() {
pushd /svr-setup/
cecho "Download ${LIBZIP_LINKFILE} ..." $boldyellow
if [ -s "${LIBZIP_LINKFILE}" ]; then
cecho "${LIBZIP_LINKFILE} found, skipping download..." $boldgreen
else
echo "wget -c4 --progress=bar $LIBZIP_LINK --tries=3"
wget -c4 --progress=bar $LIBZIP_LINK --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: ${LIBZIP_LINKFILE} download failed." $boldgreen
else
cecho "Download done." $boldyellow
fi
fi
tar xvzf ${LIBZIP_LINKFILE}
cd libzip-${LIBZIP_VER}
mkdir build
cd build/
cmake3 ..
make${MAKETHREADS}
make install
popd
}
37 changes: 31 additions & 6 deletions inc/php_configure.inc
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,33 @@ fi
# https://github.com/jedisct1/libsodium
# disable temporarily for php 7.2.0 due to libzip compile errors
# https://gist.github.com/centminmod/d1b48ef88bda29a7e352b90fd7111ac1
if [[ "$PHPMVER" = 7.3 || "$PHPMUVER" = 7.3 ]]; then
if [[ "$PHP_LIBZIP" = [yY] ]] && [[ "$PHPMVER" = 7.2 || "$PHPMUVER" = 7.2 ]]; then
ARGONTWO_OPT=' --with-password-argon2'
LIBSODIUM_OPT=' --with-sodium'
LIBZIP_OPT=' --with-libzip'
if [[ ! -f /usr/include/zip.h ]]; then
time $YUMDNFBIN${CACHESKIP} -q -y install libzip5 libzip5-devel --enablerepo=remi
# if [[ ! -f /usr/include/zip.h ]]; then
# time $YUMDNFBIN${CACHESKIP} -q -y install libzip5 libzip5-devel --enablerepo=remi
# fi
if [[ ! -f /usr/local/include/zip.h ]]; then
libzip_install
fi
# if [[ ! -f /usr/bin/zipcmp || ! -f /usr/include/zip.h ]]; then
# time $YUMDNFBIN${CACHESKIP} -q -y install libzip libzip-devel
# fi
if [ ! -f /usr/local/lib/libsodium.so ]; then
pushd "$DIR_TMP"
wget -c4 "https://github.com/jedisct1/libsodium/releases/download/${LIBSODIUM_VER}/libsodium-${LIBSODIUM_VER}.tar.gz" --tries=3
if [ -s "libsodium-${LIBSODIUM_VER}.tar.gz" ]; then
cecho "libsodium-${LIBSODIUM_VER}.tar.gz found, skipping download..." $boldgreen
else
echo "wget -c4 "https://github.com/jedisct1/libsodium/releases/download/${LIBSODIUM_VER}/libsodium-${LIBSODIUM_VER}.tar.gz" --tries=3"
wget -c4 "https://github.com/jedisct1/libsodium/releases/download/${LIBSODIUM_VER}/libsodium-${LIBSODIUM_VER}.tar.gz" --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: libsodium-${LIBSODIUM_VER}.tar.gz download failed." $boldgreen
else
cecho "Download done." $boldyellow
fi
fi
tar xzf libsodium-${LIBSODIUM_VER}.tar.gz
cd libsodium-${LIBSODIUM_VER}
make clean
Expand All @@ -320,7 +334,18 @@ if [[ "$PHPMVER" = 7.3 || "$PHPMUVER" = 7.3 ]]; then
fi
if [ ! -f /usr/local/lib/libargon2.so ]; then
pushd "$DIR_TMP"
wget -c4 "https://github.com/P-H-C/phc-winner-argon2/archive/${LIBARGON_VER}.tar.gz" --tries=3
if [ -s "${LIBARGON_VER}.tar.gz" ]; then
cecho "${LIBARGON_VER}.tar.gz found, skipping download..." $boldgreen
else
echo "wget -c4 "https://github.com/P-H-C/phc-winner-argon2/archive/${LIBARGON_VER}.tar.gz" --tries=3"
wget -c4 "https://github.com/P-H-C/phc-winner-argon2/archive/${LIBARGON_VER}.tar.gz" --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: ${LIBARGON_VER}.tar.gz download failed." $boldgreen
else
cecho "Download done." $boldyellow
fi
fi
tar xzf ${LIBARGON_VER}.tar.gz
cd phc-winner-argon2-${LIBARGON_VER}
make clean
Expand All @@ -329,7 +354,7 @@ if [[ "$PHPMVER" = 7.3 || "$PHPMUVER" = 7.3 ]]; then
popd
fi
# if libzip, libsodium or libargon2 libraries still don't exit, disable from php configuration
if [[ ! -f /usr/local/lib/libargon2.so || ! -f /usr/local/lib/libsodium.so || ! -f /usr/include/zip.h ]]; then
if [[ ! -f /usr/local/lib/libargon2.so || ! -f /usr/local/lib/libsodium.so || ! -f /usr/local/include/zip.h ]]; then
echo
echo "disbable libzip, libsodium or libargon2 libraries"
echo
Expand Down

0 comments on commit d29b3c3

Please sign in to comment.