Tuesday 28 November 2017

linux - how to grant execute permission without read permission?


I want to grant execute permission for a script, but not read permission since I do not want user to read the content for the script. But it seems not working, I post what I am doing and seeking for advice,


sub-directory demo is owned by root user and root group,


Case 1, make execute+read permission, works


chmod 775 /home/yhd/demo/text


Then user yhd can execute text command without any issues


Case 2, make execute permission only, not working


chmod 771 /home/yhd/demo/text


Then user yhn cannot execute text command, and error message is permission denied



Answer



The problem with scripts is that the script is not what is running, but the interpreter (bash in this case).


The interpreter needs to read the script.


Since reading the file is forbidden then it can't be executed inside the interpreter.


This is different from a program, because programs are loaded directly into the kernel.


One solution is to use a compiler that will generate a C program equivalent to the script, like SHC, that you can download from here or from this guide.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...