[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Control-C kills interactive bash



Kevin Mark wrote:
On Thu, Mar 06, 2008 at 04:58:21PM +1300, Lesley Walker wrote:
Never mind... I think I found it. We have this line in /etc/profile:
trap "exit" 2 3 23
If I comment it out the problem goes away. Time for me go and RTFM on traps.
That is odd. IIRC control-d was set to 'exit'. so in this case various
signals are set to do the same thing. Why is beyond me.

Most likely it's a security measure to prevent an attacker from taking control by interrupting the execution of the script - if they are quick enough to press Ctl-C while /etc/profile is still running, they might be able to drop into a shell when they're not supposed to have access to one, that sort of thing.

This sort of security measure used to be common practice, back in the days when people used actual terminals to run character-based menu-driven business software (and profile scripts took longer to run!). I don't know if it's still considered good practice.

It seems that in the older system, the trap statement ceased to apply after /etc/profile finished, but now it's necessary to explicitly "un-trap" the signals at the end of the script.

Whether I'll do that, or just remove the trap statement, I haven't quite decided yet.

LesleyW


Reply to: