blob: befce253a1551357c74e1ca64a35b32b041fcffb [file] [log] [blame]
Vic Yange01ca4d2019-05-29 15:58:32 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <sys/resource.h>
20#include <sys/types.h>
21
22#include <string>
23#include <vector>
24
25#include <cutils/iosched_policy.h>
26
27#include "result.h"
28
29namespace android {
30namespace init {
31
Tom Cherry2e4c85f2019-07-09 13:33:36 -070032struct SocketDescriptor {
33 std::string name;
34 int type = 0;
35 uid_t uid = 0;
36 gid_t gid = 0;
37 int perm = 0;
38 std::string context;
39 bool passcred = false;
40
41 Result<void> CreateAndPublish(const std::string& global_context) const;
42};
43
44struct FileDescriptor {
45 std::string name;
46 std::string type;
47
48 Result<void> CreateAndPublish() const;
49};
50
Vic Yange01ca4d2019-05-29 15:58:32 -070051struct NamespaceInfo {
Tom Cherry247ffbf2019-07-08 15:09:36 -070052 int flags;
Vic Yange01ca4d2019-05-29 15:58:32 -070053 // Pair of namespace type, path to name.
54 std::vector<std::pair<int, std::string>> namespaces_to_enter;
55};
Tom Cherrybbcbc2f2019-06-10 11:08:01 -070056Result<void> EnterNamespaces(const NamespaceInfo& info, const std::string& name, bool pre_apexd);
Vic Yange01ca4d2019-05-29 15:58:32 -070057
58struct ProcessAttributes {
59 std::string console;
60 IoSchedClass ioprio_class;
61 int ioprio_pri;
62 std::vector<std::pair<int, rlimit>> rlimits;
63 uid_t uid;
64 gid_t gid;
65 std::vector<gid_t> supp_gids;
66 int priority;
67};
Tom Cherrybbcbc2f2019-06-10 11:08:01 -070068Result<void> SetProcessAttributes(const ProcessAttributes& attr);
Vic Yange01ca4d2019-05-29 15:58:32 -070069
Tom Cherrybbcbc2f2019-06-10 11:08:01 -070070Result<void> WritePidToFiles(std::vector<std::string>* files);
Vic Yange01ca4d2019-05-29 15:58:32 -070071
72} // namespace init
73} // namespace android