From:             [EMAIL PROTECTED]
Operating system: Windows XP SP2
PHP version:      5CVS-2007-04-12 (snap)
PHP Bug Type:     Filesystem function related
Bug description:  is_executable only looks at basic executables

Description:
------------
For Windows, the is_executable() function only checks the file extensions
of exe, com, bat and cmd.

This is incomplete.

Within Windows, there is an environment variable called PATHEXT. This
contains a list of extensions which are executable.

If you type a program whose extension is in this list and the program with
that extension is in the path, then it is executed.

You can easily add .PHP to this list (see UserNote
http://www.php.net/manual/en/features.commandline.php#53252). This is
completely normal behaviour on windows.

Using the "FileTypes" mechanism allows any type of file to have an
automatic "handler" (double click a PDF file and Acrobat loads with that
file). By also adding the extension to the PATHEXT environment variable you
can type just the name at the CLI and the lovely windows magic happens
automagically.

The standard list of executable types within windows XP is:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

Mine is:

PATHEXT=.COM;.EXE;.BAT;.CMD;.PHP;.PYC;.PY;

I don't deal with MS VB scripts, but I do deal with PHP and Python!

All of these are "executable" (i.e. the behaviour of an abc.php is the
same as an abc.bat or an abc.exe).

Admittedly this is only on windows, but the current method should either
be documented as only being of limited use on Windows (with the  4 types)
or be extended to look at the Windows mechanism (just like I assume the *ix
version looks at an executable bit on the permissions?).

The following is a screen grab to prove the point.

12/04/2007 15:02:28 C:\>type "d:\PHP Quickies\isexec.php"
<?php
echo $argv[0], ' is ', (is_executable($argv[0]) ? '' : 'not '),
'executable';
?>

12/04/2007 15:02:34 C:\>set path
Path=C:\Batch;C:\PHP5;D:\PHP Quickies;C:\Program Files\Windows Resource
Kits\Tools;C:\Python\Lib;C:\Program Files\WinRAR;D:\Sage\UTILS;c:\program
files\imagemagick;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
Files\Universal Extractor\bin;C:\Program Files\Microsoft SQL
Server\80\Tools\BINN;C:\Program Files\Nmap;D:\Cygwin\bin;
PATHEXT=.COM;.EXE;.BAT;.CMD;.PHP;.PYC;.PY;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

12/04/2007 15:02:37 C:\>isexec
D:\PHP Quickies\isexec.php is not executable



Reproduce code:
---------------
<?php
echo is_executable($argv[0]) ? 'Executable' : 'Not executable';
?>

Expected result:
----------------
D:\PHP Quickies\isexec.php is executable

Actual result:
--------------
D:\PHP Quickies\isexec.php is not executable

-- 
Edit bug report at http://bugs.php.net/?id=41062&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41062&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41062&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41062&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41062&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41062&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41062&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41062&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41062&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41062&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41062&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41062&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41062&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41062&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41062&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41062&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41062&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41062&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41062&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41062&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41062&r=mysqlcfg

Reply via email to