hiigara Posted October 30, 2008 Share Posted October 30, 2008 I am running apache 2.0.55, with PHP 5.1.2 as CGI. I have this mockup upload form to reproduce my problem: -------------------------------------------------- <form action="upload_form.post.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" size="20"> <input type="submit" value="Upload file"> </form> -------------------------------------------------- I have this form processing code: -------------------------------------------------- sleep ( 10) ; $newfile = "files/" . $_FILES['file']['name'] ; move_uploaded_file ( $_FILES['file']['tmp_name'], $newfile ) ; -------------------------------------------------- During the sleep I have an ssh shell open and do ls -la on /tmp/. The temporary file is there, but with permissions rw- --- ---. Why is this a problem? you ask. Because I am uploading pictures to a gallery and then the gallery script cannot read these pictures to display them on the browser. Why don't you do: chmod($newfile , 0644); after move_uploaded_file ? you ask. Because I am a hosting reseller and I have a few people who don't know much about PHP, installing scripts on my server, and their scripts may also rely on the fact that files are uploaded with 644. Then I would have to fix each of my customers scripts one by one. Insane. I don't know if this is an apache or a php issue. Anyways here is the relevant apache configuration, it uses suphp: -------------------------------------------------- AddHandler application/x-httpd-php5 .php5 .php AddHandler application/x-httpd-php .php4 AddType application/x-httpd-php5 .php5 .php AddType application/x-httpd-php .php4 AddHandler application/x-suphp-cgi .cgi .pl .rb .py LoadModule suphp_module /usr/lib/apache2/modules/mod_suphp.so <IfModule mod_suphp.c> suPHP_Engine on suPHP_ConfigPath /etc/suphp/suphp.conf suPHP_AddHandler application/x-httpd-php suPHP_AddHandler application/x-httpd-php5 suPHP_AddHandler application/x-suphp-cgi </IfModule> -------------------------------------------------- And suphp.conf has: -------------------------------------------------- [global] ;Path to logfile logfile=/var/log/suphp/suphp.log ;Loglevel loglevel=info ;User Apache is running as webserver_user=www-data ;Path all scripts have to be in ;docroot=/var/www ;Path to chroot() to before executing script ;chroot=/mychroot ; Security options allow_file_group_writeable=true allow_file_others_writeable=false allow_directory_group_writeable=true allow_directory_others_writeable=false ;Check wheter script is within DOCUMENT_ROOT. Was true, but has to be false to ;work with apache2? check_vhost_docroot=false ;Send minor error messages to browser errors_to_browser=true ;PATH environment variable env_path=/bin:/usr/bin ;Umask to set, specify in octal notation umask=0022 ; Minimum UID min_uid=100 ; Minimum GID min_gid=30 [handlers] ;Handler for php-scripts application/x-httpd-php=php:/usr/bin/php4-cgi application/x-httpd-php5=php:/usr/bin/php5-cgi ;Handler for CGI-scripts application/x-suphp-cgi=execute:!self -------------------------------------------------- suphp seems to have the correct mask. Why I am getting 600 permissions? Thanks Ian Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.