aboutsummaryrefslogtreecommitdiff
path: root/libcap/cap_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcap/cap_alloc.c')
-rw-r--r--libcap/cap_alloc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libcap/cap_alloc.c b/libcap/cap_alloc.c
index 6dab4e6..88ba6da 100644
--- a/libcap/cap_alloc.c
+++ b/libcap/cap_alloc.c
@@ -147,6 +147,22 @@ cap_launch_t cap_new_launcher(const char *arg0, const char * const *argv,
}
/*
+ * cap_func_launcher allocates some memory for a launcher and
+ * initializes it. The purpose of this launcher, unlike one created
+ * with cap_new_launcher(), is to execute some function code from a
+ * forked copy of the program. The forked process will exit when the
+ * callback function, func, returns.
+ */
+cap_launch_t cap_func_launcher(int (callback_fn)(void *detail))
+{
+ __u32 *data = calloc(1, sizeof(__u32) + sizeof(struct cap_launch_s));
+ *(data++) = CAP_LAUNCH_MAGIC;
+ struct cap_launch_s *attr = (struct cap_launch_s *) data;
+ attr->custom_setup_fn = callback_fn;
+ return attr;
+}
+
+/*
* Scrub and then liberate an internal capability set.
*/