Here is a patch for bug 41822.  The expand_filepath() function will not
work in Solaris if a non-root user attempts to read a file under a
directory with only (--x) permissions.

Currently expand_path() returns NULL and no FD is opened, although the
file is readable.  This patch adds a last-ditch effort to open includes
using a relative path and returns NULL if it still can't get a file
descriptor.

expand_filepath() returns NULL in solaris because getcwd() returns NULL
under the above conditions.

Thanks,
-Rob



--- ./plain_wrapper.c.old       2007-10-05 02:50:59.000000000 -0400
+++ ./plain_wrapper.c   2007-10-05 02:55:38.000000000 -0400
@@ -885,9 +885,20 @@
                return NULL;
        }

-       if ((realpath = expand_filepath(filename, NULL TSRMLS_CC)) ==
NULL) {
-               return NULL;
-       }
+        if ((realpath = expand_filepath(filename, NULL TSRMLS_CC)) == NULL)
+                {
+                if (options & STREAM_OPEN_FOR_INCLUDE) {
+                        /* Attempt to open without path expansion anyways.
+                           Files in Solaris dirs with --x will
+                           not return a realpath, but are accessible */
+                        fd = open(filename, open_flags, 0666);
+                        if (fd != -1) {
+                                ret =
php_stream_fopen_from_fd_int_rel(fd, mode, persistent_id);
+                                return ret; }
+                        else {
+                                return NULL; }
+                        }
+                }

        if (persistent) {
                spprintf(&persistent_id, 0, "streams_stdio_%d_%s",
open_flags, realpath);

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to