Loading init/builtins.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1181,7 +1181,7 @@ static Result<void> do_parse_apex_configs(const BuiltinArguments& args) { return Error() << "glob pattern '" << glob_pattern << "' failed"; } std::vector<std::string> configs; Parser parser = CreateServiceOnlyParser(ServiceList::GetInstance()); Parser parser = CreateServiceOnlyParser(ServiceList::GetInstance(), true); for (size_t i = 0; i < glob_result.gl_pathc; i++) { std::string path = glob_result.gl_pathv[i]; // Filter-out /apex/<name>@<ver> paths. The paths are bind-mounted to Loading init/init.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -121,11 +121,12 @@ Parser CreateParser(ActionManager& action_manager, ServiceList& service_list) { } // parser that only accepts new services Parser CreateServiceOnlyParser(ServiceList& service_list) { Parser CreateServiceOnlyParser(ServiceList& service_list, bool from_apex) { Parser parser; parser.AddSectionParser("service", std::make_unique<ServiceParser>( &service_list, subcontext.get(), std::nullopt)); parser.AddSectionParser("service", std::make_unique<ServiceParser>(&service_list, subcontext.get(), std::nullopt, from_apex)); return parser; } Loading init/init.h +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ namespace android { namespace init { Parser CreateParser(ActionManager& action_manager, ServiceList& service_list); Parser CreateServiceOnlyParser(ServiceList& service_list); Parser CreateServiceOnlyParser(ServiceList& service_list, bool from_apex); bool start_waiting_for_property(const char *name, const char *value); Loading init/reboot.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -797,6 +797,14 @@ static Result<void> DoUserspaceReboot() { if (!SwitchToBootstrapMountNamespaceIfNeeded()) { return Error() << "Failed to switch to bootstrap namespace"; } // Remove services that were defined in an APEX. ServiceList::GetInstance().RemoveServiceIf([](const std::unique_ptr<Service>& s) -> bool { if (s->is_from_apex()) { LOG(INFO) << "Removing service '" << s->name() << "' because it's defined in an APEX"; return true; } return false; }); // Re-enable services for (const auto& s : were_enabled) { LOG(INFO) << "Re-enabling service '" << s->name() << "'"; Loading init/service.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -131,13 +131,13 @@ unsigned long Service::next_start_order_ = 1; bool Service::is_exec_service_running_ = false; Service::Service(const std::string& name, Subcontext* subcontext_for_restart_commands, const std::vector<std::string>& args) : Service(name, 0, 0, 0, {}, 0, "", subcontext_for_restart_commands, args) {} const std::vector<std::string>& args, bool from_apex) : Service(name, 0, 0, 0, {}, 0, "", subcontext_for_restart_commands, args, from_apex) {} Service::Service(const std::string& name, unsigned flags, uid_t uid, gid_t gid, const std::vector<gid_t>& supp_gids, int namespace_flags, const std::string& seclabel, Subcontext* subcontext_for_restart_commands, const std::vector<std::string>& args) const std::vector<std::string>& args, bool from_apex) : name_(name), classnames_({"default"}), flags_(flags), Loading @@ -155,7 +155,8 @@ Service::Service(const std::string& name, unsigned flags, uid_t uid, gid_t gid, "onrestart", {}), oom_score_adjust_(DEFAULT_OOM_SCORE_ADJUST), start_order_(0), args_(args) {} args_(args), from_apex_(from_apex) {} void Service::NotifyStateChange(const std::string& new_state) const { if ((flags_ & SVC_TEMPORARY) != 0) { Loading Loading @@ -763,7 +764,7 @@ Result<std::unique_ptr<Service>> Service::MakeTemporaryOneshotService( } return std::make_unique<Service>(name, flags, *uid, *gid, supp_gids, namespace_flags, seclabel, nullptr, str_args); nullptr, str_args, false); } } // namespace init Loading Loading
init/builtins.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1181,7 +1181,7 @@ static Result<void> do_parse_apex_configs(const BuiltinArguments& args) { return Error() << "glob pattern '" << glob_pattern << "' failed"; } std::vector<std::string> configs; Parser parser = CreateServiceOnlyParser(ServiceList::GetInstance()); Parser parser = CreateServiceOnlyParser(ServiceList::GetInstance(), true); for (size_t i = 0; i < glob_result.gl_pathc; i++) { std::string path = glob_result.gl_pathv[i]; // Filter-out /apex/<name>@<ver> paths. The paths are bind-mounted to Loading
init/init.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -121,11 +121,12 @@ Parser CreateParser(ActionManager& action_manager, ServiceList& service_list) { } // parser that only accepts new services Parser CreateServiceOnlyParser(ServiceList& service_list) { Parser CreateServiceOnlyParser(ServiceList& service_list, bool from_apex) { Parser parser; parser.AddSectionParser("service", std::make_unique<ServiceParser>( &service_list, subcontext.get(), std::nullopt)); parser.AddSectionParser("service", std::make_unique<ServiceParser>(&service_list, subcontext.get(), std::nullopt, from_apex)); return parser; } Loading
init/init.h +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ namespace android { namespace init { Parser CreateParser(ActionManager& action_manager, ServiceList& service_list); Parser CreateServiceOnlyParser(ServiceList& service_list); Parser CreateServiceOnlyParser(ServiceList& service_list, bool from_apex); bool start_waiting_for_property(const char *name, const char *value); Loading
init/reboot.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -797,6 +797,14 @@ static Result<void> DoUserspaceReboot() { if (!SwitchToBootstrapMountNamespaceIfNeeded()) { return Error() << "Failed to switch to bootstrap namespace"; } // Remove services that were defined in an APEX. ServiceList::GetInstance().RemoveServiceIf([](const std::unique_ptr<Service>& s) -> bool { if (s->is_from_apex()) { LOG(INFO) << "Removing service '" << s->name() << "' because it's defined in an APEX"; return true; } return false; }); // Re-enable services for (const auto& s : were_enabled) { LOG(INFO) << "Re-enabling service '" << s->name() << "'"; Loading
init/service.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -131,13 +131,13 @@ unsigned long Service::next_start_order_ = 1; bool Service::is_exec_service_running_ = false; Service::Service(const std::string& name, Subcontext* subcontext_for_restart_commands, const std::vector<std::string>& args) : Service(name, 0, 0, 0, {}, 0, "", subcontext_for_restart_commands, args) {} const std::vector<std::string>& args, bool from_apex) : Service(name, 0, 0, 0, {}, 0, "", subcontext_for_restart_commands, args, from_apex) {} Service::Service(const std::string& name, unsigned flags, uid_t uid, gid_t gid, const std::vector<gid_t>& supp_gids, int namespace_flags, const std::string& seclabel, Subcontext* subcontext_for_restart_commands, const std::vector<std::string>& args) const std::vector<std::string>& args, bool from_apex) : name_(name), classnames_({"default"}), flags_(flags), Loading @@ -155,7 +155,8 @@ Service::Service(const std::string& name, unsigned flags, uid_t uid, gid_t gid, "onrestart", {}), oom_score_adjust_(DEFAULT_OOM_SCORE_ADJUST), start_order_(0), args_(args) {} args_(args), from_apex_(from_apex) {} void Service::NotifyStateChange(const std::string& new_state) const { if ((flags_ & SVC_TEMPORARY) != 0) { Loading Loading @@ -763,7 +764,7 @@ Result<std::unique_ptr<Service>> Service::MakeTemporaryOneshotService( } return std::make_unique<Service>(name, flags, *uid, *gid, supp_gids, namespace_flags, seclabel, nullptr, str_args); nullptr, str_args, false); } } // namespace init Loading