Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP can't read file on /var/tmp

Tags:

php

apache

fedora

I have a really strange error. PHP can't read a file that do exists... Some ideas? I have not SELinux installed. I'm using fedora 17 and php 5.4.

I already try everything I know, but the problem still remains.

[root@sqd var]# ls -lia 
total 92
  8194 drwxrwxrwx. 23 root   root   4096 ago 17 10:30 .
     2 dr-xr-xr-x. 19 root   root   4096 ago 13 16:00 ..
 32139 drwxr-xr-x.  2 root   root   4096 may 22 13:42 account
   288 drwxr-xr-x.  2 root   root   4096 feb  3  2012 adm
    13 drwxr-xr-x. 14 root   root   4096 ago  8 10:26 cache
796005 drwxr-xr-x   2 root   root   4096 feb  6  2012 cvs
   289 drwxr-xr-x.  3 root   root   4096 ago 21 18:07 db
   290 drwxr-xr-x.  3 root   root   4096 may 22 13:42 empty
263682 drwxr-xr-x.  3 root   root   4096 ago  7 11:15 ftp
   291 drwxr-xr-x.  2 root   root   4096 feb  3  2012 games
 35931 drwxrwx--T.  2 root   gdm    4096 jun  8 16:05 gdm
   292 drwxr-xr-x.  2 root   root   4096 feb  3  2012 gopher
    15 drwxr-xr-x. 45 root   root   4096 ago 10 10:42 lib
   296 drwxr-xr-x.  2 root   root   4096 feb  3  2012 local
   308 lrwxrwxrwx.  1 root   root     11 may 22 13:39 lock -> ../run/lock
    12 drwxr-xr-x. 14 root   root   4096 ago 26 03:17 log
   297 lrwxrwxrwx.  1 root   root     10 may 22 13:39 mail -> spool/mail
   298 drwxr-xr-x.  2 root   root   4096 feb  3  2012 nis
931987 drwxrwxrwx   3 nobody nobody 4096 ago 17 10:32 nodejs
   299 drwxr-xr-x.  2 root   root   4096 feb  3  2012 opt
   300 drwxr-xr-x.  2 root   root   4096 feb  3  2012 preserve
   307 lrwxrwxrwx.  1 root   root      6 may 22 13:39 run -> ../run
   301 drwxr-xr-x. 15 root   root   4096 may 22 13:43 spool
   305 drwxrwxrwx.  5 nobody nobody 4096 ago 30 14:13 tmp
262637 drwxr-xr-x.  7 root   root   4096 ago  7 11:20 www
   306 drwxr-xr-x.  2 root   root   4096 feb  3  2012 yp


[root@sqd var]# ls -lia tmp/
total 216
    305 drwxrwxrwx.  5 nobody nobody   4096 ago 30 14:13 .
   8194 drwxrwxrwx. 23 root   root     4096 ago 17 10:30 ..
   3030 -rwxrwxrwx   1 nobody nobody 199397 ago 30 14:13 file_thumb_5363_1_0.jpg

But

<?php
highlight_file(__FILE__);

var_dump(file_exists('/var/tmp/file_thumb_5363_1_0.jpg')); 

print out:

bool(false) 
like image 927
Cito Avatar asked Feb 19 '23 08:02

Cito


1 Answers

Fedora 16 introduced the concept of a "private tmp" /tmp and /var/tmp I would throw my 2 cents on that direction.

From the manual:

2.3.3. Services Private /tmp
A number of services managed by systemd have been modified to make use of its ability to provide them with a private /tmp directory. Privileged services using /tmp and /var/tmp have previously been found to be open to being interfered with by unprivileged users, potentially leading to privilege escalation. Using private /tmp directories for services prevents this style of exploit.

The directive added to the systemd unit files for the modified services is:

[Service]
PrivateTmp=true

like image 108
Frankie Avatar answered Mar 03 '23 09:03

Frankie