LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-22-2005, 02:06 AM   #1
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Rep: Reputation: 15
Controlling bash


i have a perl script. which does some task. u shouldnt be worried about what it does.

what i want is that the moment the user is authenticated, the login program should start the PERL script instead of launching the bash shell.

at the same time i want to disable the escape sequences. like CNTRL+Z and CNTRL+C

so that the user remains with in the PERL script.

the objective of this futile exercise is that i dont wan the user to know that i am actually running a bash shell underneath. i wan him to have a feeling that this is my own OS.

thats why he should never be able to come out of that script and have a look at other things in his home directory.
 
Old 05-22-2005, 02:38 AM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
$ sed -i -e 's,/bin/bash,/bin/myscript.pl' /etc/passwd
(but read the man pages first )
 
Old 05-22-2005, 02:39 AM   #3
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
sure i ll love to read the man pages.

can u name the command for which i read the man pages?

or just the topic which i can search on the internet to have a know how of this problem?
 
Old 05-22-2005, 02:45 AM   #4
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
$ man /etc/passwd
$ man sed # if you don't know what it does--it's a wondertool
google('/etc/passwd')
 
Old 05-22-2005, 02:47 AM   #5
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
/etc/passwd contains the usernames and encrypted passwords.

sed is stream line editor.

this still doesnt answer my question as to how can i redirect the login program to launch my perl script instead of launching the bash shell.
 
Old 05-22-2005, 02:56 AM   #6
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
oh. Actually I directed you to the wrong manpage:
$ man 5 passwd
look at the file. Understand what sed does. make a copy and do the sed on the copy.

hth --Jonas
 
Old 05-22-2005, 02:59 AM   #7
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
thanks i got it now.

just wanted to know how sed would help in this situation?

like i just have to replace the shell field with my perl script.

what has sed go to do with this?
 
Old 05-22-2005, 03:04 AM   #8
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
doing it programatically instead of by hand.
 
Old 05-22-2005, 03:12 AM   #9
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
ok here is the passwd file in /etc

Code:
noor:x:502:502::/home/noor:/home/noor/bash.pl
so as u can see i have directed the shell to bash.pl.

now all this bash.pl does is to print a hello world message.


so when i try to logon the putty program just exits .

what should i do so that the program shouldnt exit.
 
Old 05-22-2005, 03:16 AM   #10
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
print $_ while (<STDIN>);
 
Old 05-22-2005, 03:20 AM   #11
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
thanks a lot.

now one more thing.

how to disable CNTRL+C nd all the SIGS which cause the program to terminate.

i dont wan the user to come out of this script and roam around the file system.

i know this can be done through other ways but i wan it this way.
 
Old 05-22-2005, 03:22 AM   #12
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
by the way when i pressed CNTRL+C putty just exited all on its own.

it seems that i dont have to worry about this. right?
 
Old 05-22-2005, 03:27 AM   #13
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
$ man login # and others, but I can't remember which offhand
basically, when your script exits, the user will be logged out (just like when bash terminates).

so you (probably) don't have to worry about ^C and ^Z -- though I'd find it inconvenient to get logged out by a random keypress.

if you want to catch the signals (SIGINT and SIG???), look at perls signal handling.
 
Old 05-22-2005, 03:29 AM   #14
bahadur
Member
 
Registered: Apr 2004
Distribution: Linux Red Hat
Posts: 141

Original Poster
Rep: Reputation: 15
yeah u are right.

the script should just do nothing if a user wrongly types in CNTRL+C.

this script should handle all kill SIGS.

thanks
 
  


Reply



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
controlling a touchpad justagirl Linux - Laptop and Netbook 4 12-15-2004 10:42 AM
Bandwidth controlling acdc Linux - Networking 1 09-20-2003 03:01 PM
Bandwidth controlling acdc Linux - Networking 1 09-19-2003 07:58 AM
Controlling Modem yrraja Programming 1 12-23-2002 08:05 AM
Controlling from another world. DenShinobi Linux - Newbie 2 04-11-2002 07:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:43 PM.

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