On FDE devices, initialize user 0
Fix ugly special cases for user 0: initialize them explicitly.
Bug: 26704408
Change-Id: I1b8536b9e5e87ea98b4009a309f2e22c56006651
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 5918609..e5e64b4 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -884,6 +884,13 @@
do_installkeys_ensure_dir_exists);
}
+static int do_init_user0(const std::vector<std::string>& args) {
+ if (!is_file_crypto()) {
+ return 0;
+ }
+ return e4crypt_do_init_user0();
+}
+
BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
constexpr std::size_t kMax = std::numeric_limits<std::size_t>::max();
static const Map builtin_functions = {
@@ -900,6 +907,7 @@
{"export", {2, 2, do_export}},
{"hostname", {1, 1, do_hostname}},
{"ifup", {1, 1, do_ifup}},
+ {"init_user0", {0, 0, do_init_user0}},
{"insmod", {1, kMax, do_insmod}},
{"installkey", {1, 1, do_installkey}},
{"load_persist_props", {0, 0, do_load_persist_props}},
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 289bdec..343d316 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -420,6 +420,8 @@
symlink /data/data /data/user/0
+ init_user0
+
# Reload policy from /data/security if present.
setprop selinux.reload_policy 1