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. --- daemons/console-run.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'daemons') diff --git a/daemons/console-run.c b/daemons/console-run.c index aaa1159b..fb879e53 100644 --- a/daemons/console-run.c +++ b/daemons/console-run.c @@ -49,6 +49,7 @@ int main (int argc, char **argv) { mach_port_t consdev = get_console (); + mach_port_t runsystem; char *consname; if (consdev == MACH_PORT_NULL) @@ -62,6 +63,12 @@ main (int argc, char **argv) if (argc < 2) error (1, 0, "Usage: %s PROGRAM [ARG...]", program_invocation_short_name); + /* Check whether runsystem exists before opening a console for it. */ + runsystem = file_name_lookup (argv[1], O_RDONLY, 0); + if (runsystem == MACH_PORT_NULL) + error (127, errno, "cannot open file `%s' for execution", argv[1]); + mach_port_deallocate (mach_task_self (), runsystem); + if (open_console (&consname)) setenv ("FALLBACK_CONSOLE", consname, 1); -- cgit v1.2.3