move_uploaded_file does not set right permissions (ignores umask)

Bug #294148 reported by Hark
6
Affects Status Importance Assigned to Milestone
php
Unknown
Unknown
php5 (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Binary package hint: php5

After calling move_uploaded_file a file should get permissions according to the set umask. When /tmp is on the same partition as the file's destination this doesn't happen, the file gets mode 600 making it unreadable by Apache.

I think this bug was introduced in an upgrade a few weeks maybe months ago.

This does remind me very much of an old (resolved) bug in PHP: http://bugs.php.net/bug.php?id=42291

Revision history for this message
Andreas Olsson (andol) wrote :

What versions of Ubuntu and PHP are involved?

Would it be possible to provide some example code where you use move_uploaded_file? Was a while ago since I wrote PHP code myself :)

Changed in php5:
status: New → Incomplete
Revision history for this message
Andreas Olsson (andol) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!

Changed in php5:
status: Incomplete → Invalid
Revision history for this message
Nicolas (nicolasfr) wrote :

Hi,

I am experiencing the same problem since I upgraded my server (I only upgraded a couple of week ago, the system is on production for about 6 months).

My server is running Ubuntu 8.04. The version of PHP5 I am using is:

root@hosting:~# php-cgi -v
PHP 5.2.4-2ubuntu5.5 with Suhosin-Patch 0.9.6.2 (cgi-fcgi) (built: Feb 11 2009 20:02:50)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Problem is: files uploaded through a PHP upload form and then moved with move_uploaded_file are given a umask of 0002 insted of 0022.

Changed in php5:
status: Invalid → New
Revision history for this message
Andreas Olsson (andol) wrote :

Guess I shouldn't have been so eager to close this bug.

@Nicolas: Thanks for reopening it and providing the needed version information.

I can confirm this issue on Ubuntu 8.04 (libapache2-mod-php5: 5.2.4-2ubuntu5.5). As Hark mentions this bug only seems to affect the case when the php upload_tmp_dir is on the same file system as the file's destination.

The php versions in Ubuntu 8.10 and 9.04 seems to obey the set umask just fine.

Changed in php5:
status: New → Confirmed
Andreas Olsson (andol)
Changed in php5 (Ubuntu):
importance: Undecided → Low
Revision history for this message
chrisf (chris-foerg) wrote :

Hi,

is there any solution for Ubuntu 8.04 LTS?

Thanks,
Christian

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.