From 6fd8d3bb1b9e29da5d4840bdb94fdf262fad1f3a Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Mon, 12 Aug 2019 09:26:20 -0700 Subject: [PATCH] init: Allow matching empty property values When we have a property match along with an event trigger, we currently don't allow matching empty property values, in other words, properties that are unset. For example, the below trigger would never be run: on zygote-start && property:persist.sys.fuse="" That doesn't make sense though, it should be possible to match an empty property value, so this change allows that trigger to match when persist.sys.fuse is either empty or not set. This continues to not match a '*' to an empty property, so on zygote-start && property:persist.sys.fuse=* will not run if persist.sys.fuse is empty or unset. Test: the above triggers run appropriately Change-Id: Ia57de7b96ad352590d0c82ff4ae95060b7361976 --- init/action.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/init/action.cpp b/init/action.cpp index 1a66eee4a..69e40d07f 100644 --- a/init/action.cpp +++ b/init/action.cpp @@ -195,10 +195,11 @@ bool Action::CheckPropertyTriggers(const std::string& name, found = true; } } else { - std::string prop_val = android::base::GetProperty(trigger_name, ""); - if (prop_val.empty() || (trigger_value != "*" && trigger_value != prop_val)) { - return false; + std::string prop_value = android::base::GetProperty(trigger_name, ""); + if (trigger_value == "*" && !prop_value.empty()) { + continue; } + if (trigger_value != prop_value) return false; } } return found;