I've just installed Ubuntu Server 16.04.3 and ISPConfig 3.1 following this official guide here: https://www.howtoforge.com/tutorial/perfect-server-ubuntu-16.04-with-apache-php-myqsl-pureftpd-bind-postfix-doveot-and-ispconfig/

Everything is working as expected, but I'm running into a file / directory ownership issue. To explain the issue, I need to write an example:

  • User uploads a PHP script that allows website visitors to upload images to /images/.
  • User must chmod /images/ 0777 or the PHP script will return a permission denied error when some visitor tries to upload an image.

When inspecting the contents of the /images/directory with ls -l images, it returns:

-rw-r--r-- 1 www-data www-data 69455 Dec 12 13:03 755675678.tmp

The .tmp file in this case is a file uploaded with chmod 0777. It suggests that the script is executed by www-data.

However, when inspecting the directory itself with ls -l, it returns:

drwxr-xr-x 2 web1 client1  4096 Dec 12 13:03 images

So that explains why the directory would need to be 0777 for www-data to be able to write to it. Doing some further investigation though, I've checked the client1 group with:

getent group client1 | awk -F: '{print $4}' and it returns: www-data

At this point I'm lost. I'm still very new to Linux and Ubuntu. I don't understand how groups and members of those groups work. But it would seem logical to me that www-data would have all the permissions required because it's a member of client1. I could be completely wrong about this though, so if anyone could explain me why I'm running into this problem and how to fix it, I'd be very gratefull :)

  • the group permissions are -xr, that means read and execute only. the folder permissions need to be 0772 to give group write permission. – ravery Dec 12 '17 at 14:33
  • @ravery Yes, terdon was actually just explaining me that. I assumed the group was automaticly owner of the folder as well. But that was wrong as I now understand :) – icecub Dec 12 '17 at 14:37
  • folder permissions 0777 are hardcoded in PHP script? Allowing nobody to write to the folder is very unsecure. – M. Dm. Dec 12 '17 at 14:40
  • @M.Dm. No they are not. Please read the question again. I think you misunderstood it – icecub Dec 12 '17 at 14:41
  • So if anyone would like to provide a meaningfull answer to this question, please explain that groups aren't the owner of a folder. That's why chmod 0755 wouldn't work. To solve the issue, I have to provide permissions to the group instead (0775). – icecub Dec 12 '17 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.