[klibc] [PATCH 5/8] switch_root: check that init is executable.

maximilian attems max at stro.at
Wed Jul 13 06:48:30 PDT 2011


Minimal check for the passed init.
This can be further enhanced to cleanup kinit and
switch_root(8) callers.

Signed-off-by: maximilian attems <max at stro.at>
---
 usr/kinit/switch_root/switch_rootlib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/usr/kinit/switch_root/switch_rootlib.c b/usr/kinit/switch_root/switch_rootlib.c
index 8c9599e..14c3e34 100644
--- a/usr/kinit/switch_root/switch_rootlib.c
+++ b/usr/kinit/switch_root/switch_rootlib.c
@@ -205,6 +205,9 @@ const char *switch_root(const char *realroot, const char *console,
 	dup2(confd, 2);
 	close(confd);
 
+	if (access(init, X_OK))
+		fprintf(stderr, "cannot acces %s\n", init);
+
 	/* Spawn init */
 	execv(init, initargs);
 	return init;		/* Failed to spawn init */
-- 
1.7.5.4



More information about the klibc mailing list