Applied, thank you.

On Mon, Nov 25, 2024 at 6:08 AM Hajime Tazaki <[email protected]> wrote:
>
> When the busybox is used as /sbin/init and the inittab file contains
> below:
>
> ::respawn:-/bin/sh
>
> /sbin/init spawns hush for the first time with the argv[0] contains '-',
> and hush treats it as login shell.  Then it reads /etc/profile and if
> the file contains the command execution like below, it invokes hush as
> login shell because the argv[0] argument is still '-/bin/sh' and reads
> /etc/profile again.  This will last until some failure (e.g., memory
> failure) happens.
>
>   [ "$(id -u)" -eq 0 ] && PS1="${PS1}# " || PS1="${PS1}\$ "
>
> This commit fixes this issues by adding an offset (+1) to the
> G.argv0_for_re_execing variable.
>
> This issue happens on our out-of-tree UML (use mode linux) with nommu
> configuration.
>
> Link: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Hajime Tazaki <[email protected]>
> ---
>  shell/hush.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/shell/hush.c b/shell/hush.c
> index 04dda0734..cd00a9a41 100644
> --- a/shell/hush.c
> +++ b/shell/hush.c
> @@ -10361,6 +10361,8 @@ int hush_main(int argc, char **argv)
>                 _exit(0);
>         }
>         G.argv0_for_re_execing = argv[0];
> +       if (G.argv0_for_re_execing[0] == '-')
> +               G.argv0_for_re_execing += 1;
>  #endif
>  #if ENABLE_HUSH_TRAP
>  # if ENABLE_HUSH_FUNCTIONS
> --
> 2.43.0
>
> _______________________________________________
> busybox mailing list
> [email protected]
> https://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to