Don’t run some commands!

Let’s say you are working on a project with multiple computers and users. You may want that some commands work only on a restricted set of user accounts.

You may want to restrict a newbie from using dangerous commands that could harm the project files. A solution to implement this feature is as follows:

1. Make a directory for every user (do_not_run.$HOSTNAME)

2. Put shell scripts with the same name as the command to be blocked/restricted in the folder. Make these scripts print an error to the stderr that this operation is not permitted for the user.

echo -e “\aYou are not allowed to perform this action.” 1>&2

\a or 07 provide an audible ring to notify users of error

3. Update the PATH environment variable to include your directory BEFORE the directory in which the restricted commands are placed.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: