Welcome! Log In Create A New Profile

Advanced

Re: post_action crash

Maxim Dounin
January 14, 2010 09:20PM
Hello!

On Thu, Jan 14, 2010 at 06:44:28PM -0500, Alexey Kovyrin wrote:

> А я именно точно урл записываю в post_action :-) Для всего остального
> (миллион реврайтов и тп фигни) работает.

Т.е. ты сознательно используешь *неименованный* location,
начинающийся на "@" вместо "/"? Мсье знает толк в извращениях...

Начиная с 0.6.27 post_action понимает именованные location'ы, и
соответственно заставить его использовать статический location
"@blah" нельзя.

Вообще IMHO то что можно использовать обычные location'ы не
начинающиеся со слеша - это скорее бага.

> Да и прав Максим - корок быть не должно никогда.

Патч.

Maxim Dounin
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1263521683 -10800
# Node ID 0a974cceb9de159f2daafecf6858518db4688224
# Parent c003006f3f03505d329411b58db5c515d19de5b8
Core: resolve various cycles with named locations and post_action.

Now redirects to named locations are counted against normal uri changes
limit, and post_action respect this limit as well. As a result at least the
following (bad) configurations no longer trigger infinite cycle:

1. Post action which recursively triggers post action:

location / {
post_action /index.html;
}

2. Post action pointing to nonexistent named location:

location / {
post_action @nonexistent;
}

3. Recursive error page for 500 (Internal Server Error) pointing to
nonexistent named location:

location / {
recursive_error_pages on;
error_page 500 @nonexistent;
return 500;
}

diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -2208,6 +2208,16 @@ ngx_http_named_location(ngx_http_request
ngx_http_core_main_conf_t *cmcf;

r->main->count++;
+ r->uri_changes--;
+
+ if (r->uri_changes == 0) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "rewrite or internal redirection cycle "
+ "while redirect to named location \"%V\"", name);
+
+ ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return NGX_DONE;
+ }

cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);

diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -2842,6 +2842,10 @@ ngx_http_post_action(ngx_http_request_t
return NGX_DECLINED;
}

+ if (r->post_action && r->uri_changes == 0) {
+ return NGX_DECLINED;
+ }
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"post action: \"%V\"", &clcf->post_action);

_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

Re: post_action crash

Alexey Kovyrin January 14, 2010 12:02AM

Re: post_action crash

Kruglov Eugenie January 14, 2010 01:10AM

Re: post_action crash

Alexey Kovyrin January 14, 2010 02:20AM

Re: post_action crash

Kruglov Eugenie January 14, 2010 02:24AM

Re: post_action crash

Maxim Dounin January 14, 2010 05:20AM

Re: post_action crash

Alexey Kovyrin January 14, 2010 06:46PM

Re: post_action crash

Maxim Dounin January 14, 2010 09:20PM

Re: post_action crash

Alexey Kovyrin January 17, 2010 01:26AM

Re: post_action crash

Maxim Dounin January 17, 2010 06:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 127
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready