Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fileperms(): stat failed, but the file exists

I'm using the OpenVPN Web GUI and I'm having some problems because the program doesn't see one of the necessary files. The ls -l for the file is as follows:

-rw-r--r-- 1 root www 4153 Dec 20 10:12 /etc/openvpn/inn.crt

But when I run the program, it claims that the file doesn't exist. I tried this sprintf('%d', fileperms($sLongFileName));, which raises the "can't stat" warning. file_exists() also returns false. There exists another file that's visible to PHP:

-rw-r--r-- 1 root www 581 Dec 21 12:52 /etc/openvpn/crl.pem

What's the cause of this?

EDIT: I had the program do this for both files:

file_put_contents("_dumpfile", "\n<<".$sLongFileName.">>\n", FILE_APPEND);

And the result is this:

>>/etc/openvpn/inn.crt

<</etc/openvpn/crl.pem>>

Is there some problem with the file path?

like image 438
Mg D Avatar asked Nov 15 '25 11:11

Mg D


1 Answers

Next to the physical existance of a file, there can be different other things that can prevent you from accessing the file under a specific user.

You need to verify if you can access the file and the directory the file is located with the user that is used by your PHP script to perform these calls (that depends on your server and PHP configuration). So first find out which is the username.

Then check your system configuration if utilities like SELinux are preventing access on files for a reason, e.g. webrequest results in file access on files it's not allowed to.

like image 152
hakre Avatar answered Nov 17 '25 10:11

hakre