[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Avoid sourcing bashrc when connected to sockets
From: |
Greg Wooledge |
Subject: |
Re: Avoid sourcing bashrc when connected to sockets |
Date: |
Mon, 21 Feb 2022 14:41:59 -0500 |
On Mon, Feb 21, 2022 at 11:15:43AM -0800, Andrew Gregory wrote:
> 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)
> {
>
Oh, that's interesting. Very... historical. And not configurable at all,
which is what really surprises me. I wonder why the check for ssh is
configurable (and off by default) but the check for rsh is hard-wired on.
There's a bit of inconsistency here.
Based on that code, I don't think there's any better answer than overriding
the SHLVL variable, as you have already discovered.
- Avoid sourcing bashrc when connected to sockets, Andrew Gregory, 2022/02/13
- Re: Avoid sourcing bashrc when connected to sockets, Kerin Millar, 2022/02/13
- Re: Avoid sourcing bashrc when connected to sockets, Alex fxmbsw7 Ratchev, 2022/02/13
- Re: Avoid sourcing bashrc when connected to sockets, Chet Ramey, 2022/02/14
- Re: Avoid sourcing bashrc when connected to sockets, Chet Ramey, 2022/02/21
- Re: Avoid sourcing bashrc when connected to sockets, Andrew Gregory, 2022/02/21