Re: svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c
| From: | Xinchen Hui | Date: | Wed, 21 Sep 2011 01:32:39 +0000 |
| Subject: | Re: svn: /php/php-src/ branches/PHP_5_4/sapi/cli/php_cli_server.c trunk/sapi/cli/php_cli_server.c | ||
| References: | 1 2 3 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-66602@lists.php.net to get a copy of this message | ||
s ,wam,was,
s ,get Ed, getcwd,
Thanks
Sent from my iPhone
在 2011-9-21,9:30,Xinchen Hui <laruence@gmail.com> 写道:
> hi:
> I wam only use VCWD At the first time,then I found broken_get Ed in
> main/main.c , so I added it too, I think this would be safer.
>
> Thanks
>
> Sent from my iPhone
>
> 在 2011-9-21,7:50,Moriyoshi Koizumi <mozo@mozo.jp> 写道:
>
>> Hi,
>>
>> Where does HAVE_BROKEN_GETCWD come from? Isn't simply using VCWD_GETCWD sufficient?
>>
>> Moriyoshi
>>
>> On 2011/09/20, at 16:06, Xinchen Hui wrote:
>>
>>> laruence Tue, 20 Sep 2011 07:06:55 +0000
>>>
>>> Revision: Ä
>>> 㑭ü¦Jµjà[‹°http://svn.php.net/viewvc?view=revision&revision=317040
>>>
>>> Log:
>>> Fix Bug #55726 (Changing the working directory makes router script inaccessible)
>>>
>>> Bug: https://bugs.php.net/55726 (Assigned) Changing the
>>> working directory makes router script inaccessible
>>>
>>> Changed paths:
>>> U php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
>>> U php/php-src/trunk/sapi/cli/php_cli_server.c
>>>
>>> Modified: php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c
>>> ===================================================================
>>> --- php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c 2011-09-20 05:42:36 UTC
>>> (rev 317039)
>>> +++ php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c 2011-09-20 07:06:55 UTC
>>> (rev 317040)
>>> @@ -1877,11 +1877,24 @@
>>> }
>>> {
>>> zend_file_handle zfd;
>>> +#if HAVE_BROKEN_GETCWD
>>> + int old_cwd_fd = -1;
>>> + old_cwd_fd = open(".", 0);
>>> +#else
>>> + char *old_cwd;
>>> + ALLOCA_FLAG(use_heap)
>>> +#define OLD_CWD_SIZE 4096
>>> + old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
>>> + old_cwd[0] = '\0';
>>> + php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
>>> +#endif
>>> +
>>> zfd.type = ZEND_HANDLE_FILENAME;
>>> zfd.filename = server->router;
>>> zfd.handle.fp = NULL;
>>> zfd.free_filename = 0;
>>> zfd.opened_path = NULL;
>>> +
>>> zend_try {
>>> zval *retval = NULL;
>>> if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1,
>>> &zfd)) {
>>> @@ -1893,6 +1906,18 @@
>>> decline = 1;
>>> }
>>> } zend_end_try();
>>> +
>>> +#if HAVE_BROKEN_GETCWD
>>> + if (old_cwd_fd != -1) {
>>> + fchdir(old_cwd_fd);
>>> + close(old_cwd_fd);
>>> + }
>>> +#else
>>> + if (old_cwd[0] != '\0') {
>>> + php_ignore_value(VCWD_CHDIR(old_cwd));
>>> + }
>>> + free_alloca(old_cwd, use_heap);
>>> +#endif
>>> }
>>>
>>> if (decline) {
>>>
>>> Modified: php/php-src/trunk/sapi/cli/php_cli_server.c
>>> ===================================================================
>>> --- php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-20 05:42:36 UTC (rev 317039)
>>> +++ php/php-src/trunk/sapi/cli/php_cli_server.c 2011-09-20 07:06:55 UTC (rev 317040)
>>> @@ -1877,11 +1877,24 @@
>>> }
>>> {
>>> zend_file_handle zfd;
>>> +#if HAVE_BROKEN_GETCWD
>>> + int old_cwd_fd = -1;
>>> + old_cwd_fd = open(".", 0);
>>> +#else
>>> + char *old_cwd;
>>> + ALLOCA_FLAG(use_heap)
>>> +#define OLD_CWD_SIZE 4096
>>> + old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
>>> + old_cwd[0] = '\0';
>>> + php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1));
>>> +#endif
>>> +
>>> zfd.type = ZEND_HANDLE_FILENAME;
>>> zfd.filename = server->router;
>>> zfd.handle.fp = NULL;
>>> zfd.free_filename = 0;
>>> zfd.opened_path = NULL;
>>> +
>>> zend_try {
>>> zval *retval = NULL;
>>> if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1,
>>> &zfd)) {
>>> @@ -1893,6 +1906,18 @@
>>> decline = 1;
>>> }
>>> } zend_end_try();
>>> +
>>> +#if HAVE_BROKEN_GETCWD
>>> + if (old_cwd_fd != -1) {
>>> + fchdir(old_cwd_fd);
>>> + close(old_cwd_fd);
>>> + }
>>> +#else
>>> + if (old_cwd[0] != '\0') {
>>> + php_ignore_value(VCWD_CHDIR(old_cwd));
>>> + }
>>> + free_alloca(old_cwd, use_heap);
>>> +#endif
>>> }
>>>
>>> if (decline) {
>>>
>>> --
>>> PHP CVS Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> --
>> Moriyoshi Koizumi
>> mozo@mozo.jp
>>
>>
>>