Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec73481e authored by Deyao Ren's avatar Deyao Ren Committed by Gerrit Code Review
Browse files

Merge "Add apex name to service"

parents ba1fbaf5 df40ed1b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -347,8 +347,8 @@ Parser CreateApexConfigParser(ActionManager& action_manager, ServiceList& servic
    }
#endif  // RECOVERY
    parser.AddSectionParser("service",
                            std::make_unique<ServiceParser>(&service_list, subcontext, std::nullopt,
                                                            /*from_apex=*/true));
                            std::make_unique<ServiceParser>(&service_list, subcontext,
                            std::nullopt));
    parser.AddSectionParser("on", std::make_unique<ActionParser>(&action_manager, subcontext));

    return parser;
+5 −5
Original line number Diff line number Diff line
@@ -130,13 +130,13 @@ bool Service::is_exec_service_running_ = false;
std::chrono::time_point<std::chrono::steady_clock> Service::exec_service_started_;

Service::Service(const std::string& name, Subcontext* subcontext_for_restart_commands,
                 const std::vector<std::string>& args, bool from_apex)
    : Service(name, 0, 0, 0, {}, 0, "", subcontext_for_restart_commands, args, from_apex) {}
                 const std::string& filename, const std::vector<std::string>& args)
    : Service(name, 0, 0, 0, {}, 0, "", subcontext_for_restart_commands, filename, args) {}

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, bool from_apex)
                 const std::string& filename, const std::vector<std::string>& args)
    : name_(name),
      classnames_({"default"}),
      flags_(flags),
@@ -156,7 +156,7 @@ Service::Service(const std::string& name, unsigned flags, uid_t uid, gid_t gid,
      oom_score_adjust_(DEFAULT_OOM_SCORE_ADJUST),
      start_order_(0),
      args_(args),
      from_apex_(from_apex) {}
      filename_(filename) {}

void Service::NotifyStateChange(const std::string& new_state) const {
    if ((flags_ & SVC_TEMPORARY) != 0) {
@@ -860,7 +860,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, false);
                                     nullptr, /*filename=*/"", str_args);
}

// This is used for snapuserd_proxy, which hands off a socket to snapuserd. It's
+5 −5
Original line number Diff line number Diff line
@@ -66,12 +66,12 @@ class Service {

  public:
    Service(const std::string& name, Subcontext* subcontext_for_restart_commands,
            const std::vector<std::string>& args, bool from_apex = false);
            const std::string& filename, const std::vector<std::string>& args);

    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,
            bool from_apex = false);
            Subcontext* subcontext_for_restart_commands, const std::string& filename,
            const std::vector<std::string>& args);

    static Result<std::unique_ptr<Service>> MakeTemporaryOneshotService(
            const std::vector<std::string>& args);
@@ -133,7 +133,7 @@ class Service {
    const std::vector<std::string>& args() const { return args_; }
    bool is_updatable() const { return updatable_; }
    bool is_post_data() const { return post_data_; }
    bool is_from_apex() const { return from_apex_; }
    bool is_from_apex() const { return base::StartsWith(filename_, "/apex/"); }
    void set_oneshot(bool value) {
        if (value) {
            flags_ |= SVC_ONESHOT;
@@ -225,7 +225,7 @@ class Service {

    std::optional<std::string> on_failure_reboot_target_;

    bool from_apex_ = false;
    std::string filename_;
};

}  // namespace init
+1 −1
Original line number Diff line number Diff line
@@ -647,7 +647,7 @@ Result<void> ServiceParser::ParseSection(std::vector<std::string>&& args,
        }
    }

    service_ = std::make_unique<Service>(name, restart_action_subcontext, str_args, from_apex_);
    service_ = std::make_unique<Service>(name, restart_action_subcontext, filename, str_args);
    return {};
}

+2 −5
Original line number Diff line number Diff line
@@ -31,13 +31,11 @@ class ServiceParser : public SectionParser {
  public:
    ServiceParser(
            ServiceList* service_list, Subcontext* subcontext,
            const std::optional<InterfaceInheritanceHierarchyMap>& interface_inheritance_hierarchy,
            bool from_apex = false)
            const std::optional<InterfaceInheritanceHierarchyMap>& interface_inheritance_hierarchy)
        : service_list_(service_list),
          subcontext_(subcontext),
          interface_inheritance_hierarchy_(interface_inheritance_hierarchy),
          service_(nullptr),
          from_apex_(from_apex) {}
          service_(nullptr) {}
    Result<void> ParseSection(std::vector<std::string>&& args, const std::string& filename,
                              int line) override;
    Result<void> ParseLineSection(std::vector<std::string>&& args, int line) override;
@@ -92,7 +90,6 @@ class ServiceParser : public SectionParser {
    std::optional<InterfaceInheritanceHierarchyMap> interface_inheritance_hierarchy_;
    std::unique_ptr<Service> service_;
    std::string filename_;
    bool from_apex_ = false;
};

}  // namespace init
Loading