summaryrefslogtreecommitdiff
path: root/src/shared/capability.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-12-31 22:35:54 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-02 19:45:48 -0500
commit5ce70e5bcd62e89b52485961c3699312ee4a7e0e (patch)
tree3cfa1d90fb492d5b71a38b4a8d57fe8bc5674416 /src/shared/capability.h
parentac6b760ceedd4b21921b6a682cf1479af3d3024f (diff)
Introduce cleanup functions for cap_free
Unfortunately a different cleanup function is necessary per type, because cap_t** and char** are incompatible with void**.
Diffstat (limited to 'src/shared/capability.h')
-rw-r--r--src/shared/capability.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/capability.h b/src/shared/capability.h
index 59469e56cb..64f86410ab 100644
--- a/src/shared/capability.h
+++ b/src/shared/capability.h
@@ -23,8 +23,20 @@
#include <inttypes.h>
#include <stdbool.h>
+#include <sys/capability.h>
+
+#include "util.h"
unsigned long cap_last_cap(void);
int have_effective_cap(int value);
int capability_bounding_set_drop(uint64_t drop, bool right_now);
int capability_bounding_set_drop_usermode(uint64_t drop);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free);
+#define _cleanup_cap_free_ _cleanup_(cap_freep)
+
+static inline void cap_free_charpp(char **p) {
+ if (*p)
+ cap_free(*p);
+}
+#define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp)