Skip to content

Commit

Permalink
WIP: cap_enter
Browse files Browse the repository at this point in the history
  • Loading branch information
talex5 committed Feb 19, 2024
1 parent b897454 commit f248e9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions lib_eio/unix/cap.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
#include "primitives.h"

#define HAVE_CAP_ENTER

#include <errno.h>
#include <sys/param.h>

#ifdef __FreeBSD__
# define HAVE_CAPSICUM
#endif

#ifdef HAVE_CAP_ENTER
#ifdef HAVE_CAPSICUM
# include <sys/capsicum.h>
#endif

#include <caml/mlvalues.h>
#include <caml/unixsupport.h>

CAMLprim value eio_unix_cap_enter(value v_unit) {
#ifdef HAVE_CAP_ENTER
#ifdef HAVE_CAPSICUM
int r = cap_enter();
if (r == -1 && errno != ENOSYS)
caml_uerror("cap_enter", Nothing);

return Val_bool(r == 0)
return Val_bool(r == 0);
#else
return Val_bool(0)
return Val_bool(0);
#endif
}
2 changes: 1 addition & 1 deletion lib_eio/unix/cap.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
external eio_cap_enter : unit -> bool = "eio_unix_cap_enter"

let cap_enter () =
let enter () =
if eio_cap_enter () then Ok ()
else Error `Not_supported
2 changes: 1 addition & 1 deletion lib_eio/unix/cap.mli
Original file line number Diff line number Diff line change
@@ -1 +1 @@
val cap_enter : unit -> (unit, [`Not_supported]) result
val enter : unit -> (unit, [`Not_supported]) result

0 comments on commit f248e9c

Please sign in to comment.