Loading init/property_service.cpp +8 −30 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ #include "init.h" #include "persistent_properties.h" #include "space_tokenizer.h" #include "util.h" using android::base::ReadFileToString; Loading @@ -69,6 +68,7 @@ using android::base::Timer; using android::base::Trim; using android::base::WriteStringToFile; using android::properties::BuildTrie; using android::properties::ParsePropertyInfoFile; using android::properties::PropertyInfoAreaFile; using android::properties::PropertyInfoEntry; Loading Loading @@ -728,22 +728,6 @@ static int SelinuxAuditCallback(void* data, security_class_t /*cls*/, char* buf, return 0; } Result<PropertyInfoEntry> ParsePropertyInfoLine(const std::string& line) { auto tokenizer = SpaceTokenizer(line); auto property = tokenizer.GetNext(); if (property.empty()) return Error() << "Did not find a property entry in '" << line << "'"; auto context = tokenizer.GetNext(); if (context.empty()) return Error() << "Did not find a context entry in '" << line << "'"; // It is not an error to not find these, as older files will not contain them. auto exact_match = tokenizer.GetNext(); auto schema = tokenizer.GetRemaining(); return {property, context, schema, exact_match == "exact"}; } bool LoadPropertyInfoFromFile(const std::string& filename, std::vector<PropertyInfoEntry>* property_infos) { auto file_contents = std::string(); Loading @@ -752,20 +736,14 @@ bool LoadPropertyInfoFromFile(const std::string& filename, return false; } for (const auto& line : Split(file_contents, "\n")) { auto trimmed_line = Trim(line); if (trimmed_line.empty() || StartsWith(trimmed_line, "#")) { continue; auto errors = std::vector<std::string>{}; ParsePropertyInfoFile(file_contents, property_infos, &errors); // Individual parsing errors are reported but do not cause a failed boot, which is what // returning false would do here. for (const auto& error : errors) { LOG(ERROR) << "Could not read line from '" << filename << "': " << error; } auto property_info = ParsePropertyInfoLine(line); if (!property_info) { LOG(ERROR) << "Could not read line from '" << filename << "': " << property_info.error(); continue; } property_infos->emplace_back(*property_info); } return true; } Loading property_service/libpropertyinfoparser/Android.bp +1 −0 Original line number Diff line number Diff line cc_library_static { name: "libpropertyinfoparser", host_supported: true, srcs: ["property_info_parser.cpp"], cpp_std: "experimental", Loading property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define PROPERTY_INFO_PARSER_H #include <stdint.h> #include <stdlib.h> namespace android { namespace properties { Loading property_service/libpropertyinfoserializer/Android.bp +2 −0 Original line number Diff line number Diff line cc_defaults { name: "propertyinfoserializer_defaults", host_supported: true, cpp_std: "experimental", sanitize: { misc_undefined: ["signed-integer-overflow"], Loading @@ -19,6 +20,7 @@ cc_library_static { name: "libpropertyinfoserializer", defaults: ["propertyinfoserializer_defaults"], srcs: [ "property_info_file.cpp", "property_info_serializer.cpp", "trie_builder.cpp", "trie_serializer.cpp", Loading property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info, const std::string& default_context, const std::string& default_schema, std::string* serialized_trie, std::string* error); void ParsePropertyInfoFile(const std::string& file_contents, std::vector<PropertyInfoEntry>* property_infos, std::vector<std::string>* errors); } // namespace properties } // namespace android Loading Loading
init/property_service.cpp +8 −30 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ #include "init.h" #include "persistent_properties.h" #include "space_tokenizer.h" #include "util.h" using android::base::ReadFileToString; Loading @@ -69,6 +68,7 @@ using android::base::Timer; using android::base::Trim; using android::base::WriteStringToFile; using android::properties::BuildTrie; using android::properties::ParsePropertyInfoFile; using android::properties::PropertyInfoAreaFile; using android::properties::PropertyInfoEntry; Loading Loading @@ -728,22 +728,6 @@ static int SelinuxAuditCallback(void* data, security_class_t /*cls*/, char* buf, return 0; } Result<PropertyInfoEntry> ParsePropertyInfoLine(const std::string& line) { auto tokenizer = SpaceTokenizer(line); auto property = tokenizer.GetNext(); if (property.empty()) return Error() << "Did not find a property entry in '" << line << "'"; auto context = tokenizer.GetNext(); if (context.empty()) return Error() << "Did not find a context entry in '" << line << "'"; // It is not an error to not find these, as older files will not contain them. auto exact_match = tokenizer.GetNext(); auto schema = tokenizer.GetRemaining(); return {property, context, schema, exact_match == "exact"}; } bool LoadPropertyInfoFromFile(const std::string& filename, std::vector<PropertyInfoEntry>* property_infos) { auto file_contents = std::string(); Loading @@ -752,20 +736,14 @@ bool LoadPropertyInfoFromFile(const std::string& filename, return false; } for (const auto& line : Split(file_contents, "\n")) { auto trimmed_line = Trim(line); if (trimmed_line.empty() || StartsWith(trimmed_line, "#")) { continue; auto errors = std::vector<std::string>{}; ParsePropertyInfoFile(file_contents, property_infos, &errors); // Individual parsing errors are reported but do not cause a failed boot, which is what // returning false would do here. for (const auto& error : errors) { LOG(ERROR) << "Could not read line from '" << filename << "': " << error; } auto property_info = ParsePropertyInfoLine(line); if (!property_info) { LOG(ERROR) << "Could not read line from '" << filename << "': " << property_info.error(); continue; } property_infos->emplace_back(*property_info); } return true; } Loading
property_service/libpropertyinfoparser/Android.bp +1 −0 Original line number Diff line number Diff line cc_library_static { name: "libpropertyinfoparser", host_supported: true, srcs: ["property_info_parser.cpp"], cpp_std: "experimental", Loading
property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define PROPERTY_INFO_PARSER_H #include <stdint.h> #include <stdlib.h> namespace android { namespace properties { Loading
property_service/libpropertyinfoserializer/Android.bp +2 −0 Original line number Diff line number Diff line cc_defaults { name: "propertyinfoserializer_defaults", host_supported: true, cpp_std: "experimental", sanitize: { misc_undefined: ["signed-integer-overflow"], Loading @@ -19,6 +20,7 @@ cc_library_static { name: "libpropertyinfoserializer", defaults: ["propertyinfoserializer_defaults"], srcs: [ "property_info_file.cpp", "property_info_serializer.cpp", "trie_builder.cpp", "trie_serializer.cpp", Loading
property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info, const std::string& default_context, const std::string& default_schema, std::string* serialized_trie, std::string* error); void ParsePropertyInfoFile(const std::string& file_contents, std::vector<PropertyInfoEntry>* property_infos, std::vector<std::string>* errors); } // namespace properties } // namespace android Loading