#ifndef _SYS_PRIV_H
#define _SYS_PRIV_H
#include <sys/types.h>
#include <sys/cred.h>
#include <sys/priv_names.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint32_t priv_chunk_t;
typedef struct priv_set priv_set_t;
#ifdef _KERNEL
typedef int priv_ptype_t;
typedef int priv_t;
#else
typedef const char *priv_ptype_t;
typedef const char *priv_t;
#endif
typedef enum priv_op {
PRIV_ON,
PRIV_OFF,
PRIV_SET
} priv_op_t;
#define PRIVSYS_SETPPRIV 0
#define PRIVSYS_GETPPRIV 1
#define PRIVSYS_GETIMPLINFO 2
#define PRIVSYS_SETPFLAGS 3
#define PRIVSYS_GETPFLAGS 4
#define PRIVSYS_ISSETUGID 5
#define PRIVSYS_KLPD_REG 6
#define PRIVSYS_KLPD_UNREG 7
#define PRIVSYS_PFEXEC_REG 8
#define PRIVSYS_PFEXEC_UNREG 9
#define PRIVNAME_MAX 32
typedef struct priv_impl_info {
uint32_t priv_headersize;
uint32_t priv_flags;
uint32_t priv_nsets;
uint32_t priv_setsize;
uint32_t priv_max;
uint32_t priv_infosize;
uint32_t priv_globalinfosize;
} priv_impl_info_t;
#define PRIV_IMPL_INFO_SIZE(p) \
((p)->priv_headersize + (p)->priv_globalinfosize)
#define PRIV_PRPRIV_INFO_OFFSET(p) \
(sizeof (*(p)) + \
((p)->pr_nsets * (p)->pr_setsize - 1) * sizeof (priv_chunk_t))
#define PRIV_PRPRIV_SIZE(p) \
(PRIV_PRPRIV_INFO_OFFSET(p) + (p)->pr_infosize)
#define PRIV_DEBUG 0x0001
#define PRIV_AWARE 0x0002
#define PRIV_AWARE_INHERIT 0x0004
#define __PROC_PROTECT 0x0008
#define NET_MAC_AWARE 0x0010
#define NET_MAC_AWARE_INHERIT 0x0020
#define PRIV_AWARE_RESET 0x0040
#define PRIV_XPOLICY 0x0080
#define PRIV_PFEXEC 0x0100
#define PRIV_USER (PRIV_DEBUG | NET_MAC_AWARE | NET_MAC_AWARE_INHERIT |\
PRIV_XPOLICY | PRIV_AWARE_RESET | PRIV_PFEXEC)
typedef struct priv_info {
uint32_t priv_info_type;
uint32_t priv_info_size;
} priv_info_t;
typedef struct priv_info_uint {
priv_info_t info;
uint_t val;
} priv_info_uint_t;
typedef struct priv_info_set {
priv_info_t info;
priv_chunk_t set[1];
} priv_info_set_t;
typedef struct priv_info_names {
priv_info_t info;
int cnt;
char names[1];
} priv_info_names_t;
#define PRIV_INFO_SETNAMES 0x0001
#define PRIV_INFO_PRIVNAMES 0x0002
#define PRIV_INFO_BASICPRIVS 0x0003
#define PRIV_INFO_FLAGS 0x0004
#define PRIV_ALL (-1)
#define PRIV_MULTIPLE (-2)
#define PRIV_NONE (-3)
#define PRIV_ALLZONE (-4)
#define PRIV_GLOBAL (-5)
#ifdef _KERNEL
#define PRIV_ALLOC 0x1
extern int priv_debug;
extern int priv_basic_test;
struct proc;
struct prpriv;
struct cred;
extern int priv_prgetprivsize(const struct prpriv *);
extern void cred2prpriv(const struct cred *, struct prpriv *);
extern int priv_pr_spriv(struct proc *, struct prpriv *, const struct cred *);
extern priv_impl_info_t *priv_hold_implinfo(void);
extern void priv_release_implinfo(void);
extern size_t priv_get_implinfo_size(void);
extern const priv_set_t *priv_getset(const struct cred *, int);
extern void priv_getinfo(const struct cred *, void *);
extern int priv_getbyname(const char *, uint_t);
extern int priv_getsetbyname(const char *, int);
extern const char *priv_getbynum(int);
extern const char *priv_getsetbynum(int);
extern void priv_emptyset(priv_set_t *);
extern void priv_fillset(priv_set_t *);
extern void priv_addset(priv_set_t *, int);
extern void priv_delset(priv_set_t *, int);
extern boolean_t priv_ismember(const priv_set_t *, int);
extern boolean_t priv_isemptyset(const priv_set_t *);
extern boolean_t priv_isfullset(const priv_set_t *);
extern boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *);
extern boolean_t priv_issubset(const priv_set_t *, const priv_set_t *);
extern int priv_proc_cred_perm(const struct cred *, struct proc *,
struct cred **, int);
extern void priv_intersect(const priv_set_t *, priv_set_t *);
extern void priv_union(const priv_set_t *, priv_set_t *);
extern void priv_inverse(priv_set_t *);
extern void priv_set_PA(cred_t *);
extern void priv_adjust_PA(cred_t *);
extern void priv_reset_PA(cred_t *, boolean_t);
extern boolean_t priv_can_clear_PA(const cred_t *);
extern int setpflags(uint_t, uint_t, cred_t *);
extern uint_t getpflags(uint_t, const cred_t *);
#endif
#ifdef __cplusplus
}
#endif
#endif