From 66bc428f93546065ca73779ebefd1082244ecea2 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Thu, 8 Nov 2018 13:40:52 -0800 Subject: linker: changes to init work arounds Change three things regarding the work around to the fact that init is special: 1) Only first stage init is special, so we change the check to include accessing /proc/self/exe, which if is available, means that we're not first stage init and do not need any work arounds. 2) Fix the fact that /init may be a symlink and may need readlink() 3) Suppress errors from realpath_fd() since these are expected to fail due to /proc not being mounted. Bug: 80395578 Test: sailfish boots without the audit generated from calling stat() on /init and without the errors from realpath_fd() Change-Id: I266f1486b142cb9a41ec791eba74122bdf38cf12 --- linker/linker_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linker/linker_utils.cpp') diff --git a/linker/linker_utils.cpp b/linker/linker_utils.cpp index 6b9aec9fa..72a8fa8fe 100644 --- a/linker/linker_utils.cpp +++ b/linker/linker_utils.cpp @@ -240,7 +240,7 @@ void resolve_paths(std::vector& paths, } } -bool is_init() { - static bool ret = (getpid() == 1); +bool is_first_stage_init() { + static bool ret = (getpid() == 1 && access("/proc/self/exe", F_OK) == -1); return ret; } -- cgit v1.2.3