Reputation: 4226
I'm working on a very expanded source code. I added a number of new source files to different paths, and wrote a shell script to open all of my files in a text editor.
I get an input from user to open files in his favourite code editor (gedit, geany, sublime, ...). For the sake of defensive programming, I would like to filter some commands like rm
which can delete all my files instead of opening them!
My question is what is the best way to achieve this? If I want to blacklist or whitelist a set of commands, do I need to compare the input command against all of the commands in the blacklist/whitelist? Is there any shorter way?
Upvotes: 1
Views: 804
Reputation: 295308
If you want a user to be able to edit files but not run other, arbitrary commands on them, do all of the following:
/etc/sudoers
to allow that user to run only specifically whitelisted commands as an account able to read the file.vim
can be used to run arbitrary commands, but it has a (restricted) rvim
alternative which doesn't allow privilege escalation.Or do the sane thing, and use version control. :)
Upvotes: 2