Path: blob/main/contrib/capsicum-test/capsicum-freebsd.h
39475 views
#ifndef __CAPSICUM_FREEBSD_H__1#define __CAPSICUM_FREEBSD_H__2#ifdef __FreeBSD__3/************************************************************4* FreeBSD Capsicum Functionality.5************************************************************/67#ifdef __cplusplus8extern "C" {9#endif1011/* FreeBSD definitions. */12#include <errno.h>13#include <sys/param.h>14#if __FreeBSD_version >= 1100014 || \15(__FreeBSD_version >= 1001511 && __FreeBSD_version < 1100000)16#include <sys/capsicum.h>17#else18#include <sys/capability.h>19#endif20#include <sys/procdesc.h>2122#if __FreeBSD_version >= 100000023#define AT_SYSCALLS_IN_CAPMODE24#define HAVE_CAP_RIGHTS_GET25#define HAVE_CAP_RIGHTS_LIMIT26#define HAVE_PROCDESC_FSTAT27#define HAVE_CAP_FCNTLS_LIMIT28// fcntl(2) takes int, cap_fcntls_limit(2) takes uint32_t.29typedef uint32_t cap_fcntl_t;30#define HAVE_CAP_IOCTLS_LIMIT31// ioctl(2) and cap_ioctls_limit(2) take unsigned long.32typedef unsigned long cap_ioctl_t;3334#if __FreeBSD_version >= 110100035#define HAVE_OPENAT_INTERMEDIATE_DOTDOT36#endif3738#endif3940#ifdef __cplusplus41}42#endif4344// Use fexecve_() in tests to allow Linux variant to bypass glibc version.45#define fexecve_(F, A, E) fexecve(F, A, E)4647#ifdef ENOTBENEATH48#define E_NO_TRAVERSE_CAPABILITY ENOTBENEATH49#define E_NO_TRAVERSE_O_BENEATH ENOTBENEATH50#else51#define E_NO_TRAVERSE_CAPABILITY ENOTCAPABLE52#define E_NO_TRAVERSE_O_BENEATH ENOTCAPABLE53#endif5455// FreeBSD limits the number of ioctls in cap_ioctls_limit to 25656#define CAP_IOCTLS_LIMIT_MAX 2565758// Too many links59#define E_TOO_MANY_LINKS EMLINK6061// As of commit 85b0f9de11c3 ("capsicum: propagate rights on accept(2)")62// FreeBSD generates a capability from accept(cap_fd,...).63#define CAP_FROM_ACCEPT64// As of commit 91a9e4e01dab ("capsicum: propagate rights on sctp_peeloff")65// FreeBSD generates a capability from sctp_peeloff(cap_fd,...).66#define CAP_FROM_PEELOFF6768#endif /* __FreeBSD__ */6970#endif /*__CAPSICUM_FREEBSD_H__*/717273