2

I have a php script that runs from apache2 call that needs to read files in a SD card. The SD card appears mounted in /media/user/name of SD card partition. I tried to read this answer Default file permissions for php user www-data but it did not help in my case. Can anyone help me? Thank you.

kaf
  • 123
  • What are the current permissions and ownership of /media/user/name? – Arronical Jun 23 '16 at 08:29
  • No ideia. How to check that in details? If i right click on the media that appears in the Nautilus, it says: others: files-only readling, folders-acess to files. – kaf Jun 23 '16 at 08:31
  • Open a terminal and type ls -lh /media/user/name. – Arronical Jun 23 '16 at 08:32
  • total 36K drwxr-xr-x 7 user1 user1 4,0K Abr 2 07:50 folder1 drwxr-xr-x 2 root root 16K Jun 22 04:12 lost+found drwxr-xr-x 135 user1 user1 12K Mar 29 17:23 folder2 drwxr-xr-x 3 user1 user1 4,0K Jun 22 14:07 folder3 – kaf Jun 23 '16 at 08:34
  • the actual name is /media/user1/Núbia (with an accent) – kaf Jun 23 '16 at 08:37

1 Answers1

0

Giving the mount point of your SD card partition the correct ownership should do the trick. If you want the user who mounted the SD card to still have ownership permissions, you could change the group of /media/user/name/ and all of the files and folders it contains to www-data with:

chgrp -R www-data /media/user1/Núbia

Ensure that all of those files and folders have read and write permissions with:

chmod -R g+rw /media/user1/Núbia

It's worth getting to grips with permissions, to know whether you're introducing security vulnerabilities, but this should allow you to do what you need for now.

Arronical
  • 19,893
  • It did not work. Doing the ls -lh appears the www-data user which is the one in use by apache+php but the php still cannot access the files (although i included the path in the include_path of php). The access remains denied. – kaf Jun 29 '16 at 08:04
  • I change in the apache the user www-data to myuser (not root) and then the php can acces the files. So it is really a problem of www-data permissions. – kaf Jun 29 '16 at 08:12