Merge "restorecon hwservice_contexts." into oc-dev
diff --git a/include/system b/include/system
new file mode 120000
index 0000000..b443c36
--- /dev/null
+++ b/include/system
@@ -0,0 +1 @@
+../libsystem/include/system
\ No newline at end of file
diff --git a/init/init.cpp b/init/init.cpp
index db27df1..0063017 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -736,6 +736,18 @@
return true;
}
+static bool selinux_get_vendor_mapping_version(std::string* plat_vers) {
+ if (!read_first_line("/vendor/etc/selinux/plat_sepolicy_vers.txt", plat_vers)) {
+ PLOG(ERROR) << "Failed to read /vendor/etc/selinux/plat_sepolicy_vers.txt";
+ return false;
+ }
+ if (plat_vers->empty()) {
+ LOG(ERROR) << "No version present in plat_sepolicy_vers.txt";
+ return false;
+ }
+ return true;
+}
+
static constexpr const char plat_policy_cil_file[] = "/system/etc/selinux/plat_sepolicy.cil";
static bool selinux_is_split_policy_device() { return access(plat_policy_cil_file, R_OK) != -1; }
@@ -790,6 +802,12 @@
return false;
}
+ // Determine which mapping file to include
+ std::string vend_plat_vers;
+ if (!selinux_get_vendor_mapping_version(&vend_plat_vers)) {
+ return false;
+ }
+ std::string mapping_file("/system/etc/selinux/mapping/" + vend_plat_vers + ".cil");
// clang-format off
const char* compile_args[] = {
"/system/bin/secilc",
@@ -797,7 +815,7 @@
"-M", "true",
// Target the highest policy language version supported by the kernel
"-c", std::to_string(max_policy_version).c_str(),
- "/system/etc/selinux/mapping_sepolicy.cil",
+ mapping_file.c_str(),
"/vendor/etc/selinux/nonplat_sepolicy.cil",
"-o", compiled_sepolicy,
// We don't care about file_contexts output by the compiler
diff --git a/libsystem/Android.bp b/libsystem/Android.bp
new file mode 100644
index 0000000..4d076d5
--- /dev/null
+++ b/libsystem/Android.bp
@@ -0,0 +1,4 @@
+cc_library_headers {
+ name: "libsystem_headers",
+ export_include_dirs: ["include"],
+}
diff --git a/include/system/camera.h b/libsystem/include/system/camera.h
similarity index 100%
rename from include/system/camera.h
rename to libsystem/include/system/camera.h
diff --git a/include/system/graphics-base.h b/libsystem/include/system/graphics-base.h
similarity index 100%
rename from include/system/graphics-base.h
rename to libsystem/include/system/graphics-base.h
diff --git a/include/system/graphics.h b/libsystem/include/system/graphics.h
similarity index 100%
rename from include/system/graphics.h
rename to libsystem/include/system/graphics.h
diff --git a/include/system/qemu_pipe.h b/libsystem/include/system/qemu_pipe.h
similarity index 100%
rename from include/system/qemu_pipe.h
rename to libsystem/include/system/qemu_pipe.h
diff --git a/include/system/radio.h b/libsystem/include/system/radio.h
similarity index 100%
rename from include/system/radio.h
rename to libsystem/include/system/radio.h
diff --git a/include/system/thread_defs.h b/libsystem/include/system/thread_defs.h
similarity index 100%
rename from include/system/thread_defs.h
rename to libsystem/include/system/thread_defs.h
diff --git a/include/system/window-deprecated.h b/libsystem/include/system/window-deprecated.h
similarity index 100%
rename from include/system/window-deprecated.h
rename to libsystem/include/system/window-deprecated.h
diff --git a/include/system/window.h b/libsystem/include/system/window.h
similarity index 100%
rename from include/system/window.h
rename to libsystem/include/system/window.h
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 6a01baf..0b3e3ee 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -645,6 +645,12 @@
on property:sys.boot_completed=1
bootchart stop
+on property:sys.boot_completed=1 && property:ro.build.type=user
+ write /proc/sys/kernel/modules_disabled 1
+
+on property:sys.boot_completed=1 && property:ro.build.type=userdebug
+ write /proc/sys/kernel/modules_disabled 1
+
# system server cannot write to /proc/sys files,
# and chown/chmod does not work for /proc/sys/ entries.
# So proxy writes through init.