Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 1 | /* system.h |
| 2 | * Copyright (C) 2017 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 | * Wrappers for system functionality. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _SYSTEM_H_ |
| 20 | #define _SYSTEM_H_ |
| 21 | |
Mike Frysinger | eaab420 | 2017-08-14 14:57:21 -0400 | [diff] [blame] | 22 | #include <stdbool.h> |
Jorge Lucangeli Obes | a6eb21a | 2017-04-20 10:44:00 -0400 | [diff] [blame] | 23 | #include <sys/capability.h> |
| 24 | #include <sys/prctl.h> |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 25 | #include <sys/types.h> |
| 26 | |
| 27 | #ifdef __cplusplus |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
Jorge Lucangeli Obes | a6eb21a | 2017-04-20 10:44:00 -0400 | [diff] [blame] | 31 | /* Control the ambient capability set. */ |
| 32 | #ifndef PR_CAP_AMBIENT |
| 33 | #define PR_CAP_AMBIENT 47 |
| 34 | #endif |
| 35 | |
| 36 | #ifndef PR_CAP_AMBIENT_IS_SET |
| 37 | #define PR_CAP_AMBIENT_IS_SET 1 |
| 38 | #endif |
| 39 | |
| 40 | #ifndef PR_CAP_AMBIENT_RAISE |
| 41 | #define PR_CAP_AMBIENT_RAISE 2 |
| 42 | #endif |
| 43 | |
| 44 | #ifndef PR_CAP_AMBIENT_LOWER |
| 45 | #define PR_CAP_AMBIENT_LOWER 3 |
| 46 | #endif |
| 47 | |
| 48 | #ifndef PR_CAP_AMBIENT_CLEAR_ALL |
| 49 | #define PR_CAP_AMBIENT_CLEAR_ALL 4 |
| 50 | #endif |
| 51 | |
Luis Hector Chavez | ec0a2c1 | 2017-06-29 20:29:57 -0700 | [diff] [blame] | 52 | int lock_securebits(uint64_t skip_mask); |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 53 | |
| 54 | unsigned int get_last_valid_cap(void); |
Jorge Lucangeli Obes | a6eb21a | 2017-04-20 10:44:00 -0400 | [diff] [blame] | 55 | int cap_ambient_supported(void); |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 56 | |
| 57 | int config_net_loopback(void); |
| 58 | |
| 59 | int setup_pipe_end(int fds[2], size_t index); |
| 60 | int setup_and_dupe_pipe_end(int fds[2], size_t index, int fd); |
| 61 | |
| 62 | int write_pid_to_path(pid_t pid, const char *path); |
| 63 | int write_proc_file(pid_t pid, const char *content, const char *basename); |
| 64 | |
| 65 | int setup_mount_destination(const char *source, const char *dest, uid_t uid, |
Mike Frysinger | eaab420 | 2017-08-14 14:57:21 -0400 | [diff] [blame] | 66 | uid_t gid, bool bind); |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 67 | |
Luis Hector Chavez | 7132355 | 2017-09-05 09:17:22 -0700 | [diff] [blame] | 68 | int lookup_user(const char *user, uid_t *uid, gid_t *gid); |
| 69 | int lookup_group(const char *group, gid_t *gid); |
| 70 | |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 71 | #ifdef __cplusplus |
| 72 | }; /* extern "C" */ |
| 73 | #endif |
| 74 | |
| 75 | #endif /* _SYSTEM_H_ */ |