diff --git a/bionic/0001-Add-new-mechanism-to-fake-vendor-props-on-a-per-proc.patch b/bionic/0001-Add-new-mechanism-to-fake-vendor-props-on-a-per-proc.patch new file mode 100644 index 0000000..a756b22 --- /dev/null +++ b/bionic/0001-Add-new-mechanism-to-fake-vendor-props-on-a-per-proc.patch @@ -0,0 +1,136 @@ +From ea0f283eec1e7750351302dbc2009fa905cef375 Mon Sep 17 00:00:00 2001 +From: Pierre-Hugues Husson +Date: Sat, 19 Feb 2022 08:20:25 -0500 +Subject: [PATCH] Add new mechanism to fake vendor props on a per-process basis + +This reads debug.phh.props.. If its value is "vendor", +then ro.product.device/ro.product.manufacturer is read from vendor + +Squashed: Rework property overriding + +- Support property read with callback in addition to previous + constant-size property_get +- Add another class of redirect "keymaster", to redirect to AOSP/GSI + props + SPL based on boot.img +--- + libc/system_properties/system_properties.cpp | 81 +++++++++++++++++++- + 1 file changed, 79 insertions(+), 2 deletions(-) + +diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp +index 1cb15c3df..40ff48bad 100644 +--- a/libc/system_properties/system_properties.cpp ++++ b/libc/system_properties/system_properties.cpp +@@ -35,6 +35,8 @@ + #include + #include + #include ++#include ++#include + + #include + +@@ -50,6 +52,79 @@ + #define SERIAL_DIRTY(serial) ((serial)&1) + #define SERIAL_VALUE_LEN(serial) ((serial) >> 24) + ++static char comm[128]; ++static bool self_ok = false; ++static char comm_override[PROP_VALUE_MAX]; ++ ++static void read_self() { ++ //NB: Not atomic, but should be good enough, there is no possible corruption from concurrency ++ if(self_ok) return; ++ self_ok = true; ++ ++ char cmdline[128]; ++ int fd = open("/proc/self/cmdline", O_RDONLY); ++ if(fd<0) return; ++ read(fd, cmdline, sizeof(cmdline)-1); ++ for(unsigned i=0; iGetPropAreaForName(name); ++ prop_area* pa = contexts_->GetPropAreaForName(newName); + if (!pa) { + async_safe_format_log(ANDROID_LOG_WARN, "libc", "Access denied finding property \"%s\"", name); + return nullptr; + } + +- return pa->find(name); ++ return pa->find(newName); + } + + static bool is_read_only(const char* name) { +-- +2.40.0 +