The officially official Devuan Forum!

You are not logged in.

#1 Today 01:05:57

Eeqmcsq
Member
Registered: 2017-09-19
Posts: 91  

[SOLVED] Excalibur + lightdm: How do I modify the PATH globally?

I want to add "/usr/sbin" to the PATH so I (or my scripts) can run a few sbin commands without needing sudo (examples: ifconfig, showmount). This is mainly for personal convenience.

In slim + Xfce, I can create a .sh file in /etc/profile.d, and append to the PATH:

  PATH=$PATH:/example/path

But this doesn't work with lightdm. My testing shows that lightdm doesn't run /etc/profile, which means none of the scripts in /etc/profile.d are run. And I've confirmed that the problem is lightdm, because when I switched from slim + Xfce to lightdm + Xfce, /etc/profile is NOT run anymore.

* Solutions that don't work for me
 
- Use ~/.xsessionrc. This doesn't work because TTY (CTRL+ALT+F1), ssh, or telnet does NOT run ~/.xsessionrc.

- Use ~/.bashrc. This doesn't work if I double click on a script file to launch it. ~/.bashrc is NOT run.
 
- Use /etc/environment. This also doesn't work in TTY, ssh, or telnet. It also requires me to hardcode the rest of the system paths, because /etc/environment does not support script syntax, so I can't append to an existing PATH value.

- Maybe I can find where PATH is first initialized globally, and append my path there. I've tried:
  - The initial PATH value is "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games", and I've confirmed that even though /etc/profile sets the PATH to this string, this string is ALREADY set to PATH at the start of /etc/profile. Where is it coming from?
  - I searched /etc for "/usr/games", and the only file that could make sense is /etc/login.defs. But when I manually appended a dummy path "/dbg/logindefs", and rebooted, the dummy path is NOT in PATH.
  - I extracted the ramdisk /boot/initrd.img-6.12.63+deb13-amd64, and did not find "/usr/games". Now I'm out of ideas.

* Questions

? Where can I append to the PATH globally?

? Also, where exactly is the PATH first initialized?

Last edited by Eeqmcsq (Today 01:18:02)

Offline

#2 Today 03:10:02

rbit
Member
Registered: 2018-06-12
Posts: 103  

Re: [SOLVED] Excalibur + lightdm: How do I modify the PATH globally?

I see in slim.conf: default_path        /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
but I'm not seeing anything similar in lightdm.conf.

Evidently, TTY login gets path from /etc/profile, then ~/.profile - both of which seem to be ignored by lightdm

I know it's not answering your questions (I don't know the answers), but for now you could use a combination of /etc/profile (for tty) and ~/.xsessionrc (for X)

(edit)
From this page https://wiki.archlinux.org/title/LightDM

LightDM starts your display and does not source your shell. LightDM launches the display by running a wrapper script and that finally exec's your graphic environment. By default, /etc/lightdm/Xsession is run.
5.3.1 Environment variables
The script checks and sources /etc/profile, ~/.profile, /etc/xprofile and ~/.xprofile, in that order.

I was not able to get xprofile to work, either.  I'm wondering if something is missing or misconfigured by default, or if this is a bug.

Last edited by rbit (Today 03:28:05)

Offline

#3 Today 03:59:10

Eeqmcsq
Member
Registered: 2017-09-19
Posts: 91  

Re: [SOLVED] Excalibur + lightdm: How do I modify the PATH globally?

I think I found that same archlinux page after my initial post, and I also couldn't get /etc/xprofile to work. I had also thought about appending the path in two places to handle all of my cases. So it looks like we've been down the same path of thinking.

* Solution for lightdm

- Create a .sh file in /etc/profile.d, append /usr/sbin to the PATH variable. This covers the tty/telnet/ssh cases.
- Create a local file ~/.xsessionrc, append to the PATH variable. This covers the MATE Terminal and double-click-on-script cases.

A quick test of all of my test cases running "ifconfig" without sudo confirms this solution works for me. I'll marked this as solved.

Offline

Board footer