diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-04-18 16:11:06 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-04-22 09:53:24 +0200 |
commit | 0f36a4c897ff53eb0be3bd3728a3ff91e9c0664d (patch) | |
tree | b3fc0f27363355c0928a4089405385b22fe1ced7 /src/core/manager.c | |
parent | NEWS: mention GNOME Foundation in contributors list (diff) | |
download | systemd-0f36a4c897ff53eb0be3bd3728a3ff91e9c0664d.tar.xz systemd-0f36a4c897ff53eb0be3bd3728a3ff91e9c0664d.zip |
Try path without sbin even if compiled with split-bin=true
I'm working on the transition to merged sbin in Fedora. While the transition is
happening (and probably for a while after), we need to compile systemd with
split-bin=true to support systems upgraded from previous versions. But when the
system has been upgraded and already has /usr/sbin that is a symlink, be nice
and give $PATH without sbin.
We check for both /usr/sbin and /usr/local/sbin. If either exists and is not a
symlink to ./bin, we retain previous behaviour. This means that if both are
converted, we get the same behaviour as split-bin=false, and otherwise we
get the same behaviour as before.
sd-path uses the same logic. This is not a hot path, so I got rid of the nulstr
macros that duplicated the logic.
Diffstat (limited to 'src/core/manager.c')
-rw-r--r-- | src/core/manager.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 3ffe0f87c0..b627e7abc0 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -658,8 +658,6 @@ static char** sanitize_environment(char **l) { } int manager_default_environment(Manager *m) { - int r; - assert(m); m->transient_environment = strv_free(m->transient_environment); @@ -670,8 +668,11 @@ int manager_default_environment(Manager *m) { * * The initial passed environment is untouched to keep /proc/self/environ valid; it is used * for tagging the init process inside containers. */ - m->transient_environment = strv_new("PATH=" DEFAULT_PATH); - if (!m->transient_environment) + char *path = strjoin("PATH=", default_PATH()); + if (!path) + return log_oom(); + + if (strv_consume(&m->transient_environment, path) < 0) return log_oom(); /* Import locale variables LC_*= from configuration */ @@ -684,8 +685,11 @@ int manager_default_environment(Manager *m) { if (!m->transient_environment) return log_oom(); - r = strv_env_replace_strdup(&m->transient_environment, "PATH=" DEFAULT_USER_PATH); - if (r < 0) + char *path = strjoin("PATH=", default_user_PATH()); + if (!path) + return log_oom(); + + if (strv_env_replace_consume(&m->transient_environment, path) < 0) return log_oom(); /* Envvars set for our 'manager' class session are private and should not be propagated |