[nginx] svn commit: r4495 - in trunk/src/http: . modules modules/perl

vbart at nginx.com vbart at nginx.com
Mon Feb 27 16:51:29 UTC 2012


Author: vbart
Date: 2012-02-27 16:51:28 +0000 (Mon, 27 Feb 2012)
New Revision: 4495

Modified:
   trunk/src/http/modules/ngx_http_flv_module.c
   trunk/src/http/modules/ngx_http_gzip_static_module.c
   trunk/src/http/modules/ngx_http_index_module.c
   trunk/src/http/modules/ngx_http_log_module.c
   trunk/src/http/modules/ngx_http_mp4_module.c
   trunk/src/http/modules/ngx_http_static_module.c
   trunk/src/http/modules/perl/nginx.xs
   trunk/src/http/ngx_http_core_module.c
   trunk/src/http/ngx_http_core_module.h
   trunk/src/http/ngx_http_script.c
Log:
Disable symlinks: initialization of the "disable_symlinks" field in
ngx_open_file_info_t moved to a separate function.

This is preparation for the "from=" parameter implementation of the
"disabled_symlinks" directive.


Modified: trunk/src/http/modules/ngx_http_flv_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_flv_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/ngx_http_flv_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -109,10 +109,11 @@
     of.min_uses = clcf->open_file_cache_min_uses;
     of.errors = clcf->open_file_cache_errors;
     of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/modules/ngx_http_gzip_static_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_gzip_static_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/ngx_http_gzip_static_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -129,10 +129,11 @@
     of.min_uses = clcf->open_file_cache_min_uses;
     of.errors = clcf->open_file_cache_errors;
     of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/modules/ngx_http_index_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_index_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/ngx_http_index_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -209,10 +209,11 @@
         of.test_only = 1;
         of.errors = clcf->open_file_cache_errors;
         of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-        of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+        if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+            return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        }
+
         if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
             != NGX_OK)
         {
@@ -307,10 +308,11 @@
     of.test_only = 1;
     of.valid = clcf->open_file_cache_valid;
     of.errors = clcf->open_file_cache_errors;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &dir, &of) != NGX_OK) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/modules/ngx_http_log_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_log_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/ngx_http_log_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -394,10 +394,12 @@
         of.test_only = 1;
         of.errors = clcf->open_file_cache_errors;
         of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-        of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+        if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+            /* simulate successful logging */
+            return len;
+        }
+
         if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
             != NGX_OK)
         {
@@ -444,10 +446,12 @@
     of.valid = llcf->open_file_cache_valid;
     of.min_uses = llcf->open_file_cache_min_uses;
     of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &log, &of) != NGX_OK) {
+        /* simulate successful logging */
+        return len;
+    }
+
     if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/modules/ngx_http_mp4_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_mp4_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/ngx_http_mp4_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -440,10 +440,11 @@
     of.min_uses = clcf->open_file_cache_min_uses;
     of.errors = clcf->open_file_cache_errors;
     of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/modules/ngx_http_static_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_static_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/ngx_http_static_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -94,10 +94,11 @@
     of.min_uses = clcf->open_file_cache_min_uses;
     of.errors = clcf->open_file_cache_errors;
     of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/modules/perl/nginx.xs
===================================================================
--- trunk/src/http/modules/perl/nginx.xs	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/modules/perl/nginx.xs	2012-02-27 16:51:28 UTC (rev 4495)
@@ -662,10 +662,11 @@
     of.min_uses = clcf->open_file_cache_min_uses;
     of.errors = clcf->open_file_cache_errors;
     of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+        XSRETURN_EMPTY;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
         != NGX_OK)
     {

Modified: trunk/src/http/ngx_http_core_module.c
===================================================================
--- trunk/src/http/ngx_http_core_module.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/ngx_http_core_module.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -1320,10 +1320,12 @@
         of.test_only = 1;
         of.errors = clcf->open_file_cache_errors;
         of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-        of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+        if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+            return NGX_OK;
+        }
+
         if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
             != NGX_OK)
         {
@@ -2645,6 +2647,18 @@
 }
 
 
+ngx_int_t
+ngx_http_set_disable_symlinks(ngx_http_request_t *r,
+    ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of)
+{
+#if (NGX_HAVE_OPENAT)
+    of->disable_symlinks = clcf->disable_symlinks;
+#endif
+
+    return NGX_OK;
+}
+
+
 static char *
 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
 {

Modified: trunk/src/http/ngx_http_core_module.h
===================================================================
--- trunk/src/http/ngx_http_core_module.h	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/ngx_http_core_module.h	2012-02-27 16:51:28 UTC (rev 4495)
@@ -509,6 +509,10 @@
 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
 
 
+ngx_int_t ngx_http_set_disable_symlinks(ngx_http_request_t *r,
+    ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of);
+
+
 extern ngx_module_t  ngx_http_core_module;
 
 extern ngx_uint_t ngx_http_max_module;

Modified: trunk/src/http/ngx_http_script.c
===================================================================
--- trunk/src/http/ngx_http_script.c	2012-02-27 16:46:57 UTC (rev 4494)
+++ trunk/src/http/ngx_http_script.c	2012-02-27 16:51:28 UTC (rev 4495)
@@ -1505,10 +1505,13 @@
     of.test_only = 1;
     of.errors = clcf->open_file_cache_errors;
     of.events = clcf->open_file_cache_events;
-#if (NGX_HAVE_OPENAT)
-    of.disable_symlinks = clcf->disable_symlinks;
-#endif
 
+    if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+        e->ip = ngx_http_script_exit;
+        e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
+        return;
+    }
+
     if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
         != NGX_OK)
     {



More information about the nginx-devel mailing list