I need a bash (or python) script which will edit and execute files only in a certain directory and its subdirectories but has no permissions to do so in other directories. Any ideas how to set such permissions for a script?
Asked
Active
Viewed 69 times
3
-
4i guess all you need is to learn user and file permission basics. – georgexsh Oct 09 '17 at 14:59
-
I have found [proot](https://wiki.archlinux.org/index.php/PRoot) tool that acts like chroot but it does not need root privileges. Probably, this is not secure way but it can be handled enough. I have set up proot and ubuntu 10.04 (the server has 2.6 kernel) on server where I do not have root access. It seems to work for me. – loven-doo Aug 24 '18 at 15:37
1 Answers
3
the Apache webserver does a similar thing by creating its own user on linux, i.e. the user apache can access /var/www
without being root :
https://support.rackspace.com/how-to/how-to-add-linux-user-with-document-root-permissions/
so you can create a new user and give this user only permissions for the particular directory
then any other user who needs to use the script can run it as the user you created :
https://www.cyberciti.biz/open-source/command-line-hacks/linux-run-command-as-different-user/

ralf htp
- 9,149
- 4
- 22
- 34
-
Thank you for a good idea but I need to run such script on a server where I don't have root access so I can't create a user. Thus, solutions that are based on user access seem to be not proper. – loven-doo Oct 10 '17 at 08:02
-
beside using `owner` in the linux permissions is only possible `group` https://www.linux.com/learn/understanding-linux-file-permissions however in this case ( create a group,... ) you also need root access on the server. it is not possible to allow a script to be executed only in a specific directory because there is simply no programmatical mechanism, i.e. flags that are attached to the file that contains the script , in linux any access security is regulated by the permissions – ralf htp Oct 10 '17 at 13:26