[mod_python] Request.sendfile() and symlinks

Wim Heirman Wim.Heirman at UGent.be
Sat Oct 15 10:04:20 EDT 2005


Ok, found it: in req_sendfile(), apr_stat is called with the APR_READ flag. 
APR_READ is however an invalid flag there, apr_stat interprets it as 
APR_FINFO_LINK (they're both #define'd as 1) making it behave as an 
lstat(). APR_FINFO_NORM would probably be the right value for the 3rd 
argument.


Regards,
Wim.


> Can't look at it until tomorrow, but check code in src/requestobject.c of 
> mod_python
> source code. The req_sendfile() may well have a bug in it as does a stat of 
> the
> file to get the length and when it tells Apache to send the file it passes 
> that length
> to the underlying call as the number of bytes to send. If the stat call is 
> being
> performed on the symlink as it appears and not what it points at, the wrong 
> length
> would be used. The contents of the actual file will be sent though as the 
> symlink
> will be followed correctly at that point, just not enough is sent.
>
> Maybe someone else can look at this while I get some sleep. ;-)
>
> Graham
>
> On 15/10/2005, at 10:37 PM, Wim Heirman wrote:
>
>> Hello,
>> 
>> When I call req.sendfile(filename) where filename is a symbolic link, only 
>> part of the file is sent to the client (as many bytes as there are 
>> characters in the symlink's file reference, so for a symlink pointing to 
>> '../index.html' I get the first 13 bytes of the correct file). Is this 
>> normal behaviour?
>> 
>> Also, I would like to set the Content-Type correctly, based on the file I'm 
>> sending. Using the standard mimetypes package works fine, but is it 
>> possible to use Apache's mime-typing for this? Since the code for that is 
>> already loaded it should be a bit more efficient.
>> 
>> Regards,
>> 
>> Wim
>> 
>> 
>> -- 
>> ir. Wim Heirman,
>> ELIS Department, Ghent University, Belgium
>> Phone: +32-9-264.95.27
>> E-mail: wim.heirman at elis.UGent.be
>> http://www.elis.UGent.be/~wheirman/
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>> 
>

-- 
ir. Wim Heirman,
ELIS Department, Ghent University, Belgium
Phone: +32-9-264.95.27
E-mail: wim.heirman at elis.UGent.be
http://www.elis.UGent.be/~wheirman/


More information about the Mod_python mailing list