php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54432 sapi_module.executable_location is not a real path in all circumstances.
Submitted: 2011-03-31 14:18 UTC Modified: -
From: RQuadling at GMail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 5.3SVN-2011-03-31 (SVN) OS:
Private report: No CVE-ID: None
 [2011-03-31 14:18 UTC] RQuadling at GMail dot com
Description:
------------
Hi.

I'm looking and learning.

In sapi_module, there is an entry called executable_location.

The name (executable_location) doesn't match the content which is the name that was entered by the user (for the CLI sapi for example).

At the command line, I can type ...

php

and my PATH is examined by the OS to find the first php file whose extension is in my list of PATHEXTs will be used. This all happens along the same lines that I 
documented at 
http://docs.php.net/manual/en/install.windows.commandline.php for running php scripts from the command line without the need to type the php.exe or the .php part.

The program is ran and argv[0] will be 'php'.

Not C:\PHP5\php.exe

I did a search on executable_location on PHP5.3 and all of PECL (the only PECL use is in http://pecl.php.net/package/proctitle ("This extension allows changing the 
current process' name on Linux and *BSD systems. This is useful 
when using pcntl_fork() to identify running processes in process list").

There are 2 main uses.

1 - Population.

The SAPIs CLI, CGI, embed, fpm, litespeed and milter all populate the entry. The others SAPIs don't.

If it is populated by ...

xxx_sapi_module.executable_location = argv[0];


This reflects the issue I see in that the executable_location is not really a location, just the name passed to the program from the command line.


2 - Used to determine where a local php.ini file is.

In main/php.ini, sapi_module.executable_location is checked to see if it is set.

Then, for windows, the win32 call to GetModuleFileName() is called and that returns the real location of the exe. For non-win32, a loop through PATH is performed, 
looking for the executable_location filename in each location.

In both cases, the variable binary_location is populate with the physical location of the executable.



Could this be assigned to sapi_module.executable_location?

I think the definition may need to change from a *char to a char array or another char array created during SAPI initialization and freed during the SAPI teardown.


The searching in the local directory was a bug fix from http://bugs.php.net/bug.php?id=33882, but having the executable_location updated would be useful for reporting 
later on if there is a problem.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2024-07-01 09:00 UTC] emily835joshep at gmail dot com
Thanks for sharing this info. Its really very helpful to me.  (https://github.com)(https://www-choiceadvantage.com)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC