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
This commit is contained in:
Tom Cherry 2019-08-12 09:26:20 -07:00
parent 4b8e6b673f
commit 6fd8d3bb1b
1 changed files with 4 additions and 3 deletions

View File

@ -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;