Mike Frysinger | 50e31fa | 2018-01-19 18:59:49 -0500 | [diff] [blame] | 1 | /* Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 2 | * Use of this source code is governed by a BSD-style license that can be |
| 3 | * found in the LICENSE file. |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 4 | * |
| 5 | * Wrappers for system functionality. |
| 6 | */ |
| 7 | |
| 8 | #ifndef _SYSTEM_H_ |
| 9 | #define _SYSTEM_H_ |
| 10 | |
Mike Frysinger | eaab420 | 2017-08-14 14:57:21 -0400 | [diff] [blame] | 11 | #include <stdbool.h> |
Jorge Lucangeli Obes | a6eb21a | 2017-04-20 10:44:00 -0400 | [diff] [blame] | 12 | #include <sys/capability.h> |
| 13 | #include <sys/prctl.h> |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 14 | #include <sys/types.h> |
| 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Jorge Lucangeli Obes | a6eb21a | 2017-04-20 10:44:00 -0400 | [diff] [blame] | 20 | /* Control the ambient capability set. */ |
| 21 | #ifndef PR_CAP_AMBIENT |
| 22 | #define PR_CAP_AMBIENT 47 |
| 23 | #endif |
| 24 | |
| 25 | #ifndef PR_CAP_AMBIENT_IS_SET |
| 26 | #define PR_CAP_AMBIENT_IS_SET 1 |
| 27 | #endif |
| 28 | |
| 29 | #ifndef PR_CAP_AMBIENT_RAISE |
| 30 | #define PR_CAP_AMBIENT_RAISE 2 |
| 31 | #endif |
| 32 | |
| 33 | #ifndef PR_CAP_AMBIENT_LOWER |
| 34 | #define PR_CAP_AMBIENT_LOWER 3 |
| 35 | #endif |
| 36 | |
| 37 | #ifndef PR_CAP_AMBIENT_CLEAR_ALL |
| 38 | #define PR_CAP_AMBIENT_CLEAR_ALL 4 |
| 39 | #endif |
| 40 | |
Luis Hector Chavez | ec0a2c1 | 2017-06-29 20:29:57 -0700 | [diff] [blame] | 41 | int lock_securebits(uint64_t skip_mask); |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 42 | |
| 43 | unsigned int get_last_valid_cap(void); |
Jorge Lucangeli Obes | a6eb21a | 2017-04-20 10:44:00 -0400 | [diff] [blame] | 44 | int cap_ambient_supported(void); |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 45 | |
| 46 | int config_net_loopback(void); |
| 47 | |
| 48 | int setup_pipe_end(int fds[2], size_t index); |
| 49 | int setup_and_dupe_pipe_end(int fds[2], size_t index, int fd); |
| 50 | |
| 51 | int write_pid_to_path(pid_t pid, const char *path); |
| 52 | int write_proc_file(pid_t pid, const char *content, const char *basename); |
| 53 | |
| 54 | 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] | 55 | uid_t gid, bool bind); |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 56 | |
Luis Hector Chavez | 7132355 | 2017-09-05 09:17:22 -0700 | [diff] [blame] | 57 | int lookup_user(const char *user, uid_t *uid, gid_t *gid); |
| 58 | int lookup_group(const char *group, gid_t *gid); |
| 59 | |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 60 | #ifdef __cplusplus |
| 61 | }; /* extern "C" */ |
| 62 | #endif |
| 63 | |
| 64 | #endif /* _SYSTEM_H_ */ |