require_once: Failed to open stream even with 777 permissions

37 Views Asked by At

I have a fairly simple PHP backend where every file is in the same folder.

One of those files is a simple script to login a user

<?php
ini_set("display_errors", "On");
error_reporting(E_ALL);

require_once "helper.php";

if(!isset($_POST['login']) || !isset($_POST['pwd'])) sendError("No login or pwd");

authenticate() ? sendMessage("") : sendError("Login or pwd invalid");

?>

However testing is using postman I get the following error

<br />
<b>Warning</b>: require_once(/home/johan/public_html/backend/helper.php): Failed to open stream: Permission denied in
<b>/home/johan/public_html/backend/checkLogin.php</b> on line <b>5</b><br />
<br />
<b>Fatal error</b>: Uncaught Error: Failed opening required 'helper.php'
(include_path='.:/usr/share/pear:/usr/share/php') in /home/johan/public_html/backend/checkLogin.php:5
Stack trace:
#0 {main}
thrown in <b>/home/johan/public_html/backend/checkLogin.php</b> on line <b>5</b><br />

Reading the error I assume it's a permissions problem, so I run chmod 777 helper.php to brute force it but it didn't change anything.

I admit I'm out of ideas.

1

There are 1 best solutions below

0
Johan Daniel On

Found the answer;

Since I'm running Fedora, which is using SELinux, I had to authorize Apache to read the content of /home with

sudo setsebool httpd_read_user_content=1

Apologies for the lack of details in the original post