[MacPorts] #40603: MacPorts bash doesn't work properly as a default shell (should define SH_SOURCE_BASHRC)

MacPorts noreply at macports.org
Fri Sep 27 15:34:25 PDT 2013


#40603: MacPorts bash doesn't work properly as a default shell (should define
SH_SOURCE_BASHRC)
---------------------+--------------------------------
 Reporter:  dlitz@…  |      Owner:  macports-tickets@…
     Type:  defect   |     Status:  new
 Priority:  Normal   |  Milestone:
Component:  ports    |    Version:  2.2.0
 Keywords:           |       Port:  bash
---------------------+--------------------------------
 The bash port shipped with MacPorts doesn't work properly when a user sets
 it up as their default shell.

 == Steps to reproduce ==

 1. port install bash
 2. Add /opt/local/bin/bash to /etc/shells
 3. Make sure OSX's bash is your default shell:
    {{{
    chsh -s/bin/bash
    }}}
 4. Put something like this at the top of your ~/.bashrc:
    {{{
    echo "Hello from $BASH"
    }}}
 5. Run "ssh localhost true".  You should see "Hello from /bin/bash".
 6. As a user, change your shell to MacPorts bash:
    {{{
    chsh -s/opt/local/bin/bash
    }}}
 7. Run "ssh localhost true" again.

 === What you should see ===

     {{{
     $ chsh -s/bin/bash
     Changing shell for dlitz.
     Password for dlitz:
     $ ssh localhost true
     Hello from /bin/bash
     $ chsh -s/opt/local/bin/bash
     Changing shell for dlitz.
     Password for dlitz:
     $ ssh localhost true
     Hello from /opt/local/bin/bash
     $
     }}}

 === What you actually see ===

     {{{
     $ chsh -s/bin/bash
     Changing shell for dlitz.
     Password for dlitz:
     $ ssh localhost true
     Hello from /bin/bash
     $ chsh -s/opt/local/bin/bash
     Changing shell for dlitz.
     Password for dlitz:
     $ ssh localhost true
     $
     }}}

 == Explanation ==

 There's an option in config-top.h that's not enabled by default, but it's
 usually defined by Linux distros, and by Apple in OSX:

     {{{
     /* Define this if you want bash to try to check whether it's being run
 by
        sshd and source the .bashrc if so (like the rshd behavior).  This
 checks
        for the presence of SSH_CLIENT or SSH2_CLIENT in the initial
 environment,
        which can be fooled under certain not-uncommon circumstances. */
     /* #define SSH_SOURCE_BASHRC */
     }}}

 This needs to be enabled.

 == Impact ==

 This breaks things like git or hg over ssh.

 == Solution ==

 Add the following to bash's Portfile:

     {{{
     configure.cflags-append "-DSSH_SOURCE_BASHRC"
     }}}

-- 
Ticket URL: <https://trac.macports.org/ticket/40603>
MacPorts <http://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list