Can not access a files that belong to other users
I have a plugin that must read some files every X minutes (this plugin is running under user1), those files belong to user2 (from another application), the structure is something like this:
drwxr-xr-x. 2 user2 5536 4096 sep 2 11:09 directory1
#Inside this directory, it contains some files:
-rw-r--r--. 1 user2 5536 0 mar 10 2020 file1
-rw-r--r--. 1 user2 5536 0 mar 8 2018 file2
When I run the plugin, it does not let me access these files, it is returning this error:
check your filesystem (permissions/usage/integrity) and disk devices
Changing the owner of the directory and the files is not an option (because those files are used by another application).
I also tried to change the permissions to 777 but it returns the same error.
ACLs are not an option...
Solution 1:
Users can access files owned by other users. What you should do is make the users that will "share" files/directories belong to the same group, and assign the same group to files/directories, with suitable permissions (read/write) for the group.
Detailed instructions are shown here and here.
There is no point in copy-pasting them, as they belong to SO.
Note that in the example the group is admin
, but it could be anything.
Please follow it, and if you find any difficulty post exactly what you did, and exactly what problem you found.
Make sure all directories above directory1
allow for reading from a different user.
You could also check this, a 10-minute read.
Solution 2:
I think this: "Make sure all directories above directory1 allow for reading from a different user." is a clue to the solution (in the answer by sancho.s ReinstateMonicaCellio).
You should ask the owner of the files to make the whole path readable for you, either set it for 'others' or create a group with read permissions all the way and enter the relevant user IDs into that group.
An alternative is to ask the owner of the files to move the files somewhere else, where it is easier or safer to give you read access.