Loading init/Android.bp +2 −4 Original line number Diff line number Diff line Loading @@ -88,7 +88,6 @@ init_device_sources = [ init_host_sources = [ "check_builtins.cpp", "host_import_parser.cpp", "host_init_verifier.cpp", ] soong_config_module_type { Loading Loading @@ -321,7 +320,6 @@ cc_binary { visibility: ["//packages/modules/Virtualization/microdroid"], } soong_config_module_type { name: "init_first_stage_cc_defaults", module_type: "cc_defaults", Loading Loading @@ -614,13 +612,13 @@ cc_defaults { cc_binary { name: "host_init_verifier", defaults: ["init_host_defaults"], srcs: init_common_sources + init_host_sources, srcs: ["host_init_verifier.cpp"] + init_common_sources + init_host_sources, } cc_library_host_static { name: "libinit_host", defaults: ["init_host_defaults"], srcs: init_common_sources, srcs: init_common_sources + init_host_sources, export_include_dirs: ["."], proto: { export_proto_headers: true, Loading init/check_builtins.cpp +24 −1 Original line number Diff line number Diff line Loading @@ -28,9 +28,9 @@ #include <android-base/parsedouble.h> #include <android-base/parseint.h> #include <android-base/strings.h> #include <property_info_parser/property_info_parser.h> #include "builtin_arguments.h" #include "host_init_verifier.h" #include "interface_utils.h" #include "property_type.h" #include "rlimit_parser.h" Loading @@ -39,6 +39,9 @@ using android::base::ParseInt; using android::base::StartsWith; using android::properties::BuildTrie; using android::properties::PropertyInfoArea; using android::properties::PropertyInfoEntry; #define ReturnIfAnyArgsEmpty() \ for (const auto& arg : args) { \ Loading @@ -50,6 +53,26 @@ using android::base::StartsWith; namespace android { namespace init { const PropertyInfoArea* property_info_area; Result<void> InitializeHostPropertyInfoArea(const std::vector<PropertyInfoEntry>& property_infos) { static std::string serialized_contexts; std::string trie_error; if (!BuildTrie(property_infos, "u:object_r:default_prop:s0", "string", &serialized_contexts, &trie_error)) { return Error() << "Unable to serialize property contexts: " << trie_error; } property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_contexts.c_str()); return {}; } static Result<void> check_stub(const BuiltinArguments& args) { return {}; } #include "generated_stub_builtin_function_map.h" Result<void> check_chown(const BuiltinArguments& args) { if (!args[1].empty()) { auto uid = DecodeUid(args[1]); Loading init/check_builtins.h +7 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ #include "builtin_arguments.h" #include "result.h" #include <vector> #include <property_info_serializer/property_info_serializer.h> namespace android { namespace init { Loading @@ -43,5 +47,8 @@ Result<void> check_umount_all(const BuiltinArguments& args); Result<void> check_wait(const BuiltinArguments& args); Result<void> check_wait_for_prop(const BuiltinArguments& args); Result<void> InitializeHostPropertyInfoArea( const std::vector<properties::PropertyInfoEntry>& property_infos); } // namespace init } // namespace android init/host_init_verifier.cpp +3 −19 Original line number Diff line number Diff line Loading @@ -14,8 +14,6 @@ // limitations under the License. // #include "host_init_verifier.h" #include <errno.h> #include <getopt.h> #include <pwd.h> Loading @@ -36,6 +34,7 @@ #include <android-base/strings.h> #include <generated_android_ids.h> #include <hidl/metadata.h> #include <property_info_parser/property_info_parser.h> #include <property_info_serializer/property_info_serializer.h> #include "action.h" Loading @@ -57,9 +56,7 @@ using android::base::EndsWith; using android::base::ParseInt; using android::base::ReadFileToString; using android::base::Split; using android::properties::BuildTrie; using android::properties::ParsePropertyInfoFile; using android::properties::PropertyInfoArea; using android::properties::PropertyInfoEntry; static std::vector<std::string> passwd_files; Loading Loading @@ -148,12 +145,6 @@ passwd* getpwnam(const char* login) { // NOLINT: implementing bad function. namespace android { namespace init { static Result<void> check_stub(const BuiltinArguments& args) { return {}; } #include "generated_stub_builtin_function_map.h" void PrintUsage() { fprintf(stdout, R"(usage: host_init_verifier [options] Loading Loading @@ -196,8 +187,6 @@ Result<InterfaceInheritanceHierarchyMap> ReadInterfaceInheritanceHierarchy() { return result; } const PropertyInfoArea* property_info_area; void HandlePropertyContexts(const std::string& filename, std::vector<PropertyInfoEntry>* property_infos) { auto file_contents = std::string(); Loading Loading @@ -288,16 +277,11 @@ int main(int argc, char** argv) { } SetKnownInterfaces(*interface_inheritance_hierarchy_map); std::string serialized_contexts; std::string trie_error; if (!BuildTrie(property_infos, "u:object_r:default_prop:s0", "string", &serialized_contexts, &trie_error)) { LOG(ERROR) << "Unable to serialize property contexts: " << trie_error; if (auto result = InitializeHostPropertyInfoArea(property_infos); !result.ok()) { LOG(ERROR) << result.error(); return EXIT_FAILURE; } property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_contexts.c_str()); if (!partition_map.empty()) { std::vector<std::string> vendor_prefixes; for (const auto& partition : {"vendor", "odm"}) { Loading init/host_init_verifier.hdeleted 100644 → 0 +0 −27 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <property_info_parser/property_info_parser.h> namespace android { namespace init { extern const android::properties::PropertyInfoArea* property_info_area; } // namespace init } // namespace android Loading
init/Android.bp +2 −4 Original line number Diff line number Diff line Loading @@ -88,7 +88,6 @@ init_device_sources = [ init_host_sources = [ "check_builtins.cpp", "host_import_parser.cpp", "host_init_verifier.cpp", ] soong_config_module_type { Loading Loading @@ -321,7 +320,6 @@ cc_binary { visibility: ["//packages/modules/Virtualization/microdroid"], } soong_config_module_type { name: "init_first_stage_cc_defaults", module_type: "cc_defaults", Loading Loading @@ -614,13 +612,13 @@ cc_defaults { cc_binary { name: "host_init_verifier", defaults: ["init_host_defaults"], srcs: init_common_sources + init_host_sources, srcs: ["host_init_verifier.cpp"] + init_common_sources + init_host_sources, } cc_library_host_static { name: "libinit_host", defaults: ["init_host_defaults"], srcs: init_common_sources, srcs: init_common_sources + init_host_sources, export_include_dirs: ["."], proto: { export_proto_headers: true, Loading
init/check_builtins.cpp +24 −1 Original line number Diff line number Diff line Loading @@ -28,9 +28,9 @@ #include <android-base/parsedouble.h> #include <android-base/parseint.h> #include <android-base/strings.h> #include <property_info_parser/property_info_parser.h> #include "builtin_arguments.h" #include "host_init_verifier.h" #include "interface_utils.h" #include "property_type.h" #include "rlimit_parser.h" Loading @@ -39,6 +39,9 @@ using android::base::ParseInt; using android::base::StartsWith; using android::properties::BuildTrie; using android::properties::PropertyInfoArea; using android::properties::PropertyInfoEntry; #define ReturnIfAnyArgsEmpty() \ for (const auto& arg : args) { \ Loading @@ -50,6 +53,26 @@ using android::base::StartsWith; namespace android { namespace init { const PropertyInfoArea* property_info_area; Result<void> InitializeHostPropertyInfoArea(const std::vector<PropertyInfoEntry>& property_infos) { static std::string serialized_contexts; std::string trie_error; if (!BuildTrie(property_infos, "u:object_r:default_prop:s0", "string", &serialized_contexts, &trie_error)) { return Error() << "Unable to serialize property contexts: " << trie_error; } property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_contexts.c_str()); return {}; } static Result<void> check_stub(const BuiltinArguments& args) { return {}; } #include "generated_stub_builtin_function_map.h" Result<void> check_chown(const BuiltinArguments& args) { if (!args[1].empty()) { auto uid = DecodeUid(args[1]); Loading
init/check_builtins.h +7 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ #include "builtin_arguments.h" #include "result.h" #include <vector> #include <property_info_serializer/property_info_serializer.h> namespace android { namespace init { Loading @@ -43,5 +47,8 @@ Result<void> check_umount_all(const BuiltinArguments& args); Result<void> check_wait(const BuiltinArguments& args); Result<void> check_wait_for_prop(const BuiltinArguments& args); Result<void> InitializeHostPropertyInfoArea( const std::vector<properties::PropertyInfoEntry>& property_infos); } // namespace init } // namespace android
init/host_init_verifier.cpp +3 −19 Original line number Diff line number Diff line Loading @@ -14,8 +14,6 @@ // limitations under the License. // #include "host_init_verifier.h" #include <errno.h> #include <getopt.h> #include <pwd.h> Loading @@ -36,6 +34,7 @@ #include <android-base/strings.h> #include <generated_android_ids.h> #include <hidl/metadata.h> #include <property_info_parser/property_info_parser.h> #include <property_info_serializer/property_info_serializer.h> #include "action.h" Loading @@ -57,9 +56,7 @@ using android::base::EndsWith; using android::base::ParseInt; using android::base::ReadFileToString; using android::base::Split; using android::properties::BuildTrie; using android::properties::ParsePropertyInfoFile; using android::properties::PropertyInfoArea; using android::properties::PropertyInfoEntry; static std::vector<std::string> passwd_files; Loading Loading @@ -148,12 +145,6 @@ passwd* getpwnam(const char* login) { // NOLINT: implementing bad function. namespace android { namespace init { static Result<void> check_stub(const BuiltinArguments& args) { return {}; } #include "generated_stub_builtin_function_map.h" void PrintUsage() { fprintf(stdout, R"(usage: host_init_verifier [options] Loading Loading @@ -196,8 +187,6 @@ Result<InterfaceInheritanceHierarchyMap> ReadInterfaceInheritanceHierarchy() { return result; } const PropertyInfoArea* property_info_area; void HandlePropertyContexts(const std::string& filename, std::vector<PropertyInfoEntry>* property_infos) { auto file_contents = std::string(); Loading Loading @@ -288,16 +277,11 @@ int main(int argc, char** argv) { } SetKnownInterfaces(*interface_inheritance_hierarchy_map); std::string serialized_contexts; std::string trie_error; if (!BuildTrie(property_infos, "u:object_r:default_prop:s0", "string", &serialized_contexts, &trie_error)) { LOG(ERROR) << "Unable to serialize property contexts: " << trie_error; if (auto result = InitializeHostPropertyInfoArea(property_infos); !result.ok()) { LOG(ERROR) << result.error(); return EXIT_FAILURE; } property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_contexts.c_str()); if (!partition_map.empty()) { std::vector<std::string> vendor_prefixes; for (const auto& partition : {"vendor", "odm"}) { Loading
init/host_init_verifier.hdeleted 100644 → 0 +0 −27 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <property_info_parser/property_info_parser.h> namespace android { namespace init { extern const android::properties::PropertyInfoArea* property_info_area; } // namespace init } // namespace android