<div dir="ltr"><div>I had a problem where bash was not overwriting the default PATH variable which defaults to &#39;/usr/bin:/bin&#39;. This was causing remote management to fail because it couldn&#39;t find the commands in the PATH. I found that for bash to execute ~/.bashrc the environment variable &#39;SSH_CLIENT&#39; needs to be set. Openssh sets the variable to &quot;remoteip remote_port local_port&quot;, which is very similar to &#39;SSH_CONNECTION&#39;. This patch sets the &#39;SSH_CLIENT&#39; environment variable which causes bash to execute .bashrc upon startup.</div><div><br></div><div>Thanks,</div><div>Ryan</div><div><br></div><div><div>Author: Ryan &lt;<a href="mailto:rcleere@gmail.com">rcleere@gmail.com</a>&gt;</div><div>Date:   Mon Oct 20 12:59:47 2014 -0500</div><div><br></div><div>    Add SSH_CLIENT environment variable</div><div><br></div><div>diff --git a/chansession.h b/chansession.h</div><div>index 1a01d04..50ba8f0 100644</div><div>--- a/chansession.h</div><div>+++ b/chansession.h</div><div>@@ -54,6 +54,9 @@ struct ChanSess {</div><div>        /* Used to set $SSH_CONNECTION in the child session.</div><div>        Is only set temporarily before forking */</div><div>        char *connection_string;</div><div>+</div><div>+       /* Used to set $SSH_CLIENT in the child session. */</div><div>+       char *client_string;</div><div><br></div><div> #ifndef DISABLE_X11FWD</div><div>        struct Listener * x11listener;</div><div>diff --git a/svr-chansession.c b/svr-chansession.c</div><div>index 6c73778..b3c5c87 100644</div><div>--- a/svr-chansession.c</div><div>+++ b/svr-chansession.c</div><div>@@ -241,6 +241,7 @@ static int newchansess(struct Channel *channel) {</div><div>        chansess = (struct ChanSess*)m_malloc(sizeof(struct ChanSess));</div><div>        chansess-&gt;cmd = NULL;</div><div>        chansess-&gt;connection_string = NULL;</div><div>+       chansess-&gt;client_string = NULL;</div><div>        chansess-&gt;pid = 0;</div><div><br></div><div>        /* pty details */</div><div>@@ -617,6 +618,21 @@ static char* make_connection_string() {</div><div>        return ret;</div><div> }</div><div><br></div><div>+static char* make_client_string() {</div><div>+       char *local_ip, *local_port, *remote_ip, *remote_port;</div><div>+       size_t len;</div><div>+       char *ret;</div><div>+       get_socket_address(ses.sock_in, &amp;local_ip, &amp;local_port, &amp;remote_ip, &amp;remote_port, 0);</div><div>+       len = strlen(local_ip) + strlen(local_port) + strlen(remote_ip) + strlen(remote_port) + 4;</div><div>+       ret = m_malloc(len);</div><div>+       snprintf(ret, len, &quot;%s %s %s&quot;, remote_ip, remote_port, local_port);</div><div>+       m_free(local_ip);</div><div>+       m_free(local_port);</div><div>+       m_free(remote_ip);</div><div>+       m_free(remote_port);</div><div>+       return ret;</div><div>+}</div><div>+</div><div> /* Handle a command request from the client. This is used for both shell</div><div>  * and command-execution requests, and passes the command to</div><div>  * noptycommand or ptycommand as appropriate.</div><div>@@ -678,6 +694,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,</div><div>        connection_string is freed below. */</div><div> #ifndef USE_VFORK</div><div>        chansess-&gt;connection_string = make_connection_string();</div><div>+       chansess-&gt;client_string = make_client_string();</div><div> #endif</div><div><br></div><div>        if (chansess-&gt;term == NULL) {</div><div>@@ -694,6 +711,7 @@ static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,</div><div><br></div><div> #ifndef USE_VFORK</div><div>        m_free(chansess-&gt;connection_string);</div><div>+       m_free(chansess-&gt;client_string);</div><div> #endif</div><div><br></div><div>        if (ret == DROPBEAR_FAILURE) {</div><div>@@ -949,6 +967,10 @@ static void execchild(void *user_data) {</div><div>        if (chansess-&gt;connection_string) {</div><div>                addnewvar(&quot;SSH_CONNECTION&quot;, chansess-&gt;connection_string);</div><div>        }</div><div>+</div><div>+       if (chansess-&gt;client_string) {</div><div>+               addnewvar(&quot;SSH_CLIENT&quot;, chansess-&gt;client_string);</div><div>+       }</div><div><br></div><div> #ifdef ENABLE_SVR_PUBKEY_OPTIONS</div><div>        if (chansess-&gt;original_command) {</div></div></div>