views:

280

answers:

4

Hi
I'm trying to initialize a session but i get this error:

Warning: session_start() [function.session-start]: open(/tmp/sess_7af3ee9ec1350680bedcf63833d160bd, O_RDWR) failed: Permission denied (13)

The session.path is set to /tmp with 777 perms.

I try to edit the session.path to "0;777;/tmp" but the session files are created with the wrong permissions(only write).

I'm using PHP 5.2 on apache2 and ubuntu 9.10. Any ideas?

+1  A: 

It seems like you do not have permissions to write to the tmp directory, you need to give it permissions to save a file.

Anthony Forloney
+1: Reminds me of last week when a machine I ran across that someone else set up had /tmp as 0770 instead of 1777 or 1666. Come to think of it, that was a Ubuntu Server too.
R. Bemrose
It looks like he's already stated that /tmp's perms are set to 777.
Marc W
+2  A: 

Please verify that the permissions of /tmp really are xx777

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$s = stat('/tmp');
printf('%o', $s[2]);
file_put_contents('/tmp/phptest1234.txt', 'test');
unlink('/tmp/phptest1234.txt');

edit: next try, umask

<?php
echo ' php-umask: ', sprintf('%o', umask()), "\n";
echo ' exec-umask: ', exec('umask'), "\n";
VolkerK
Your script returns 44777.The session files are written in /tmp but with wrong permissions: php create session files with 100366 permissions. I can write but not read.
Daniel
That sounds like an umask of 0411, see edit.
VolkerK
It returns:php-umask: 22 exec-umask: 0022
Daniel
That's odd. If you create a file in /tmp on the shell like e.g. `ls -la > /tmp/mytestfile.deleteAtAnyTime` does it also have the mode set to 100366?
VolkerK
No, the permissions are correctly 644 only session files are created with wrong perms. Maybe there is a bug like this:http://bugs.php.net/bug.php?id=31323
Daniel
A: 

I resolve the problem, there was a third party library that sets wrong umask to 777, by deleting it the problem was solved. Thanks for answers.

Daniel
I have the same problem . how can I resolve it ? . thanks
bader
A: 

I had this problem, as well. There was a line in /etc/sysconfig/httpd that was setting the umask improperly, so I commented it out:

#umask 644

All is well now.

Brad Griffith