Opened 4 years ago

Closed 4 years ago

#731 closed defect (fixed)

client_body_temp_path with levels does not work in some cases.

Reported by: deathbaba@… Owned by:
Priority: major Milestone:
Component: nginx-core Version: 1.6.x
Keywords: Cc:
uname -a: Darwin Mac.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64 Linux CentOS 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.6.2 built by clang 6.0 (clang-600.0.56) (based on LLVM 3.5svn) TLS SNI support enabled configure arguments: --prefix=/usr/local/Cellar/nginx/1.6.2 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx/1.6.2/bin/nginx --with-cc-opt='-I/usr/local/Cellar/pcre/8.36/include -I/usr/local/Cellar/openssl/1.0.1j_1/include' --with-ld-opt='-L/usr/local/Cellar/pcre/8.36/lib -L/usr/local/Cellar/openssl/1.0.1j_1/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module nginx version: nginx/1.0.15 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) TLS SNI support enabled configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=-Wl,-E

Description

client_body_temp_path /tmp/stats_log 4 4 4;

gives the following error in the log (and of course, nothing is saved on a disk).

015/03/10 18:25:29 [crit] 23272#0: *15 mkdir() "/tmp/stats_log/0002/0000/0/00" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "POST /stats HTTP/1.1", host: "localhost:8080"

The issue disappears if sum of levels is <= 12, e.g. the following lines works fine:

client_body_temp_path /tmp/stats_log 3 3 4;
client_body_temp_path /tmp/stats_log 4 3 3;

Full config is here:

server {
  #...

  location = /does_not_save_post_bodies {
    limit_except POST { deny all; }
    client_body_temp_path /tmp/stats_log 4 4 4;
    client_body_in_file_only on;
    client_body_buffer_size 1M;
    client_max_body_size 100M;

    access_log /tmp/stats-access.log combined;
    error_log  /tmp/stats-error.log info;

    proxy_pass_request_headers on;
    proxy_set_header X-FILE $request_body_file;
    proxy_set_body off;
    proxy_redirect off;
    proxy_pass http://localhost:8080/alohalytics;
 }

 location /alohalytics {
   add_header Content-Type text/plain;
   return 200 Mahalo;
  }
}

Change History (3)

comment:1 Changed 4 years ago by pluknet

  • Status changed from new to accepted

comment:2 Changed 4 years ago by Sergey Kandaurov <pluknet@…>

In 7bdd34cd27114e7376c9e53c815b51108f94be89/nginx:

Core: limited levels of subdirectory hierarchy used for temp files.

Similar to ngx_http_file_cache_set_slot(), the last component of file->name
with a fixed length of 10 bytes, as generated in ngx_create_temp_path(), is
used as a source for the names of intermediate subdirectories with each one
taking its own part. Ensure that the sum of specified levels with slashes
fits into the length (ticket #731).

comment:3 Changed 4 years ago by pluknet

  • Resolution set to fixed
  • Status changed from accepted to closed

Thanks, this bug is fixed in 1.7.12.

Note: See TracTickets for help on using tickets.