This discussion is archived
4 Replies Latest reply: Sep 6, 2010 1:58 AM by 807578 RSS

Bash shell breaking JDS/CDE login operation?

807578 Newbie
Currently Being Moderated
Hello all,

I am very new to the Solaris OS, Sun machines and JDS. I recently installed Solaris 10 on a Sun v240 that I got off of ebay and was also able to install an XVR-100 graphics card. Took me quite a while to figure out but I now seem to have it working perfectly...that is until...

Just tonight I added the following to my .profile because I prefer the bash shell to the default shell:
# Switch to dynamically linked bash shell if it exists, otherwise
# stay in statically linked '/sbin/sh'.
if [ -x /usr/bin/bash ]; then
  SHELL=/usr/bin/bash
  export SHELL
  exec /usr/bin/bash
else
  echo /usr/bin/bash not found using default shell of $SHELL
fi
The above is the only thing in my .profile file. However, after adding this I was no longer able to login to JDS or CDE at all. I would get the login screen no problem but when I actually attempted to login the login screen would go away, the screen would flash a couple of time, then the login screen would reappear like nothing ever happened.

Fortunately I remembered that I had modified the .profile file and I moved it to .profile.bak. I then tried to login again and it worked fine - no problems whatsoever.

I checked the ~/.dt/startlog file for a login attempt both with and without the .profile file existing. When the .profile did exist with contents shown above I get the following:
(snip)
--- starting desktop on /dev/pts/2
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
/usr/dt/bin/Xsession[788]: 1135 Hangup
X connection to :0.0 broken (explicit kill or server shutdown).
X connection to :0.0 broken (explicit kill or server shutdown).
X connection to :0.0 broken (explicit kill or server shutdown).
When I moved the .profile to .profile.bak I get the following:
(snip)
--- starting desktop on /dev/pts/2
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
Java Accessibility Bridge for GNOME loaded.
The log is not really informative as to the problem. And the parts that I snipped out were identical for both runs.

So the question is...what's the deal with JDS/CDE not liking the bash shell? And how can I still automatically switch to the bash shell at console login but still have the desktop login work? Or is it just not possible? I'm really mostly interested in why something so simple would break the JDS/CDE login process.

Thanks in advance!

Jonathon
  • 1. Re: Bash shell breaking JDS/CDE login operation?
    807578 Newbie
    Currently Being Moderated
    Johnathon


    Is is perhaps that you are executing a Bash shell which is jumping out of the login process and never returning?
    exec /usr/bin/bash
    I suspect that by calling the bash shell from within the profile you are initiating a jump to the bash interpreter which never returns and as a consequence the Xsession never finishes processing the .profile.

    All you need to do is set the preferred shell using the environment variable and then when you request a new shell, e.g. selecting new terminal from a menu, Solaris will start the appropriate one for you.

    Try removing the exec line.

    Regards,

    Paul
  • 2. Re: Bash shell breaking JDS/CDE login operation?
    807578 Newbie
    Currently Being Moderated
    I suspect that by calling the bash shell from within the profile you are initiating a jump to the bash interpreter which never returns and as a consequence the Xsession never finishes processing the .profile.
    Wow, dang dude, I bet you're absolutely right. Nice catch. I commented out the exec line and I was able to login to JDS and CDE no problem. And now whenever I open a new terminal window from the GUI it opens to bash as appropriate! Nice!!!

    However, can you help me with one minor related annoyance? Since I have taken out the exec line now whenever I login to the system over SSH it always brings me to the default shell instead of bash. Is there a way to get this to work over SSH as well or am I stuck with picking one or the other?

    Thanks a lot Paul! :)
  • 3. Re: Bash shell breaking JDS/CDE login operation?
    807578 Newbie
    Currently Being Moderated
    Ahh, if you're connecting via ssh then you're invoking the sshd server on the Solaris machine. For full details try
    # man sshd
    The ssh server makes use of the environment variables in your .login rather than .profile. If you don't have a .login in your user home dir then the values are taken from:

    /etc/defult/login

    The simplest way to overwrite the default is to add a {HOMEDIR}/.login file containing

    SHELL=/usr/bin/bash

    Or if the alternative shell is required for all users then change the defaults in /etc/default/login.

    The variables you need to check in /etc/default/login are:

    ALTSHELL=YES
    SHELL=<your_choice>

    Regards,

    Paul.
  • 4. Re: Bash shell breaking JDS/CDE login operation?
    807578 Newbie
    Currently Being Moderated
    UPDATE: I figured it out!! It turns out that the JDS/CDE startup process conveniently defines a shell variable named DT. And if you simply check to see if it exists you can use it for conditional operations in your .profile/.login scripts! Here is my updated .profile which now works for either SSH console or GUI JDS/CDE logins:
    # Switch to dynamically linked bash shell if it exists,
    # otherwise stay in statically linked '/sbin/sh'.
    if [ -x /usr/bin/bash ]; then
      SHELL=/usr/bin/bash
      export SHELL
    
      # Only start bash if we are not being sourced by the JDS/CDE startup process!
      # See http://forums.sun.com/post!reply.jspa?messageID=11044792 for more info.
      if [ ! "$DT" ]; then
        exec /usr/bin/bash
      fi
    else
      echo /usr/bin/bash not found using default shell of $SHELL
    fi
    Sweet!

    Jonathon =D