Solved

session_start(): open(/tmp/sess_aabb3a6218468f7eb03c8a4b732b2be2, O_RDWR) failed: Permission denied (13)

Posted on 2004-04-29
18
11,522 Views
Last Modified: 2011-08-18
I know this question has been answered before at least once here:
http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20909827.html

but that didn't seem to help my problem.  I am hosting my own php/apache server and most solutions I've found for this problem is "Asked sys admin to fix it"  Well I'm the sysadmin and I can't fix it :)

this is the error:
Warning: session_start(): open(/tmp/sess_aabb3a6218468f7eb03c8a4b732b2be2, O_RDWR) failed: Permission denied (13) in /home/esports/public_html/authenticate.php on line 2

It should be noted that this is an intermittant problem.  It'll work about 90% of the time then you get this error and I get stumped.

this is what I've tried so far
-I've 777'd the temporary directory /tmp there are numerous sess_* files in there already
-I've tried using ini_set to change save path to a local dir
-I've viewed the php settings page and the session save path is /tmp

Any new ideas on this one?  Thanks
0
Comment
Question by:DaK00L1
  • 8
  • 6
  • 2
  • +2
18 Comments
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10950654
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 10950845
cthe cgi-central says to change permissions, which are already set to 777 and  I'm not sure what the comparison operators have to do with this... can you elaborate?
0
 
LVL 6

Expert Comment

by:aolXFT
ID: 10951889
From your error this clearly isn't a Problem with PHP, so much as it is a problem with your enviornment. The syscall to open the file has failed.

Are you using Linux? Are you sure there is sufficient space in /tmp

What filesystem are you using?

I suspect that your problem is with your kernel(as it is a system call that fails).
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 10952625
File system: EXT3
O/S: RedHat Linux 9
Linux: 2.4.20-8
free space - 20 gig +

I have googled this problem and it seems to be a common problem with php but I have yet to find a solution that works for me.  The fact that it is in intermitant problem leads me to believe I have some kind of timeout problem or permissions problem.
0
 
LVL 9

Expert Comment

by:techtonik
ID: 10955041
A very common problem, you're right.
Change you session.save_path in your php.ini or via ini_set.
Make sure you're using right php.ini

Hmm.. It also can be if you're passing sessions between different PHP's handlers.
To say one is CGI and one is mod_php. Check permissions and owners on session files.
It can be, that owner is mod_php and permissions are set for session file so that CGI version can't read them, because it is running under different user.

If nothing helps, provide your PHP version.
0
 
LVL 3

Expert Comment

by:Aliev
ID: 10957066
Tray to delete that file. And then give to tmp filder chmod 755
0
 
LVL 6

Expert Comment

by:aolXFT
ID: 10958421
I would recommend crossposting this on the Linux area of the site.

Can you show us the permissions of a created session file?

I would also suggest checking your syslogs for any hints. of what is wrong.
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 10961912
Session save path is /tmp, and I have sessions already in the /tmp dir.

aolXFT - I'm pretty this is a php settings problem because there are posts in forums about the same problem on a windows box.
http://p2p.wrox.com/topic.asp?TOPIC_ID=6665

Aliev - if I delete the sess_* files then everything works again.

OK! I just did an ls on my tmp and found that some of the sessions have 000 as permissions.   while some have the proper 600.  Is there anyway to explicitly set the permission of the session file?  Does anyone know why some sessions are 000 and some are 600?

ls -al /tmp
<snippet>
17418ce039f6e
----------    1 apache   apache        109 Apr 30 10:26 sess_9e8c09293210dedff29
0bb8a7953faa4
----------    1 apache   apache          0 Apr 30 08:24 sess_ac59bd6390a2d80cab4
4f1682ced0822
-rw-------    1 apache   apache        109 Apr 30 08:30 sess_ec42d20f4f2083c6766
</snippet>

I normally don't post my pages but I'm really stumped so this is the php info page...
http://esports.missolutions.ca/test2.php
Does anyone see anything in the session section that could be causing it?


One more thing is  $_SESSION['sSessionName'] the same as  $_SESSION["sSessionName"]?

thanks for the help
0
 
LVL 9

Expert Comment

by:techtonik
ID: 10968077
Perhaps some cron job, which sets 000 attributes, so nobody can read temp files. Or some script explicitly chmod's them. These are only ideas that came into my mind. Try to make different directory for sessions and set audit for it somehow.
0
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:aolXFT
ID: 10968174
I'd agree with techtonik on this one.

Something seems to be changeing the permissions on your session files.

The handiest way would be to try putting your sessions somewhere else (ie outside of /tmp), by setting the php.ini accordingly.

If you want a quick fix, you could just dynamicly chmod them back to whatever they should be

chmod ("/tmp/sess_" . $_COOKIE['PHPSESSID'], 0600)

or something like that before calling session_start();

>> $_SESSION['sSessionName'] the same as  $_SESSION["sSessionName"]
They are the same. The only difference I see is that Strings are delimited by single and dbl quotes. This would only make a difference if you wanted to use escapable characters(like \"'$, etc), or variable substitution.




0
 
LVL 6

Expert Comment

by:aolXFT
ID: 10968188
Oh yeah:

do a crontab -u apache -l, and a crontab -u root -l to see if there are any cron jobs making life hard for you.
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 10968635
ya no cron jobs... and I've watched the sessions appear in /tmp...

another thing i've noticed...
if I get the session problem... then I go to my IE and clear my cookies and try again It will work again.

I'm still convinced it is a PHP setting problem... it doesn't seem to be handling the cookies properly... I'll try the chmod as a quick fix for now... though
0
 
LVL 6

Expert Comment

by:aolXFT
ID: 10986735
Did you try a different session save path? It seems that your distro is periodicly setting the permissions of your temp files to 000.

That wouldn't be a PHP setting.

I recommend posting a Link to this to the Linux area of the site.
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 10991919
I've done tests with Perl, and local files and I could not get the permissions to change for me.  In addition I've tried to change the sessions path and I had the same problem.

and php builder seems to have people posting messages with similar problems.  http://www.phpbuilder.com/annotate/message.php3?id=1010459

Don't get me wrong I appreciate the suggestions but the fact that only php session files get set to 000 and they only get set when I "create new ones" (on the web page) leads me to believe strongly that it is not a problem with linux alone but is actually a php problem (possibly in combination with linux).


Any other possible suggestions?
0
 
LVL 6

Accepted Solution

by:
aolXFT earned 180 total points
ID: 11007954
Ah, that brings us into a new kittle of fish.

I didn't know that it was only new PHP Session files that were wrong. This suggests that the system is creating them with 'bad' permisisons. I'm not sure what to do about that, but is there a possibility it could be a umask problem?
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 11042891
sorry I didn't get back sooner I was away for a couple days....


I've decided to check the actual bugs in php and I found a lot... something... that was quite similar to the problem I'm having
http://bugs.php.net/bug.php?id=6641

I didn't know I had to specifically set the damn umask :)  I'm not sure if this is the problem but I'll try it tonight and see if it works.

for future reference for other people having this problem...
http://www.php.net/manual/en/function.umask.php

or do what we'll be doing in about a month is store the sessions in the database not the filesystem itself.  This will prevent this problem I'm having, and it will make it O/S independent.  
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 11109349
It's going to be about a week before I can confirm if that was the problem... but points are coming
0
 
LVL 2

Author Comment

by:DaK00L1
ID: 11272603
I'm sorry I can't confirm the umask thing... maybe someone else can...

instead I switched to database session handler.


Thanks for the help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now