Skip to content

Commit 6674213

Browse files
authored
Remove dead code in fpm of redirect_status (#16090)
This is a feature copied from the CGI SAPI, but since cgi is always 0 in fpm, this code is dead. Similarly, the INI settings related to this are no longer used after removing this dead code.
1 parent 40f23d1 commit 6674213

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed

sapi/fpm/fpm/fpm_main.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,9 @@ typedef struct _php_cgi_globals_struct {
143143
bool rfc2616_headers;
144144
bool nph;
145145
bool fix_pathinfo;
146-
bool force_redirect;
147146
bool discard_path;
148147
bool fcgi_logging;
149148
bool fcgi_logging_request_started;
150-
char *redirect_status_env;
151149
HashTable user_config_cache;
152150
char *error_header;
153151
char *fpm_config;
@@ -1423,8 +1421,6 @@ static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_
14231421
PHP_INI_BEGIN()
14241422
STD_PHP_INI_BOOLEAN("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
14251423
STD_PHP_INI_BOOLEAN("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
1426-
STD_PHP_INI_BOOLEAN("cgi.force_redirect", "1", PHP_INI_SYSTEM, OnUpdateBool, force_redirect, php_cgi_globals_struct, php_cgi_globals)
1427-
STD_PHP_INI_ENTRY("cgi.redirect_status_env", NULL, PHP_INI_SYSTEM, OnUpdateString, redirect_status_env, php_cgi_globals_struct, php_cgi_globals)
14281424
STD_PHP_INI_BOOLEAN("cgi.fix_pathinfo", "1", PHP_INI_SYSTEM, OnUpdateBool, fix_pathinfo, php_cgi_globals_struct, php_cgi_globals)
14291425
STD_PHP_INI_BOOLEAN("cgi.discard_path", "0", PHP_INI_SYSTEM, OnUpdateBool, discard_path, php_cgi_globals_struct, php_cgi_globals)
14301426
STD_PHP_INI_BOOLEAN("fastcgi.logging", "1", PHP_INI_SYSTEM, OnUpdateBool, fcgi_logging, php_cgi_globals_struct, php_cgi_globals)
@@ -1437,8 +1433,6 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals)
14371433
{
14381434
php_cgi_globals->rfc2616_headers = 0;
14391435
php_cgi_globals->nph = 0;
1440-
php_cgi_globals->force_redirect = 1;
1441-
php_cgi_globals->redirect_status_env = NULL;
14421436
php_cgi_globals->fix_pathinfo = 1;
14431437
php_cgi_globals->discard_path = 0;
14441438
php_cgi_globals->fcgi_logging = 1;
@@ -1549,7 +1543,7 @@ static zend_module_entry cgi_module_entry = {
15491543
int main(int argc, char *argv[])
15501544
{
15511545
int exit_status = FPM_EXIT_OK;
1552-
int cgi = 0, c, use_extended_info = 0;
1546+
int c, use_extended_info = 0;
15531547
zend_file_handle file_handle;
15541548

15551549
/* temporary locals */
@@ -1767,46 +1761,6 @@ int main(int argc, char *argv[])
17671761
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
17681762
}
17691763

1770-
/* check force_cgi after startup, so we have proper output */
1771-
if (cgi && CGIG(force_redirect)) {
1772-
/* Apache will generate REDIRECT_STATUS,
1773-
* Netscape and redirect.so will generate HTTP_REDIRECT_STATUS.
1774-
* redirect.so and installation instructions available from
1775-
* http://www.koehntopp.de/php.
1776-
* -- kk@netuse.de
1777-
*/
1778-
if (!getenv("REDIRECT_STATUS") &&
1779-
!getenv ("HTTP_REDIRECT_STATUS") &&
1780-
/* this is to allow a different env var to be configured
1781-
* in case some server does something different than above */
1782-
(!CGIG(redirect_status_env) || !getenv(CGIG(redirect_status_env)))
1783-
) {
1784-
zend_try {
1785-
SG(sapi_headers).http_response_code = 400;
1786-
PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
1787-
<p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\
1788-
means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
1789-
set, e.g. via an Apache Action directive.</p>\n\
1790-
<p>For more information as to <i>why</i> this behaviour exists, see the <a href=\"http://php.net/security.cgi-bin\">\
1791-
manual page for CGI security</a>.</p>\n\
1792-
<p>For more information about changing this behaviour or re-enabling this webserver,\n\
1793-
consult the installation file that came with this distribution, or visit \n\
1794-
<a href=\"http://php.net/install.windows\">the manual page</a>.</p>\n");
1795-
} zend_catch {
1796-
} zend_end_try();
1797-
#if defined(ZTS) && !PHP_DEBUG
1798-
/* XXX we're crashing here in msvc6 debug builds at
1799-
* php_message_handler_for_zend:839 because
1800-
* SG(request_info).path_translated is an invalid pointer.
1801-
* It still happens even though I set it to null, so something
1802-
* weird is going on.
1803-
*/
1804-
tsrm_shutdown();
1805-
#endif
1806-
return FPM_EXIT_SOFTWARE;
1807-
}
1808-
}
1809-
18101764
#if ZEND_RC_DEBUG
18111765
old_rc_debug = zend_rc_debug;
18121766
zend_rc_debug = 0;

0 commit comments

Comments
 (0)