0

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

  • There are a number of files that can be sourced that are completely unique to a SSH connection. I helped someone audit this last year and I think steering you in the direction of that answer will help eliminate a number possibilities. Please let us know when you've ruled out those possibilities and edit your question to contain all of the files you've checked. – Andrew B Jul 30 '15 at 19:49
  • Thanks for the reply Andrew. I edited my question to make it more clear. It's actually the reverse scenario from the post you linked to, that I can't explain. See edits for details. – Justin Miller Jul 30 '15 at 20:02
  • Can you provide a specific example of things "getting weird" as you put it? It might help us narrow it down. – Andrew B Jul 30 '15 at 20:02
  • Yep! Done. See Edit 2. – Justin Miller Jul 31 '15 at 12:15
0

I had this problem under 6.6. Don't know if the same under 7.

/etc/profile sets system-wide environment variables and adds "sbin" paths for the "root" user. /etc/xrdp/startwm.sh loads this file in the pre_start() function which is executed at the bottom of the file.

But the top of /etc/xrdp/startwm.sh looks like this:

# if xinitrc exists use it instead, it should load user prefferences
# including desktop environment specified in /etc/sysconfig/desktop
if [ -f /etc/X11/xinit/xinitrc ]
then
    . /etc/X11/xinit/xinitrc
    exit 0
fi 

So, if /etc/X11/xinit/xinitrc exists, /etc/xrdp/startwm.sh executes it and terminates so none of the remaining setup is done. /etc/X11/xinit/xinitrc does not load /etc/profile, at least mine didn't.

I commented out the check for xinitrc in startwm.sh:

# if xinitrc exists use it instead, it should load user prefferences
# including desktop environment specified in /etc/sysconfig/desktop
#if [ -f /etc/X11/xinit/xinitrc ]
#then
#    . /etc/X11/xinit/xinitrc
#    exit 0
#fi 

This solved the problem for me and I didn't notice any difference in the function of XRDP.

0

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.