2019-06-26 19:46:20 +02:00
|
|
|
/*
|
|
|
|
* 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 <vector>
|
|
|
|
|
2019-08-03 00:13:50 +02:00
|
|
|
#include "interface_utils.h"
|
2019-06-26 19:46:20 +02:00
|
|
|
#include "parser.h"
|
|
|
|
#include "service.h"
|
|
|
|
#include "service_list.h"
|
|
|
|
#include "subcontext.h"
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace init {
|
|
|
|
|
|
|
|
class ServiceParser : public SectionParser {
|
|
|
|
public:
|
2019-07-09 20:00:53 +02:00
|
|
|
ServiceParser(
|
2019-09-18 22:47:19 +02:00
|
|
|
ServiceList* service_list, Subcontext* subcontext,
|
2022-07-15 00:51:10 +02:00
|
|
|
const std::optional<InterfaceInheritanceHierarchyMap>& interface_inheritance_hierarchy)
|
2019-06-27 21:18:08 +02:00
|
|
|
: service_list_(service_list),
|
2019-09-18 22:47:19 +02:00
|
|
|
subcontext_(subcontext),
|
2019-07-09 20:00:53 +02:00
|
|
|
interface_inheritance_hierarchy_(interface_inheritance_hierarchy),
|
2022-07-15 00:51:10 +02:00
|
|
|
service_(nullptr) {}
|
2019-06-26 19:46:20 +02:00
|
|
|
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;
|
|
|
|
Result<void> EndSection() override;
|
|
|
|
void EndFile() override { filename_ = ""; }
|
|
|
|
|
|
|
|
private:
|
2019-06-26 20:22:52 +02:00
|
|
|
using OptionParser = Result<void> (ServiceParser::*)(std::vector<std::string>&& args);
|
2019-07-23 01:05:36 +02:00
|
|
|
const KeywordMap<ServiceParser::OptionParser>& GetParserMap() const;
|
2019-06-26 20:22:52 +02:00
|
|
|
|
|
|
|
Result<void> ParseCapabilities(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseClass(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseConsole(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseCritical(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseDisabled(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseEnterNamespace(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseGroup(std::vector<std::string>&& args);
|
2022-12-02 00:44:31 +01:00
|
|
|
Result<void> ParseGentleKill(std::vector<std::string>&& args);
|
2019-06-26 20:22:52 +02:00
|
|
|
Result<void> ParsePriority(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseInterface(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseIoprio(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseKeycodes(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseOneshot(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseOnrestart(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseOomScoreAdjust(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseOverride(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseMemcgLimitInBytes(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseMemcgLimitPercent(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseMemcgLimitProperty(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseMemcgSoftLimitInBytes(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseMemcgSwappiness(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseNamespace(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseProcessRlimit(std::vector<std::string>&& args);
|
2019-09-10 19:40:47 +02:00
|
|
|
Result<void> ParseRebootOnFailure(std::vector<std::string>&& args);
|
2019-06-26 20:22:52 +02:00
|
|
|
Result<void> ParseRestartPeriod(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseSeclabel(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseSetenv(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseShutdown(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseSigstop(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseSocket(std::vector<std::string>&& args);
|
2019-09-24 01:16:54 +02:00
|
|
|
Result<void> ParseStdioToKmsg(std::vector<std::string>&& args);
|
2020-04-30 20:58:39 +02:00
|
|
|
Result<void> ParseTaskProfiles(std::vector<std::string>&& args);
|
2019-06-26 20:22:52 +02:00
|
|
|
Result<void> ParseTimeoutPeriod(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseFile(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseUser(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseWritepid(std::vector<std::string>&& args);
|
|
|
|
Result<void> ParseUpdatable(std::vector<std::string>&& args);
|
|
|
|
|
2019-06-26 19:46:20 +02:00
|
|
|
bool IsValidName(const std::string& name) const;
|
|
|
|
|
|
|
|
ServiceList* service_list_;
|
2019-09-18 22:47:19 +02:00
|
|
|
Subcontext* subcontext_;
|
2019-07-09 20:00:53 +02:00
|
|
|
std::optional<InterfaceInheritanceHierarchyMap> interface_inheritance_hierarchy_;
|
2019-06-26 19:46:20 +02:00
|
|
|
std::unique_ptr<Service> service_;
|
|
|
|
std::string filename_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace init
|
|
|
|
} // namespace android
|