mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] startup: don't fallback to shell from menu
@ 2024-11-25 15:39 Ahmad Fatoum
  2024-11-29 12:03 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-11-25 15:39 UTC (permalink / raw)
  To: barebox; +Cc: Christian Melki, Ahmad Fatoum

The code to determine whether to drop to shell or to run the menu is a
bit hard to follow and may even be used to circumvent the menu in some
circumstances.

Fix this by wrapping the menu in an infinite loop and refuse dropping to
shell.

Suggested-by: Christian Melki <christian.melki@t2data.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/startup.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index d71d83c221dc..4c497d95bedb 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -318,16 +318,17 @@ static int run_init(void)
 	if (IS_ENABLED(CONFIG_NET) && !IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT))
 		eth_open_all();
 
-	if (autoboot == AUTOBOOT_MENU)
+	if (autoboot != AUTOBOOT_MENU) {
+		if (autoboot == AUTOBOOT_ABORT && autoboot == global_autoboot_state)
+			watchdog_inhibit_all();
+
+		run_shell();
+	}
+
+	while (1)
 		run_command(MENUFILE);
 
-	if (autoboot == AUTOBOOT_ABORT && autoboot == global_autoboot_state)
-		watchdog_inhibit_all();
-
-	run_shell();
-	run_command(MENUFILE);
-
-	return 0;
+	unreachable();
 }
 
 typedef void (*ctor_fn_t)(void);
-- 
2.39.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-29 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 15:39 [PATCH] startup: don't fallback to shell from menu Ahmad Fatoum
2024-11-29 12:03 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox