help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoid sourcing bashrc when connected to sockets


From: Andrew Gregory
Subject: Re: Avoid sourcing bashrc when connected to sockets
Date: Mon, 21 Feb 2022 11:15:43 -0800

On 02/21/22 at 02:01pm, Greg Wooledge wrote:
> On Mon, Feb 21, 2022 at 10:31:21AM -0800, Andrew Gregory wrote:
> > On 02/14/22 at 11:11am, Chet Ramey wrote:
> > > You might also want to tell your vendor about this, since they built bash
> > > with the non-standard option that enables this behavior.
> > 
> > Can you explain this?  Looking at the package build script[1] and the bash
> > source, nothing stands out to me as specifically enabling this behavior.
> 
> I don't know Arch, but Debian does it by applying a patch:
> 
> https://sources.debian.org/src/bash/5.1-2/debian/patches/deb-bash-config.diff/
> 
> The last piece of that patch sets the SSH_SOURCE_BASHRC macro in the
> config-top.h file, which is what enables the feature.  I would guess
> that Arch does something similar, with whatever system of source code
> patches it uses.

Hmmm, that appears to be a different check, specific to ssh.  That shouldn't be
what we're hitting.  I believe we're hitting the isnetconn check below it,
which doesn't appear to be behind a configure option that I can see.  From
shell.c:

  /* get the rshd/sshd case out of the way first. */
  if (interactive_shell == 0 && no_rc == 0 && login_shell == 0 &&
      act_like_sh == 0 && command_execution_string)
    {
#ifdef SSH_SOURCE_BASHRC
      run_by_ssh = (find_variable ("SSH_CLIENT") != (SHELL_VAR *)0) ||
                   (find_variable ("SSH2_CLIENT") != (SHELL_VAR *)0);
#else
      run_by_ssh = 0;
#endif

      /* If we were run by sshd or we think we were run by rshd, execute
         ~/.bashrc if we are a top-level shell. */
      if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)
        {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]