What if we try to access a file without read permission through a program

Consider that ‘dq’ and ‘learn’ are two users and there is one file say ‘x’ and a executable program say ‘p’ in ‘learn’s’ home directory. ‘dq’ has r-x access to files in ‘learns’ home directory. If the program ‘p’ can modify the content in file ‘x’ and dq can execute this program, will ‘dq’ indirectly get the access to the file ‘x’ ? or the program execution will pop an error: file permission denied ?

Hi @dvbagul:

Please provide a question link and a screenshot of your code and expected output as per these guidelines.

Edit: yes as @otavios.s has said, please share your code formatted in markdown so we can use it to easily troubleshoot your issue.

1 Like

Thank you for referring to the guidelines, but it is important that @dvbagul do not share a screenshot, but the code formatted using markdown as per the guidelines.

1 Like

Actually my question is bit conceptual and hence I have not shared any code with it. It is out of curiosity, that I asked. :slightly_smiling_face:

Hi @dvbagul:

Your question is quite vague and unclear to me. Do you mind elaborating further?

So from what I understand from your scenario, this is what happens when I enter the following commands at the command line:

$ls -l
-rwxr-xr-x  p.exe
-rwxr-xr--  x.txt

You need to bear in mind that the permissions is linux are as follows

 -                  rwx        rwx          rwx 
[directory]        [owner]    [group]  [other user]

The first character is a hyphen - if the object is a file (and not a folder) otherwise its a d which stands for directory (or a folder).

And I am assuming learn is the owner and dq is a user in the group which is specified to have access to /home/learn.

If this is the case it depends. Say x was a assembly or C file instead of a .txt then dq would need to recompile x.exe, which he does not have permission to do since he cannot write to the file (only read and execute).

Thank you for your response : I am sorry that my initial question seems bit unclear. I will try my best to elaborate. You interpreted most of the part correctly but I guess you are having a bit of trouble understanding about files I stated. Consider that there is a program p which reads the file x.txt and makes changes in it. Owner of this files is learn. Now dq is another user which has permission r-- for file x.txt and rwx for program p. If dq can access and execute the program p will that give dq a chance to access x.txt through p even though he does not have access to x.txt or will the execution of program p result in error.

(Note- This is just out of my curiosity resulted from learning something new :smile:and is not about anything in instruction section that we need to implement on screens.)

Hi @dvbagul: I have not come across such a situation in the command line but logically, it is possible since it is possible for p to indirectly modify x.txt without having any error and I guess this is true in the case of log files (i.e. the system administrator does not want the user to tamper with the log files generated by the application p.exe)

Hope this clarifies!

Oh okay got it, Thank you again for clarifying. Now I am all clear! :slightly_smiling_face: :+1:

No worries @dvbagul anytime!

1 Like