From 5ec93aff2ad01f269669a12f45aeb8abaa853062 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 19 Jul 2019 10:33:01 +0200
Subject: [PATCH] handle "lib64" case for glibc detection
Also move the "simple" way first
to avoid file parsing or shell call
Notice: it seems that this information if not really used anywhere
and I'm not aware of any pear/pecl package with constraint on glibc version
---
OS/Guess.php | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/OS/Guess.php b/OS/Guess.php
index c45e84f15..79d5cfe36 100644
--- a/OS/Guess.php
+++ b/OS/Guess.php
@@ -195,9 +195,22 @@ function _detectGlibcVersion()
}
$major = $minor = 0;
include_once "System.php";
+
+ if (@is_link('/lib64/libc.so.6')) {
+ // Let's try reading the libc.so.6 symlink
+ if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib64/libc.so.6')), $matches)) {
+ list($major, $minor) = explode('.', $matches[1]);
+ }
+ } else if (@is_link('/lib/libc.so.6')) {
+ // Let's try reading the libc.so.6 symlink
+ if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
+ list($major, $minor) = explode('.', $matches[1]);
+ }
+ }
// Use glibc's <features.h> header file to
// get major and minor version number:
- if (@file_exists('/usr/include/features.h') &&
+ if (!($major && $minor) &&
+ @file_exists('/usr/include/features.h') &&
@is_readable('/usr/include/features.h')) {
if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
$features_file = fopen('/usr/include/features.h', 'rb');
@@ -252,13 +265,6 @@ function _detectGlibcVersion()
unlink($tmpfile);
} // features.h
- if (!($major && $minor) && @is_link('/lib/libc.so.6')) {
- // Let's try reading the libc.so.6 symlink
- if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
- list($major, $minor) = explode('.', $matches[1]);
- }
- }
-
if (!($major && $minor)) {
return $glibc = '';
}