Loading init/action_parser.cpp +6 −10 Original line number Diff line number Diff line Loading @@ -19,7 +19,11 @@ #include <android-base/properties.h> #include <android-base/strings.h> #include "stable_properties.h" #if defined(__ANDROID__) #include "property_service.h" #else #include "host_init_stubs.h" #endif using android::base::GetBoolProperty; using android::base::StartsWith; Loading @@ -36,15 +40,7 @@ bool IsActionableProperty(Subcontext* subcontext, const std::string& prop_name) return true; } if (kExportedActionableProperties.count(prop_name) == 1) { return true; } for (const auto& prefix : kPartnerPrefixes) { if (android::base::StartsWith(prop_name, prefix)) { return true; } } return false; return CanReadProperty(subcontext->context(), prop_name); } Result<Success> ParsePropertyTrigger(const std::string& trigger, Subcontext* subcontext, Loading init/host_init_stubs.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ namespace init { std::string default_console = "/dev/console"; // property_service.h bool CanReadProperty(const std::string& source_context, const std::string& name) { return true; } uint32_t SetProperty(const std::string& key, const std::string& value) { android::base::SetProperty(key, value); return 0; Loading init/host_init_stubs.h +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ namespace init { extern std::string default_console; // property_service.h bool CanReadProperty(const std::string& source_context, const std::string& name); extern uint32_t (*property_set)(const std::string& name, const std::string& value); uint32_t HandlePropertySet(const std::string& name, const std::string& value, const std::string& source_context, const ucred& cr, std::string* error); Loading init/property_service.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,22 @@ void property_init() { LOG(FATAL) << "Failed to load serialized property info file"; } } bool CanReadProperty(const std::string& source_context, const std::string& name) { const char* target_context = nullptr; property_info_area->GetPropertyInfo(name.c_str(), &target_context, nullptr); PropertyAuditData audit_data; audit_data.name = name.c_str(); ucred cr = {.pid = 0, .uid = 0, .gid = 0}; audit_data.cr = &cr; return selinux_check_access(source_context.c_str(), target_context, "file", "read", &audit_data) == 0; } static bool CheckMacPerms(const std::string& name, const char* target_context, const char* source_context, const ucred& cr) { if (!target_context || !source_context) { Loading init/property_service.h +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ namespace android { namespace init { bool CanReadProperty(const std::string& source_context, const std::string& name); extern uint32_t (*property_set)(const std::string& name, const std::string& value); uint32_t HandlePropertySet(const std::string& name, const std::string& value, Loading Loading
init/action_parser.cpp +6 −10 Original line number Diff line number Diff line Loading @@ -19,7 +19,11 @@ #include <android-base/properties.h> #include <android-base/strings.h> #include "stable_properties.h" #if defined(__ANDROID__) #include "property_service.h" #else #include "host_init_stubs.h" #endif using android::base::GetBoolProperty; using android::base::StartsWith; Loading @@ -36,15 +40,7 @@ bool IsActionableProperty(Subcontext* subcontext, const std::string& prop_name) return true; } if (kExportedActionableProperties.count(prop_name) == 1) { return true; } for (const auto& prefix : kPartnerPrefixes) { if (android::base::StartsWith(prop_name, prefix)) { return true; } } return false; return CanReadProperty(subcontext->context(), prop_name); } Result<Success> ParsePropertyTrigger(const std::string& trigger, Subcontext* subcontext, Loading
init/host_init_stubs.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,9 @@ namespace init { std::string default_console = "/dev/console"; // property_service.h bool CanReadProperty(const std::string& source_context, const std::string& name) { return true; } uint32_t SetProperty(const std::string& key, const std::string& value) { android::base::SetProperty(key, value); return 0; Loading
init/host_init_stubs.h +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ namespace init { extern std::string default_console; // property_service.h bool CanReadProperty(const std::string& source_context, const std::string& name); extern uint32_t (*property_set)(const std::string& name, const std::string& value); uint32_t HandlePropertySet(const std::string& name, const std::string& value, const std::string& source_context, const ucred& cr, std::string* error); Loading
init/property_service.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,22 @@ void property_init() { LOG(FATAL) << "Failed to load serialized property info file"; } } bool CanReadProperty(const std::string& source_context, const std::string& name) { const char* target_context = nullptr; property_info_area->GetPropertyInfo(name.c_str(), &target_context, nullptr); PropertyAuditData audit_data; audit_data.name = name.c_str(); ucred cr = {.pid = 0, .uid = 0, .gid = 0}; audit_data.cr = &cr; return selinux_check_access(source_context.c_str(), target_context, "file", "read", &audit_data) == 0; } static bool CheckMacPerms(const std::string& name, const char* target_context, const char* source_context, const ucred& cr) { if (!target_context || !source_context) { Loading
init/property_service.h +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ namespace android { namespace init { bool CanReadProperty(const std::string& source_context, const std::string& name); extern uint32_t (*property_set)(const std::string& name, const std::string& value); uint32_t HandlePropertySet(const std::string& name, const std::string& value, Loading