Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84110 invoked by uid 1010); 11 Apr 2005 15:58:08 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84095 invoked from network); 11 Apr 2005 15:58:08 -0000 Received: from unknown (HELO netia.net.pl) (127.0.0.1) by localhost with SMTP; 11 Apr 2005 15:58:08 -0000 X-Host-Fingerprint: 195.114.173.133 lars.internetia.pl Linux 2.4 w/o timestamps Received: from ([195.114.173.133:41077] helo=lars.internetia.pl) by pb1.pair.com (ecelerity HEAD r(5268)) with SMTP id E3/59-19272-F8E9A524 for ; Mon, 11 Apr 2005 11:58:08 -0400 Received: from szafir.internetia.pl ([212.106.7.66.18580]) by lars.internetia.pl with esmtp (Exim 3.35) envelope-from for id 1DL1Ia-0001YX-00; Mon, 11 Apr 2005 17:58:04 +0200 Received: from granat.internetia.pl ([195.114.173.177.48515] helo=[10.114.160.200]) by szafir.internetia.pl with esmtp (TLSv1:RC4-MD5:128) (Exim 3.35) envelope-from for id 1DL1IJ-0000p0-00; Mon, 11 Apr 2005 17:57:47 +0200 Organization: Netia SA To: internals@lists.php.net Date: Mon, 11 Apr 2005 17:57:47 +0200 User-Agent: KMail/1.7.2 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_75pWC3VnBjCjO51" Message-ID: <200504111757.47645.Piotr_Roszatycki@netia.net.pl> Subject: extension_path From: Piotr_Roszatycki@netia.net.pl (Piotr Roszatycki) --Boundary-00=_75pWC3VnBjCjO51 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline I wonder why extension_dir couldn't seek the modules in more that one directory. All known interpreters (perl, ruby, python) can read modules from the different directories. The layout is usually: /usr/lib/php - system modules installed from package /usr/local/lib/php - manually installed modules My proposition is to extend extension_dir setting and allow to set the directories separated with colon sign. -- .''`. Piotr Roszatycki, Netia SA : :' : mailto:Piotr_Roszatycki@netia.net.pl `. `' mailto:dexter@debian.org `- --Boundary-00=_75pWC3VnBjCjO51 Content-Type: text/x-diff; charset="us-ascii"; name="121-extension_dir_path.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="121-extension_dir_path.patch" The extension_dir can contains path list separated with colon. diff -Nru php-5.0.4.orig/ext/standard/dl.c php-5.0.4/ext/standard/dl.c --- php-5.0.4.orig/ext/standard/dl.c 2005-03-21 09:34:37 +0100 +++ php-5.0.4/ext/standard/dl.c 2005-04-05 11:48:00 +0200 @@ -46,6 +46,11 @@ #endif /* defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H */ +#include +#if HAVE_UNISTD_H +#include +#endif + /* {{{ proto int dl(string extension_filename) Load a PHP extension at runtime */ @@ -101,6 +106,8 @@ zend_module_entry *(*get_module)(void); int error_type; char *extension_dir; + char *tmp = NULL, *ptr = NULL; + struct stat buf; if (type==MODULE_PERSISTENT) { /* Use the configuration hash directly, the INI mechanism is not yet initialized */ @@ -111,24 +118,54 @@ extension_dir = PG(extension_dir); } - if (type==MODULE_TEMPORARY) { - error_type = E_WARNING; - } else { - error_type = E_CORE_WARNING; + if (extension_dir && extension_dir[0]) { + tmp = emalloc(strlen(extension_dir)); + strcpy(tmp, extension_dir); + extension_dir = tmp; } - if (extension_dir && extension_dir[0]){ - int extension_dir_len = strlen(extension_dir); + while (1) { - libpath = emalloc(extension_dir_len+Z_STRLEN_P(file)+2); + if (extension_dir && extension_dir[0] && (ptr = strchr(extension_dir, ':')) != NULL) { + ptr[0] = 0; + ptr++; + } - if (IS_SLASH(extension_dir[extension_dir_len-1])) { - sprintf(libpath, "%s%s", extension_dir, Z_STRVAL_P(file)); /* SAFE */ + if (type==MODULE_TEMPORARY) { + error_type = E_WARNING; } else { - sprintf(libpath, "%s%c%s", extension_dir, DEFAULT_SLASH, Z_STRVAL_P(file)); /* SAFE */ + error_type = E_CORE_WARNING; } - } else { - libpath = estrndup(Z_STRVAL_P(file), Z_STRLEN_P(file)); + + if (extension_dir && extension_dir[0]){ + int extension_dir_len = strlen(extension_dir); + + libpath = emalloc(extension_dir_len+Z_STRLEN_P(file)+2); + + if (IS_SLASH(extension_dir[extension_dir_len-1])) { + sprintf(libpath, "%s%s", extension_dir, Z_STRVAL_P(file)); /* SAFE */ + } else { + sprintf(libpath, "%s%c%s", extension_dir, DEFAULT_SLASH, Z_STRVAL_P(file)); /* SAFE */ + } + } else { + libpath = estrndup(Z_STRVAL_P(file), Z_STRLEN_P(file)); + } + + if (stat(libpath, &buf) == 0) { + break; + } + + if (!ptr || !ptr[0]) { + break; + } + + efree(libpath); + + extension_dir = ptr; + } + + if (tmp) { + efree(tmp); } /* load dynamic symbol */ --Boundary-00=_75pWC3VnBjCjO51--