Skip to contentSkip to conversation

How to set target system PATH?

Buildroot Grant Edwards 2 participants 5 messages Jan 23, 2025

lore
Share & tools
lore
#0 lore raw

I've set the desired PATH in the config file:

BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/apps/bin"

But that only seems to affect login shells, and not daemons started from /etc/init.d.

How do I set the _system_ PATH rather than just the login shell PATH.

--
Grant

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#1 lore raw
Quoted 8 lines · Grant Edwards

I've set the desired PATH in the config file:

   BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/apps/bin"

But that only seems to affect login shells, and not daemons started from /etc/init.d.

How do I set the _system_ PATH rather than just the login shell PATH.

Good question! That depends on the init system (because that one is
responsible to set the path). I looked in the source, and it looks like both systemd and busybox init hardcode it without any configuration option...

So unless you convince the maintainers of your favourite init system to
change, you won't be able to customize the system path.

Regards,
Arnout

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi Arnout, Grant,

Quoted 10 lines · Arnout Vandecappelle via buildroot
Quoted 5 lines · Grant Edwards

I've set the desired PATH in the config file:

   BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/apps/bin"

But that only seems to affect login shells, and not daemons started from /etc/init.d.
How do I set the _system_ PATH rather than just the login shell PATH.

Good question! That depends on the init system (because that one is responsible to set the path). I looked in the source, and it looks like both systemd and busybox init hardcode it without any configuration option...

Busybox code indicates that you can extend the default PATH by setting the BB_ADDITIONAL_PATH macro in CFLAGS.

SysV init appears to hard code the PATH.

baruch

Signature · 7 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Arnout Vandecappelle via buildroot
Quoted 10 lines · Arnout Vandecappelle via buildroot
Quoted 7 lines · Grant Edwards

I've set the desired PATH in the config file:

   BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/apps/bin"

But that only seems to affect login shells, and not daemons started from /etc/init.d.

Quoted 8 lines
Quoted 1 line

How do I set the _system_ PATH rather than just the login shell PATH.

Good question! That depends on the init system (because that one is
responsible to set the path). I looked in the source, and it looks like both systemd and busybox init hardcode it without any configuration option...

So unless you convince the maintainers of your favourite init system to
change, you won't be able to customize the system path.

Yea, I've been looking at the busybox init docs, and it doesn't look like there's any way to add/change the environment variables. It sure would have been nice if that could be done in /etc/inittab.

I dug through the local archives, and it turns out I addressed this problem once 13 years ago. I used a postbbuild script and sed commands to insert a couple lines into etc/init.d/rcS to set/export PATH and LD_LIBRARY_PATH.

IIRC, I wasn't very happy with that at the time, but I guess I'll have to do it again.

--
Grant

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Baruch Siach via buildroot
Quoted 10 lines · Baruch Siach via buildroot

Hi Arnout, Grant,

Quoted 7 lines · Arnout Vandecappelle via buildroot
Quoted 5 lines · Grant Edwards

I've set the desired PATH in the config file:

   BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/apps/bin"

But that only seems to affect login shells, and not daemons started from /etc/init.d.
How do I set the _system_ PATH rather than just the login shell PATH.

Quoted 8 lines
Quoted 3 lines

Good question! That depends on the init system (because that one is responsible to set the path). I looked in the source, and it looks like both systemd and busybox init hardcode it without any configuration option...

Busybox code indicates that you can extend the default PATH by setting the BB_ADDITIONAL_PATH macro in CFLAGS.

SysV init appears to hard code the PATH.

Great! I'm using busybox init, so I'll try setting CONFIG_EXTRA_CFLAGS in the busybox config. I'd really like to avoid having to munge rc.S with a post-build script.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot