Preserve environment when launching overlay_remounter
fexecve does not preserve the environment by default. The environment is
used to pass certain information to second stage init. Specifically
whether force debuggable is set is passed this way.
Test: Run following steps
vendor/google/tools/flashall --wipe --force_debuggable
adb shell getprop ro.adb.secure
adb root && adb remount && adb reboot
adb shell getprop ro.adb.secure
Without this change, the first getprop would return 0 and the second 1
With this change, both return 0
Bug: 397402912
Change-Id: I4722bd0c2960dd695dc096d8c59c259d12c28a65
diff --git a/init/selinux.cpp b/init/selinux.cpp
index 8bdf5b6..2a27c1d 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -749,7 +749,7 @@
PLOG(FATAL) << "Failed to unlink " << or_dest;
}
const char* args[] = {or_dest.c_str(), nullptr};
- fexecve(dest.get(), const_cast<char**>(args), nullptr);
+ fexecve(dest.get(), const_cast<char**>(args), environ);
// execv() only returns if an error happened, in which case we
// panic and never return from this function.