Executing Commands From Non-Standard Path (Changing user's PATH secretely???)

Hi:

I have a requirement as below:

I have some standard Unix commands modified and kept them in a directory say /usr/clsh/bin. For example I have a script named "ls" kept here which is modified version of "ls" (say it always gives long listing i.e. ls -l).

When any user logs on and types commands, I want this dir (/usr/clsh/bin) to be looked upon first to check if modified version of the command is available. If yes execute that else execute normal command.

I have implemented it by writing a script say "clsh.bash" which changes PATH to PATH=/usr/clsh/bin:${PATH}. This script I am executing from /etc/profile so that it applies to all the users. So when user logs on his PATH will be changed. And in this case if he issues "ls" it will execute my modified version of "ls" that I kept in /usr/clsh/bin. If user issues any other command then it will normally be executed as there is no equivalent script available in /usr/clsh/bin.

This works fine.

But user can always revert back to original PATH by changing PATH variable. I don't want to happen this and also when user types in "echo $PATH" he will know that the PATH is been modified, I don't want to happen that either.

So basically I would like to know if there is any workaround for this or there is any alternate method to achieve this.

Your help is most appreciated so please guide me with your expert comments.

Thanks is advance and hope to get your answers quickly.

Regards,
Ramesh

---------- Post updated at 01:41 AM ---------- Previous update was at 12:25 AM ----------

39 views and no replies yet :frowning:

Please let me know if more information is needed or I am not making myself clear. Thanks.

Use a restricted shell such as rbash or rksh and set the path and don't allow users to execute commands not in their PATH

OK makes sense. This is for BASH shell so will check how I can set rbash. So is it possible that to do from /etc/profile? I need all the normal users except administrators to get rbash when they log in.

Also can I configure the rbash such that it will allow user to execute only commands in their path. And if I force users to rbash will they be able to execute commands like 'cd' etc. Will they be able to change their path?

Basically would like to know if it is possible to custom configure rbash or we have to accept it's default behavior.

Many thanks for the reply and I hope I will be able to solve this issue today by getting help from this thread.

Regards,
Ramesh

---------- Post updated at 04:14 AM ---------- Previous update was at 03:28 AM ----------

rbash will totally restrict the users. Like their ability to "cd" etc among other things. I was wondering if I can set default shell of users as rbash and then customize it further, for example allow them to use commands like "cd" etc.

Just checking that possibility. Any comments from your side "reborg"?

Thanks...