Hi Chris

On 4/25/07, Christopher Jones <[EMAIL PROTECTED]> wrote:
Instead of overloading PATH can we use a PHP-specific environment variable?

I can't think of a reason why I'd put my php.ini in the same directory as
any executables other than perhaps where the php CLI executable is.

This patch searches for the location of the php binary, not php.ini.
So even if you have php.ini anywhere in $PATH it will not be picked up
unless its the location of the binary itself.

-Hannes


Chris

Hannes Magnusson wrote:
> bjori         Wed Apr 25 10:02:23 2007 UTC
>
>   Modified files:
>     /php-src/main     php_ini.c
>   Log:
>   - Don't pick up php.ini from cwd on BSDs
>   - "Resolve" (with the help of $PATH) to /path/to/php and pick up
>       the php.ini from there
>
>
> 
http://cvs.php.net/viewvc.cgi/php-src/main/php_ini.c?r1=1.149&r2=1.150&diff_format=u
> Index: php-src/main/php_ini.c
> diff -u php-src/main/php_ini.c:1.149 php-src/main/php_ini.c:1.150
> --- php-src/main/php_ini.c:1.149      Mon Apr 16 09:43:52 2007
> +++ php-src/main/php_ini.c    Wed Apr 25 10:02:23 2007
> @@ -16,7 +16,7 @@
>     +----------------------------------------------------------------------+
>   */
>
> -/* $Id: php_ini.c,v 1.149 2007/04/16 09:43:52 dmitry Exp $ */
> +/* $Id: php_ini.c,v 1.150 2007/04/25 10:02:23 bjori Exp $ */
>
>  #include "php.h"
>  #include "ext/standard/info.h"
> @@ -351,7 +351,26 @@
>  #else
>               if (sapi_module.executable_location) {
>                       binary_location = (char *)emalloc(PATH_MAX);
> -                     if (!realpath(sapi_module.executable_location, 
binary_location)) {
> +                     if (!strchr(sapi_module.executable_location, '/')) {
> +                             char *path;
> +                             int found = 0;
> +
> +                             if ((path = getenv("PATH")) != NULL) {
> +                                     char *search_dir, 
search_path[MAXPATHLEN];
> +
> +                                     while ((search_dir = strsep(&path, 
":")) != NULL) {
> +                                             snprintf(search_path, MAXPATHLEN, 
"%s/%s", search_dir, sapi_module.executable_location);
> +                                             if (VCWD_REALPATH(search_path, 
binary_location) && !VCWD_ACCESS(binary_location, X_OK)) {
> +                                                     found = 1;
> +                                                     break;
> +                                             }
> +                                     }
> +                             }
> +                             if (!found) {
> +                                     efree(binary_location);
> +                                     binary_location = NULL;
> +                             }
> +                     } else if 
(!VCWD_REALPATH(sapi_module.executable_location, binary_location) || 
VCWD_ACCESS(binary_location, X_OK)) {
>                               efree(binary_location);
>                               binary_location = NULL;
>                       }
>


--
Christopher Jones, Oracle
Email: [EMAIL PROTECTED]    Tel: +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to