]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/capability-util.h
tree-wide: drop 'This file is part of systemd' blurb
[thirdparty/systemd.git] / src / basic / capability-util.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
05d3a176 2#pragma once
7f110ff9
LP
3
4/***
d7832d2c 5 Copyright 2010 Lennart Poettering
7f110ff9
LP
6***/
7
ec8927ca 8#include <stdbool.h>
11c3a366 9#include <stdint.h>
5ce70e5b 10#include <sys/capability.h>
11c3a366 11#include <sys/types.h>
5ce70e5b 12
11c3a366 13#include "macro.h"
5ce70e5b 14#include "util.h"
ec8927ca 15
a103496c
IP
16#define CAP_ALL (uint64_t) -1
17
d7832d2c
KS
18unsigned long cap_last_cap(void);
19int have_effective_cap(int value);
a103496c
IP
20int capability_bounding_set_drop(uint64_t keep, bool right_now);
21int capability_bounding_set_drop_usermode(uint64_t keep);
5ce70e5b 22
755d4b67
IP
23int capability_ambient_set_apply(uint64_t set, bool also_inherit);
24int capability_update_inherited_set(cap_t caps, uint64_t ambient_set);
25
45afd519 26int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities);
966bff26 27
dd5ae4c3
PK
28int drop_capability(cap_value_t cv);
29
5ce70e5b
ZJS
30DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free);
31#define _cleanup_cap_free_ _cleanup_(cap_freep)
32
33static inline void cap_free_charpp(char **p) {
34 if (*p)
35 cap_free(*p);
36}
37#define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp)
a103496c
IP
38
39static inline bool cap_test_all(uint64_t caps) {
40 uint64_t m;
41 m = (UINT64_C(1) << (cap_last_cap() + 1)) - 1;
d94a24ca 42 return FLAGS_SET(caps, m);
a103496c 43}
39f608e4
LP
44
45bool ambient_capabilities_supported(void);