LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   kdm/kde hijacking $PATH environment (https://www.linuxquestions.org/questions/linux-software-2/kdm-kde-hijacking-%24path-environment-764191/)

<Ol>Origy 10-24-2009 11:32 AM

kdm/kde hijacking $PATH environment
 
Hello.

I have small problem with my environment variables, particularly the $PATH. I have set the PATH in /etc/environment to: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:."

It was a small modification to include the current path "." at the end. If I let the system boot to the kdm login screen, and do ctrl+alt+F2 to login on another tty as a regular user, I get the proper $PATH output when issuing a `set` command or `echo $PATH`. The same happens when I login as root. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:.

Going back to kdm with ctrl+alt+F7 and logging in with my regular user account will bring me to my KDE screen. So when I fire up a terminal (Konsole) in KDE, the $PATH will look completely different: PATH=/opt/kde3/bin:/opt/kde3/games:/usr/local/bin:/opt/kde3/bin:/usr/bin:/bin:/opt/kde3/games:/usr/games

Notice that /opt/kde3/bin and /opt/kde3/games appear twice, and that /sbin is missing? It appears that for some reason $PATH is getting completely overwritten. Doing a `su <user>` to login as another user in the existing terminal will once again show appropriate $PATH as defined in /etc/environment.

Any ideas what might be causing this and how to prevent it? :scratch: My kde version is 3.5.10.

Elv13 10-24-2009 06:47 PM

Set it in your ~/.bashrc too, it might work.

<Ol>Origy 10-26-2009 02:17 AM

Yeah, exporting the path in .bashrc works. Looking at it again, I've exported a few more variables in /etc/environment, which do not appear in Konsole terminal unless I redefine them in .bashrc too. However, having two separate places for environmental vars isn't a good idea, as I'm sure you'd agree. I'm still wondering what is causing these vars to be overwritten and/or reset, as it did not happen before I installed kdm.

Looking at my disk, I found a file /etc/kde3/kdm/kdmrc where an interesting piece of text can be found:

Quote:

# The PATH for the Session program.
# Default is "/usr/local/bin:/opt/kde3/bin:/usr/bin:/bin:/opt/kde3/games:/usr/games"
#UserPath=
Notice how this string matches a part of the hijacked $PATH in my first post? In another file at /opt/kde3/bin/startkde you can see how the first two folders get added to the $PATH and become duplicates:

Quote:

export KDEHOME=$HOME/.kde3 && export PATH=/opt/kde3/bin:/opt/kde3/games:$PATH && export KDEDIRS=/usr/:/opt/kde3/ && export XDG_DATA_DIRS=/opt/kde3/share/:/usr/share/ && export XDG_CONFIG_DIRS=/opt/kde3/etc/xdg/:/etc/xdg/ && export MANPATH=/opt/kde3/share/man:$MANPATH
I think kdm is the main culprit here.


All times are GMT -5. The time now is 02:00 PM.