Skip to content

WIP: Preserve PATH - #1083

Open
stacyharper wants to merge 2 commits into
OpenRC:masterfrom
stacyharper:wbarraco/rrvpnryrmuto
Open

stacyharper wants to merge 2 commits into
OpenRC:masterfrom
stacyharper:wbarraco/rrvpnryrmuto

Conversation

@stacyharper

@stacyharper stacyharper commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Seems to works, but is it okay? Also should we now add PATH as user allow env list?

We already re-order them in src/shared/misc.c env_config. Here we just
have to add this libexec part to have access to einfo, etc...
Before re-ordering parts, store the initial value as RC_PREV_PATH,
and restore this just before stripping RC_* values on start-stop-daemon
and supervise-daemon.
Comment thread sh/functions.sh.in
export PATH="@LIBEXECDIR@/bin:/bin:/sbin:/usr/bin:/usr/sbin:@LOCAL_PREFIX@/bin:@LOCAL_PREFIX@/sbin$(_sanitize_path)"
unset _sanitize_path
# Add libexec to PATH
export PATH="@LIBEXECDIR@/bin:$PATH"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we also have to add LOCAL_PREFIX/{,s}bin?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local prefix is /usr/local or /usr/pkg, if we're not adding system paths like /bin, it'd be consistent to not add /usr/local either

also, env_config already adds RC_LIBEXECDIR "/bin", /bin, /sbin, /usr/bin, and /usr/sbin to PATH

it also still reorders the path, to put those first, now that i look at it

lastly we shouldn't change functions.sh unconditionally, it can be sourced by other scripts via /etc/init.d/functions.sh, if we're removing that bit of code, probably better to guard it behind RC_OPENRC_PID being defined

Comment thread sh/functions.sh.in
export PATH="@LIBEXECDIR@/bin:/bin:/sbin:/usr/bin:/usr/sbin:@LOCAL_PREFIX@/bin:@LOCAL_PREFIX@/sbin$(_sanitize_path)"
unset _sanitize_path
# Add libexec to PATH
export PATH="@LIBEXECDIR@/bin:$PATH"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this could store RC_PREV_PATH if not set, so that we drop this LIBEXECDIR/bin later

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start-stop-daemon and supervise-daemon already strip that entry from path before starting the daemon, fwiw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants