Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to stop user getting to the command line 3

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
Hello

I've inherited some code which allows me to give users a menu to run certain Unix commands but which should stop them getting to the command line. My problem is this doesn't now work properly (probably never did).

As an example this is the end of a user's .profile:

# other stuff here for setting up things #
# ... #
usermenu.cexe menufile.mnu
exit

usermenu.cexe is the program (written in C) which displays the menu;
menufile.mnu is a text file which lists the menu items & the commands they invoke.

This bit works but when I do a ^C I crash out of the program to the command line. My documentation tells me that the exit at the end of the .profile will log me out if this happens but it doesn't.

(My documentation also says that the C code uses a trap command to force ^C to be ignored - but that doesn't work either.)

So my question is - is there a solution to this in the shell script? I'd rather not go back to the C code as I'm no C expert (& the person who wrote this was our last one ...). I guess I'm hoping there's some way to get the running process to run the exit before the command line is shown to the user.

Thanks, Chris
 
Hi

A brutal solution : specify that usermenu.cexe program as that user's shell in the /etc/passwd file :
Code:
guest:guest:501:501::/home/guest:/opt/usermenu.cexe
For this to work, you must enumerate the usermenu.cexe in the /etc/shells file.

Feherke.
 
At the end of the user's profile:
exec usermenu.cexe menufile.mnu

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
exec - I knew that - but had forgotten ...

Feherke - I like the look of your suggestion but PHV's suggestion works fine so have gone for that.

Thanks as usual
 
I know you have a solution, but another idea would be to add the following at the beginning of the .profile:

[tt]trap exit 1 2 15[/tt]

That would force it to exit the shell when Ctrl-C was hit.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top