Shell script as login shell

Shell script as login shell

Post by Barry Margoli » Sun, 05 Apr 1998 04:00:00





Quote:>I've heard that putting a shell script in the /etc/passwd entry of an
>user as the login shell is dangerous. Could somebody demonstrate
>how dangerous it is ? What about a compilered C program calling
>a shell function ?

You've heard wrong.  There are lots of people who don't understand how
things work, and think that there's some way to "break out" of a shell
script to switch into an interactive shell, perhaps by hitting Ctl-C really
quickly when it starts up.  But this is not true.

--

GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.

 
 
 

Shell script as login shell

Post by David Richar » Sun, 05 Apr 1998 04:00:00






>>I've heard that putting a shell script in the /etc/passwd entry of an
>>user as the login shell is dangerous. Could somebody demonstrate
>>how dangerous it is ? What about a compilered C program calling
>>a shell function ?

The "safe" way to run have a script run when a user logs in is to set
their login shell to be a compiled 'C' program which throws away the
environment variables it's started with, creates a new environment with
safe values, then executes the script.

Quote:>You've heard wrong.  There are lots of people who don't understand how
>things work, and think that there's some way to "break out" of a shell
>script to switch into an interactive shell, perhaps by hitting Ctl-C really
>quickly when it starts up.  But this is not true.

What _is_ dangerous is giving the user a normal login shell (say /bin/ksh)
and then making their $HOME/.profile a script that you expect them not to
be able to break out of. Very bad idea.

Making their /etc/passwd entry a shell script _is_potentially_dangerous_,
assuming that your system has the old bug where the IFS variable can be
changed by the remote telnet or extra information at the login prompt.

 
 
 

Shell script as login shell

Post by Marc Slemk » Sun, 05 Apr 1998 04:00:00





>>I've heard that putting a shell script in the /etc/passwd entry of an
>>user as the login shell is dangerous. Could somebody demonstrate
>>how dangerous it is ? What about a compilered C program calling
>>a shell function ?
>You've heard wrong.  There are lots of people who don't understand how
>things work, and think that there's some way to "break out" of a shell
>script to switch into an interactive shell, perhaps by hitting Ctl-C really
>quickly when it starts up.  But this is not true.

He has heard right.

It is not always possible on all systems to always be able to bypass
shell scripts used as login shells, however in many cases it is very
possible.

Example?


telnet> env define ENV /etc/shells
telnet> env export ENV
telnet> open localhost
Trying 127.0.0.1...
(...then login...)

Warning: this could bring your system to a crawl by forking infinite
processes unless you have ulimits to avoid it.  /etc/shells is just
the easy one, you can make another file with a shell listed in it
and just use it.

This is not the only way, just one example that works on many
systems.  In general, it is a poor idea to use shell scripts as
login shells.

 
 
 

Shell script as login shell

Post by Who am I » Mon, 06 Apr 1998 05:00:00


Hello all,

I've heard that putting a shell script in the /etc/passwd entry of an
user as the login shell is dangerous. Could somebody demonstrate
how dangerous it is ? What about a compilered C program calling
a shell function ?

S

Please remove .NOSPAM. in my email address when reply by mail.

 
 
 

Shell script as login shell

Post by Tomas Beinaraviciu » Wed, 08 Apr 1998 04:00:00



> >I've heard that putting a shell script in the /etc/passwd entry of an
> >user as the login shell is dangerous. Could somebody demonstrate
> >how dangerous it is ? What about a compilered C program calling
> >a shell function ?

> You've heard wrong.  There are lots of people who don't understand how
> things work, and think that there's some way to "break out" of a shell
> script to switch into an interactive shell, perhaps by hitting Ctl-C really
> quickly when it starts up.  But this is not true.

Avoid following situations: do not make home of user with shell script
as shell. If somebody will put .rhosts with '+ +' and  .profile with
"exec tcsh", you might have a trouble.

--
Tomas Beinaravicius
No Magic, Inc.