From 0931a9f15e7436346e33c66129f3ff822c33f52a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 22 Sep 2012 23:59:21 +0200 Subject: Check that runsystem script exists before trying it. * init/init.c (launch_something): Check with file_name_lookup that runsystem script exists before calling start_child. * daemons/console-run.c (main): Check with file_name_lookup that runsystem script exists before opening a console for it. --- init/init.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'init') diff --git a/init/init.c b/init/init.c index d66bee0b..edfe1236 100644 --- a/init/init.c +++ b/init/init.c @@ -1082,6 +1082,7 @@ start_child (const char *prog, char **progargs) static void launch_something (const char *why) { + file_t something; static unsigned int try; static const char *const tries[] = { @@ -1093,12 +1094,26 @@ launch_something (const char *why) if (why) error (0, 0, "%s %s", tries[try - 1], why); - if (try == 0 && start_child (tries[try++], &global_argv[1]) == 0) - return; + something = file_name_lookup (tries[try], O_EXEC, 0); + if (something != MACH_PORT_NULL) + { + mach_port_deallocate (mach_task_self (), something); + if (try == 0 && start_child (tries[try++], &global_argv[1]) == 0) + return; + } + else + try++; while (try < sizeof tries / sizeof tries[0]) - if (start_child (tries[try++], NULL) == 0) - return; + { + something = file_name_lookup (tries[try], O_EXEC, 0); + if (something != MACH_PORT_NULL) + { + mach_port_deallocate (mach_task_self (), something); + if (start_child (tries[try++], NULL) == 0) + return; + } + } crash_system (); } -- cgit v1.2.3