Centos – xrdp changing PATH environment variable

centoscentos7environment-variablesremote desktop

All,

I'm using xrdp to connect to a Centos 7 box. I notice that my PATH environment variable is different depending on whether I RDP in or SSH and I can't for the life of me figure out where that's happening.

I've checked /etc/xrdp/startwm.sh but all the PATH related code is already commented out. My /etc/profile is fairly standard and there's nothing in /etc/profile.d that would be doing this. Besides, if it were somewhere in /etc/profile[.d] then that would be applied even during SSH logins.

I've seen this mentioned a few times in various places on the Internets with no real solution or explanation.

Anyone have an explanation and can point me in the right direction?

Kind of driving me crazy not knowing where this is happening!

EDIT:

I should have been more clear. It's the RDP scenario that I am having trouble figuring out. I can pretty much explain all the PATH related shenanigans I see during an SSH session (or even during a VNC session, mostly anyway). If I look through the /etc/profile* settings as well as my own ~/.bash_profile, things make sense during an SSH session. But when I RDP in, things get weird.

In addition to /etc/xrdp/startwm.sh, I checked /etc/security/pam_env.conf in which everything was already commented out.

EDIT 2:

In an SSH/normal login session, my path looks like:

/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

In an RDP session, my PATH looks like:

/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin

I can see in /etc/profile where /usr/local/sbin and /usr/sbin are being appended (or prepended if root).

In the RDP case, there are a couple additions as well as things being rearranged. For example, /bin is all of a sudden present, as well as /usr/XllR6/bin. Also, /usr/bin is now before /usr/local/bin. It's mostly this last part that I don't want.

I know I could fix it up in my own ~/.bash_profile, but I don't see why I should have to. Don't see why the path is being messed with to that degree in the first place.

Thanks,
Justin

Best Answer

I'm not sure if this will solve your issue, since it impacts Ubuntu with XRDP and XFCE4. Still, there is a chance it does, so let's see.

I was facing a similar problem: the PATH environment variable was different when I logged into the machine through SSH and through XRDP. Concretely, when I opened a Terminal window in XRDP (xterm), the PATH variable was not set with local user paths (~/bin, ~/.local/bin, etc).

However, these paths were present when I logged in through SSH.

The problem was not in XRDP, but in how the Bash session is created with XTerm and with SSH. Since SSH creates a login session, the loaded files included /etc/environment and ~/.profile. In the latter, the paths I required were included.

This was not the case with XTerm. It creates a non-login bash session, and thus it loads /etc/bash.bashrc and ~/.bashrc.

The way I could fix it was simply to include the PATH initialization line from ~/.profile into one of these two files. Since I wanted this to impact all the users in the machine, I included it into /etc/bash.bashrc:

echo PATH="$HOME/bin:$HOME/.local/bin:$PATH" >> /etc/bash.bashrc

You can find more information about how works in man bash