From: Mike Yuan Date: Tue, 8 Apr 2025 20:35:14 +0000 (+0200) Subject: run0: make sure we submit $SHELL to remote X-Git-Tag: v256.14~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=977e985b628520c0075e084ea6d8752b38d4be86;p=thirdparty%2Fsystemd.git run0: make sure we submit $SHELL to remote Normally, the service manager sets $SHELL to the target user's login shell, but run0 always overrides that with either originating user's shell or value from --setenv=SHELL=. In both cases $SHELL needs to be sent. Fixes #35007 (cherry picked from commit ba7fb8cf5f8f6ad26ff5509722ab4795e566bf09) (cherry picked from commit fbfeda9ff5eefad33dbb40c02c1d51e877a7baa5) --- diff --git a/src/run/run.c b/src/run/run.c index d8118763f07..b40e188455f 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -912,18 +912,25 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) { const char *e; e = strv_env_get(arg_environment, "SHELL"); - if (e) + if (e) { arg_exec_path = strdup(e); - else { + if (!arg_exec_path) + return log_oom(); + } else { if (arg_transport == BUS_TRANSPORT_LOCAL) { r = get_shell(&arg_exec_path); if (r < 0) return log_error_errno(r, "Failed to determine shell: %m"); - } else + } else { arg_exec_path = strdup("/bin/sh"); + if (!arg_exec_path) + return log_oom(); + } + + r = strv_env_assign(&arg_environment, "SHELL", arg_exec_path); + if (r < 0) + return log_error_errno(r, "Failed to set $SHELL environment variable: %m"); } - if (!arg_exec_path) - return log_oom(); l = make_login_shell_cmdline(arg_exec_path); }