I am trying to write a PHP script for a Web server (lighttpd) to read a file in another user. The Web server runs under user http:
JavaScript
x
http 1929 336 0 Nov20 /usr/bin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
The file the script is trying to read has the following permissions:
JavaScript
-rw-r--r-- 1 pi www-data 721 Oct 30 05:20 /home/pi/bmSunday
Which I thought meant that any user can read it.
The fopen in the script results in a Permission denied:
JavaScript
Warning: fopen(/home/pi/bmSunday): failed to open stream: Permission denied in /srv/http/p1/index.php
I am running Arch Linux.
JavaScript
uname -r
displays:
JavaScript
4.4.32-2-ARCH
What permissions do I need to set on the file so that user http is allowed to read it?
By the way, am I correct in assuming I can also test the permission via:
JavaScript
sudo -u http cat /home/pi/bmSunday
Using the above command, the result is:
JavaScript
cat: /home/pi/bmSunday: Permission denied
Advertisement
Answer
The permissions on the directory are probably wrong, http
probably doesn’t have execute permission. Add world execute permissions:
JavaScript
chmod o+x /home/pi