SliTaz SliTaz Forum

You are not logged in.

#1 2013-03-10 13:32:02

emgi
Member
Registered: 2012-12-17
Posts: 127

lighttpd issue

Fortunately this issue is already solved but others might come across it as well.

One of the things I want to do in my project is to permit uploading files (by registered users only).

In order to allow this I adapted the basic script at http://perlmeme.org/tutorials/cgi_upload.html

One of the issues to address is to set the max file size. I wanted to set the maximum file size at 6MB using the well documented CGI::POST_MAX from perl.

When setting this to a low value like 2k for testing everything seemed fine but when I wanted to upload something roughly over 50k, I always got http error message: 413-Request entity too large.

Initially I checked and re-checked my script but nothing came up.

That was the right moment to take the dogs for a walk!

During the walk it dawned upon me that the error might be external, i.e. in lighttpd.

When checking the error.log upon my return, this suspicion was confirmed. The following message was abundantly present:

2013-03-10 13:06:25: (connections.c.1117) denying upload as opening to temp-file for upload failed: /var/tmp/lighttpd-upload-1qcg74 Permission denied

So this means httpd is creating a temp-file in /var/tmp for large uploads but user www (as which lighttpd runs) doesn't have write permissions here. I solved it, at least temporarily by setting the group for /var/tmp to www and changing the mode:

root@svm01:/var# ls -l | grep tmp

drwxr-xr-x    2 root     root          4096 Dec 18 13:11 tmp

root@svm01:/var# chown .www tmp

root@svm01:/var# chmod 775 tmp

root@svm01:/var#  ls -l | grep tmp

drwxrwxr-x    2 root     www           4096 Dec 18 13:11 tmp

root@svm01:/var#

After this, the uploads work as intended. No files remain in /var/tmp/ when the upload is completed.

Although it would perhaps be better (for security freaks) to have a dedicated upload folder for lighttpd, this solution is good enough for me.

/emgi

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.016 seconds, 7 queries executed - Memory usage: 1.53 MiB (Peak: 1.77 MiB) ]