I would like to merge this patch into 5.0 and 4.4.
It also fixes the problem that existed since 4.3 - is_executable() is affected 
by open_basedir setting:

[EMAIL PROTECTED]:/usr/src/dev/orig/php-src_5_0> ./sapi/cli/php -n -d open_basedir="/www" 
-r 'var_dump(is_executable("/bin/bash"));'
bool(false)

[EMAIL PROTECTED]:/usr/src/dev/orig/php-src_5_1> ./sapi/cli/php -n -d open_basedir="/www" 
-r 'var_dump(is_executable("/bin/bash"));'
bool(true)

Any objections?

On 22.10.2005 21:26, Wez Furlong wrote:
wez             Sat Oct 22 13:26:16 2005 EDT

Modified files: /php-src/main/streams php_stream_plain_wrapper.h /php-src/ext/standard filestat.c Log:
  merge VCWD_ACCESS bugfix to head.
  Test suite is unusable in HEAD, so I guess it works here too.
http://cvs.php.net/diff.php/php-src/main/streams/php_stream_plain_wrapper.h?r1=1.7&r2=1.8&ty=u
Index: php-src/main/streams/php_stream_plain_wrapper.h
diff -u php-src/main/streams/php_stream_plain_wrapper.h:1.7 
php-src/main/streams/php_stream_plain_wrapper.h:1.8
--- php-src/main/streams/php_stream_plain_wrapper.h:1.7 Wed Aug  3 10:08:42 2005
+++ php-src/main/streams/php_stream_plain_wrapper.h     Sat Oct 22 13:26:16 2005
@@ -16,12 +16,13 @@
    +----------------------------------------------------------------------+
  */
-/* $Id: php_stream_plain_wrapper.h,v 1.7 2005/08/03 14:08:42 sniper Exp $ */
+/* $Id: php_stream_plain_wrapper.h,v 1.8 2005/10/22 17:26:16 wez Exp $ */
/* definitions for the plain files wrapper */ /* operations for a plain file; use the php_stream_fopen_XXX funcs below */
 PHPAPI extern php_stream_ops php_stream_stdio_ops;
+PHPAPI extern php_stream_wrapper php_plain_files_wrapper;
BEGIN_EXTERN_C() http://cvs.php.net/diff.php/php-src/ext/standard/filestat.c?r1=1.137&r2=1.138&ty=u
Index: php-src/ext/standard/filestat.c
diff -u php-src/ext/standard/filestat.c:1.137 
php-src/ext/standard/filestat.c:1.138
--- php-src/ext/standard/filestat.c:1.137       Tue Aug 23 08:53:23 2005
+++ php-src/ext/standard/filestat.c     Sat Oct 22 13:26:16 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
-/* $Id: filestat.c,v 1.137 2005/08/23 12:53:23 dmitry Exp $ */
+/* $Id: filestat.c,v 1.138 2005/10/22 17:26:16 wez Exp $ */
#include "php.h"
 #include "safe_mode.h"
@@ -543,6 +543,7 @@
 #define IS_LINK_OPERATION(__t) ((__t) == FS_TYPE || (__t) == FS_IS_LINK || 
(__t) == FS_LSTAT)
 #define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS  || (__t) == FS_IS_W || (__t) 
== FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || 
(__t) == FS_IS_LINK)
 #define IS_ABLE_CHECK(__t) ((__t) == FS_IS_R || (__t) == FS_IS_W || (__t) == 
FS_IS_X)
+#define IS_ACCESS_CHECK(__t) (IS_ABLE_CHECK(type) || (__t) == FS_EXISTS)
/* {{{ php_stat
  */
@@ -560,6 +561,35 @@
                RETURN_FALSE;
        }
+ if (IS_ACCESS_CHECK(type)) {
+               char *local;
+
+               if (php_stream_locate_url_wrapper(filename, &local, 0 TSRMLS_CC) == 
&php_plain_files_wrapper) {
+                       switch (type) {
+#ifdef F_OK
+                               case FS_EXISTS:
+                                       RETURN_BOOL(VCWD_ACCESS(local, F_OK) == 
0);
+                                       break;
+#endif
+#ifdef W_OK
+                               case FS_IS_W:
+                                       RETURN_BOOL(VCWD_ACCESS(local, W_OK) == 
0);
+                                       break;
+#endif
+#ifdef R_OK
+                               case FS_IS_R:
+                                       RETURN_BOOL(VCWD_ACCESS(local, R_OK) == 
0);
+                                       break;
+#endif
+#ifdef X_OK
+                               case FS_IS_X:
+                                       RETURN_BOOL(VCWD_ACCESS(local, X_OK) == 
0);
+                                       break;
+#endif
+                       }
+               }
+       }
+
        if (IS_LINK_OPERATION(type)) {
                flags |= PHP_STREAM_URL_STAT_LINK;
        }
@@ -617,7 +647,7 @@
                php_stream_wrapper *wrapper;
wrapper = php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC);
-               if (wrapper && wrapper->wops && wrapper->wops->label && 
strcmp(wrapper->wops->label, "plainfile") == 0) {
+               if (wrapper == &php_plain_files_wrapper) {
                        if (type == FS_IS_X) {
                                xmask = S_IXROOT;
                        } else {



--
Wbr, Antony Dovgal

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

Reply via email to