]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
05d3a176 | 2 | #pragma once |
7f110ff9 LP |
3 | |
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
d7832d2c | 7 | Copyright 2010 Lennart Poettering |
7f110ff9 LP |
8 | |
9 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
10 | under the terms of the GNU Lesser General Public License as published by |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
7f110ff9 LP |
12 | (at your option) any later version. |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 17 | Lesser General Public License for more details. |
7f110ff9 | 18 | |
5430f7f2 | 19 | You should have received a copy of the GNU Lesser General Public License |
7f110ff9 LP |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
21 | ***/ | |
22 | ||
ec8927ca | 23 | #include <stdbool.h> |
11c3a366 | 24 | #include <stdint.h> |
5ce70e5b | 25 | #include <sys/capability.h> |
11c3a366 | 26 | #include <sys/types.h> |
5ce70e5b | 27 | |
11c3a366 | 28 | #include "macro.h" |
5ce70e5b | 29 | #include "util.h" |
ec8927ca | 30 | |
a103496c IP |
31 | #define CAP_ALL (uint64_t) -1 |
32 | ||
d7832d2c KS |
33 | unsigned long cap_last_cap(void); |
34 | int have_effective_cap(int value); | |
a103496c IP |
35 | int capability_bounding_set_drop(uint64_t keep, bool right_now); |
36 | int capability_bounding_set_drop_usermode(uint64_t keep); | |
5ce70e5b | 37 | |
755d4b67 IP |
38 | int capability_ambient_set_apply(uint64_t set, bool also_inherit); |
39 | int capability_update_inherited_set(cap_t caps, uint64_t ambient_set); | |
40 | ||
45afd519 | 41 | int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities); |
966bff26 | 42 | |
dd5ae4c3 PK |
43 | int drop_capability(cap_value_t cv); |
44 | ||
5ce70e5b ZJS |
45 | DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free); |
46 | #define _cleanup_cap_free_ _cleanup_(cap_freep) | |
47 | ||
48 | static inline void cap_free_charpp(char **p) { | |
49 | if (*p) | |
50 | cap_free(*p); | |
51 | } | |
52 | #define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp) | |
a103496c IP |
53 | |
54 | static inline bool cap_test_all(uint64_t caps) { | |
55 | uint64_t m; | |
56 | m = (UINT64_C(1) << (cap_last_cap() + 1)) - 1; | |
57 | return (caps & m) == m; | |
58 | } | |
39f608e4 LP |
59 | |
60 | bool ambient_capabilities_supported(void); |