Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-21-2004, 06:13 PM   #1
LQ Newbie
Registered: Jun 2004
Distribution: Redhat 9
Posts: 11

Rep: Reputation: 0
Disable ctrl - c for users

I need the logged on users to only have access to my shell script in /scriptt/script . I had linux to start that shell script when the user logs in but I have found that the user can still crtl - c to the bash prompt.
is thier some way to prevent this?
Old 08-21-2004, 06:22 PM   #2
Senior Member
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Set that as their shell in /etc/passwd? Any change permissions of bash and other shells?
Old 08-21-2004, 06:42 PM   #3
LQ Newbie
Registered: Jun 2004
Distribution: Redhat 9
Posts: 11

Original Poster
Rep: Reputation: 0

Ive tried that and it works at the terminal But when i try to login through an ssh client it says Exec format error. So i put the script in etc/skel which would put it in every users .bash_profile and it worked. but they can still ctrl - c .

Last edited by quack322; 08-21-2004 at 10:36 PM.
Old 08-22-2004, 12:38 AM   #4
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
You need to catch the interrupt signal in your scripts.

Search LQ for keyword: SigInt and user crabboy. You'll see a couple of examples.
Old 08-22-2004, 03:17 AM   #5
Registered: Sep 2003
Distribution: *bsd, solaris, gentoo
Posts: 86

Rep: Reputation: 15
Hello quack322,

Add the following code toward the top of your script
function nobreak()
#change this to what ever you want it to say when a user presses ctrl-c 
echo "You cannot use that command"
This defines a function that you will need to prevent users from pressing ctrl-c

I'm assuming that your script contains some type of loop, to allow users to execute commands or something of that nature probably an until statement
Right under where this loop starts (whatever it may be) add the following
trap nobreak  INT
What this does is call the function named 'nobreak' every time the user presses ctrl-c

btw: Could you post the code so i can be more specific on where these entrys should go.

Good luck
Old 08-22-2004, 11:14 AM   #6
Registered: Jul 2004
Location: Boston, MA, USA
Distribution: FreeBSD, Debian/AMD64, Ubuntu/i386
Posts: 59

Rep: Reputation: 15
Don't fiddle with this stuff if it is really security-releated. Anybody with more knowledge than you will break out.

E.g, ask the above posters about Control-\


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable password changing permissions to normal users ? toraghun Linux - Newbie 14 11-17-2005 11:17 AM
Disable Viewing Users in /home gsoft Linux - Security 2 09-09-2005 02:32 AM
How To Disable CTRL-ALT-F1 beajedi Linux - Security 6 12-24-2004 12:07 AM
How to disable Ctrl and Alt keys? (and maybe sysrq) bigperk420 Slackware 13 12-07-2004 06:53 PM
Disable CTRL-ALT-DEL dog606 Red Hat 2 04-19-2004 02:25 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration