From 32232724fbb21bba8aafa9e40036ace7f1c619db Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Wed, 1 Mar 2017 18:24:46 +0800 Subject: [PATCH] init: skip early mount in recovery mode We don't need early mount in recovery mode for security considerations, e.g., users should explicitly select 'mount /system' from the recovery menu. This CL checks the existence of file "/sbin/recovery" and skip early mount when it is found. Bug: 35853576 Test: early mount /vendor without dm-verity on sailfish Test: early mount not happen in recovery mode on sailfish Change-Id: I69cc96f6fd0de6ce493082921738a958dd571115 --- init/init.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/init/init.cpp b/init/init.cpp index bddf005bf..ad4042617 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -790,6 +790,12 @@ static bool get_early_partitions(const std::vector& early_fstab_recs /* Early mount vendor and ODM partitions. The fstab is read from device-tree. */ static bool early_mount() { + // skip early mount if we're in recovery mode + if (access("/sbin/recovery", F_OK) == 0) { + LOG(INFO) << "Early mount skipped (recovery mode)"; + return true; + } + // first check if device tree fstab entries are compatible if (!is_dt_fstab_compatible()) { LOG(INFO) << "Early mount skipped (missing/incompatible fstab in device tree)";