mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
homectl: when chainloading a shell, prefix "-" rather than overriding first char
Login shells are supposed to marked via a dash as first char. We follow that logic, but right now we simply overwrite the first char of the shell. That might not be the right choice, given that this turns "zsh" into "-sh", which suggests some bourne shell process. Hence, let's correct things, and instead prefix a dash, which should be safer. Inspired by findings on https://github.com/systemd/systemd/issues/34153#issuecomment-2338104907
This commit is contained in:
parent
3a2a8585e6
commit
34ed064f67
@ -4538,8 +4538,13 @@ static int fallback_shell(int argc, char *argv[]) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EISDIR), "Shell '%s' is a path to a directory, refusing.", shell);
|
||||
|
||||
/* Invoke this as login shell, by setting argv[0][0] to '-' (unless we ourselves weren't called as login shell) */
|
||||
if (!argv || isempty(argv[0]) || argv[0][0] == '-')
|
||||
argv0[0] = '-';
|
||||
if (!argv || isempty(argv[0]) || argv[0][0] == '-') {
|
||||
_cleanup_free_ char *prefixed = strjoin("-", argv0);
|
||||
if (!prefixed)
|
||||
return log_oom();
|
||||
|
||||
free_and_replace(argv0, prefixed);
|
||||
}
|
||||
|
||||
l = strv_new(argv0);
|
||||
if (!l)
|
||||
|
Loading…
Reference in New Issue
Block a user