Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005202 [Resin] major always 08-30-12 22:45 08-31-12 10:48
Reporter ssmax View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 4.0.29
Summary 0005202: sendfile file permision error return 0 byte.
Description resin pro 4.0.29 --enable-64bit --enable-jni
jdk: oracle java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
os: centos 5.8 final
kernel: 2.6.18-308.1.1.el5 / 2.6.18-308.13.1.el5 / etc..

start resin pro with config:
setuid_user : nobody
setuid_group : nobody
sendfile : true

visit the regular file using resin-file, for example:
-rw-r--r-- 1 root root 14 Aug 31 12:20 /home/resin/webapps/ROOT/test.txt

http://127.0.0.1/test.txt [^]

if the file havn't the write permission for the user who start the resin, then http response will return the right length but 0 byte like :

--------------------------
HTTP/1.1 200 OK
Server: Resin/4.0.29
ETag: "CXpHhK1fUZd"
Last-Modified: Fri, 31 Aug 2012 04:34:23 GMT
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
Content-Length: 14
Date: Fri, 31 Aug 2012 05:23:42 GMT

(but nothing here , 0 byte)

--------------------------

i trace down the code and found something strange here:
resin-pro-4.0.29/modules/c/src/resin_os/jni_socket.c
line 471 in jni_open_file block:

 flags = O_RDWR|O_CREAT;

this set a read and write flag when opening the file, and sendfile will use this fd to send the file to the socket.

fd = jni_open_file(env, name, name_length);
....
result = sendfile(conn->fd, fd, &sendfile_offset, file_length);

when operate the file which resin has no write permission, i guess there will be a problem here.

so i edit the code like :
 flags = O_RDONLY;

and recompile resin , start it with same config above.
and everythig gets right.
Additional Information
Attached Files

- Relationships

- Notes
(0006032)
ferg
08-31-12 10:48

server/1c15
 

- Issue History
Date Modified Username Field Change
08-30-12 22:45 ssmax New Issue
08-31-12 10:48 ferg Note Added: 0006032
08-31-12 10:48 ferg Assigned To  => ferg
08-31-12 10:48 ferg Status new => closed
08-31-12 10:48 ferg Resolution open => fixed
08-31-12 10:48 ferg Fixed in Version  => 4.0.31


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker