Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 29 | namespace android { |
| 30 | namespace init { |
| 31 | |
Tom Cherry | 2e4c85f | 2019-07-09 13:33:36 -0700 | [diff] [blame^] | 32 | struct 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 | |
| 44 | struct FileDescriptor { |
| 45 | std::string name; |
| 46 | std::string type; |
| 47 | |
| 48 | Result<void> CreateAndPublish() const; |
| 49 | }; |
| 50 | |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 51 | struct NamespaceInfo { |
Tom Cherry | 247ffbf | 2019-07-08 15:09:36 -0700 | [diff] [blame] | 52 | int flags; |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 53 | // Pair of namespace type, path to name. |
| 54 | std::vector<std::pair<int, std::string>> namespaces_to_enter; |
| 55 | }; |
Tom Cherry | bbcbc2f | 2019-06-10 11:08:01 -0700 | [diff] [blame] | 56 | Result<void> EnterNamespaces(const NamespaceInfo& info, const std::string& name, bool pre_apexd); |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 57 | |
| 58 | struct 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 Cherry | bbcbc2f | 2019-06-10 11:08:01 -0700 | [diff] [blame] | 68 | Result<void> SetProcessAttributes(const ProcessAttributes& attr); |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 69 | |
Tom Cherry | bbcbc2f | 2019-06-10 11:08:01 -0700 | [diff] [blame] | 70 | Result<void> WritePidToFiles(std::vector<std::string>* files); |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 71 | |
| 72 | } // namespace init |
| 73 | } // namespace android |