Check that 'dl' function is available and usable before trying to call it with error suppression; if it's disabled or unavailable we end up with mysterious failures during installation or loading of libraries.

Fixed for StatusNet installer as well as some external libraries that should be fixed upstream if they haven't already been:
* PEAR
* Auth/OpenID
* Auth/Yadis
This commit is contained in:
Brion Vibber 2009-09-01 20:04:36 -03:00 committed by Craig Andrews
parent 4a19c292fb
commit fe9473ac78
4 changed files with 15 additions and 8 deletions

View File

@ -376,7 +376,7 @@ function Auth_OpenID_detectMathLibrary($exts)
// Try to load dynamic modules. // Try to load dynamic modules.
if (!$loaded) { if (!$loaded) {
foreach ($extension['modules'] as $module) { foreach ($extension['modules'] as $module) {
if (@dl($module . "." . PHP_SHLIB_SUFFIX)) { if (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode') && @dl($module . "." . PHP_SHLIB_SUFFIX)) {
$loaded = true; $loaded = true;
break; break;
} }

View File

@ -349,7 +349,7 @@ function &Auth_Yadis_getXMLParser()
foreach ($extensions as $name => $params) { foreach ($extensions as $name => $params) {
if (!extension_loaded($name)) { if (!extension_loaded($name)) {
foreach ($params['libname'] as $libname) { foreach ($params['libname'] as $libname) {
if (@dl($libname)) { if (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode') && @dl($libname)) {
$classname = $params['classname']; $classname = $params['classname'];
} }
} }

View File

@ -746,7 +746,7 @@ class PEAR
{ {
if (!extension_loaded($ext)) { if (!extension_loaded($ext)) {
// if either returns true dl() will produce a FATAL error, stop that // if either returns true dl() will produce a FATAL error, stop that
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1) || !function_exists('dl')) {
return false; return false;
} }
if (OS_WINDOWS) { if (OS_WINDOWS) {

View File

@ -267,12 +267,19 @@ function checkPrereqs()
function checkExtension($name) function checkExtension($name)
{ {
if (!extension_loaded($name)) { if (extension_loaded($name)) {
if (!@dl($name.'.so')) { return true;
return false; } elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) {
} // dl will throw a fatal error if it's disabled or we're in safe mode.
// More fun, it may not even exist under some SAPIs in 5.3.0 or later...
$soname = $name . '.' . PHP_SHLIB_SUFFIX;
if (PHP_SHLIB_SUFFIX == 'dll') {
$soname = "php_" . $soname;
}
return @dl($soname);
} else {
return false;
} }
return true;
} }
function showLibs() function showLibs()