Re: cvs: php-src(PHP_5_2) / NEWS /ext/standard proc_open.c
| From: | Nuno Lopes | Date: | Sat, 06 Jan 2007 16:48:19 +0000 |
| Subject: | Re: cvs: php-src(PHP_5_2) / NEWS /ext/standard proc_open.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-42579@lists.php.net to get a copy of this message | ||
Uhm, maybe we can also apply this to unix code (skip 'sh')?
----- Original Message ----- From: "Dmitry Stogov" <dmitry@php.net>
To: <php-cvs@lists.php.net>
Sent: Saturday, January 06, 2007 9:02 AM
Subject: [PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/standard proc_open.c
dmitry Sat Jan 6 09:02:02 2007 UTCModified files: (Branch: PHP_5_2)/php-src NEWS /php-src/ext/standard proc_open.c Log: Improved proc_open(). Now on Windows it can run external commands not through CMD.EXE http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.473&r2=1.2027.2.547.2.474&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.473 php-src/NEWS:1.2027.2.547.2.474 --- php-src/NEWS:1.2027.2.547.2.473 Thu Jan 4 23:55:56 2007 +++ php-src/NEWS Sat Jan 6 09:02:02 2007 @@ -1,6 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Jan 2007, PHP 5.2.1RC3 +- Improved proc_open(). Now on Windows it can run external commands not through + CMD.EXE. (Dmitry) 04 Jan 2007, PHP 5.2.1RC2 - Small optimization of the date() function (Matt,Ilia) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/proc_open.c?r1=1.36.2.1.2.6&r2=1.36.2.1.2.7&diff_format=u Index: php-src/ext/standard/proc_open.c diff -u php-src/ext/standard/proc_open.c:1.36.2.1.2.6 php-src/ext/standard/proc_open.c:1.36.2.1.2.7 --- php-src/ext/standard/proc_open.c:1.36.2.1.2.6 Tue Jan 2 15:29:09 2007 +++ php-src/ext/standard/proc_open.c Sat Jan 6 09:02:02 2007 @@ -15,7 +15,7 @@ | Author: Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: proc_open.c,v 1.36.2.1.2.6 2007/01/02 15:29:09 nlopess Exp $ */ +/* $Id: proc_open.c,v 1.36.2.1.2.7 2007/01/06 09:02:02 dmitry Exp $ */ #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__)) # define _BSD_SOURCE /* linux wants this when XOPEN mode is on */ @@ -489,6 +489,7 @@ int is_persistent = 0; /* TODO: ensure that persistent procs will work */ #ifdef PHP_WIN32 int suppress_errors = 0; + int bypass_shell = 0; #endif #if PHP_CAN_DO_PTS php_file_descriptor_t dev_ptmx = -1; /* master */ @@ -509,10 +510,17 @@ if (other_options) { zval **item; if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), "suppress_errors", sizeof("suppress_errors"), (void**)&item)) { - if (Z_TYPE_PP(item) == IS_BOOL && Z_BVAL_PP(item)) { + if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) &&+ Z_LVAL_PP(item)) {suppress_errors = 1; } } + if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), "bypass_shell", sizeof("bypass_shell"), (void**)&item)) { + if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) &&+ Z_LVAL_PP(item)) {+ bypass_shell = 1; + } + } } #endif @@ -727,21 +735,25 @@ memset(&pi, 0, sizeof(pi)); - command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof(" /c ")); - sprintf(command_with_cmd, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command); - if (suppress_errors) { old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX); } - newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi); + if (bypass_shell) { + newprocok = CreateProcess(NULL, command, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi); + } else { + command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof(" /c ")); + sprintf(command_with_cmd, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command); + + newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi); + + efree(command_with_cmd); + } if (suppress_errors) { SetErrorMode(old_error_mode); } - efree(command_with_cmd); - if (FALSE == newprocok) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "CreateProcess failed"); goto exit_fail; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php