blob: 7f36ad2290e7814717e65284cb8b487afd4d0ff2 [file] [log] [blame]
Mike Frysinger50e31fa2018-01-19 18:59:49 -05001/* 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 Obes0b208772017-04-19 14:15:46 -04004 *
5 * Wrappers for system functionality.
6 */
7
8#ifndef _SYSTEM_H_
9#define _SYSTEM_H_
10
Mike Frysingereaab4202017-08-14 14:57:21 -040011#include <stdbool.h>
Jorge Lucangeli Obesa6eb21a2017-04-20 10:44:00 -040012#include <sys/capability.h>
13#include <sys/prctl.h>
Jorge Lucangeli Obes0b208772017-04-19 14:15:46 -040014#include <sys/types.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
Jorge Lucangeli Obesa6eb21a2017-04-20 10:44:00 -040020/* 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 Chavezec0a2c12017-06-29 20:29:57 -070041int lock_securebits(uint64_t skip_mask);
Jorge Lucangeli Obes0b208772017-04-19 14:15:46 -040042
43unsigned int get_last_valid_cap(void);
Jorge Lucangeli Obesa6eb21a2017-04-20 10:44:00 -040044int cap_ambient_supported(void);
Jorge Lucangeli Obes0b208772017-04-19 14:15:46 -040045
46int config_net_loopback(void);
47
48int setup_pipe_end(int fds[2], size_t index);
49int setup_and_dupe_pipe_end(int fds[2], size_t index, int fd);
50
51int write_pid_to_path(pid_t pid, const char *path);
52int write_proc_file(pid_t pid, const char *content, const char *basename);
53
54int setup_mount_destination(const char *source, const char *dest, uid_t uid,
Mike Frysingereaab4202017-08-14 14:57:21 -040055 uid_t gid, bool bind);
Jorge Lucangeli Obes0b208772017-04-19 14:15:46 -040056
Luis Hector Chavez71323552017-09-05 09:17:22 -070057int lookup_user(const char *user, uid_t *uid, gid_t *gid);
58int lookup_group(const char *group, gid_t *gid);
59
Jorge Lucangeli Obes0b208772017-04-19 14:15:46 -040060#ifdef __cplusplus
61}; /* extern "C" */
62#endif
63
64#endif /* _SYSTEM_H_ */