priv.h revision 134a1f4e3289b54e0f980e9cf05352e419a60bee
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#ifndef _SYS_PRIV_H
#define _SYS_PRIV_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
/*
* Kernel type definitions.
*/
typedef int priv_ptype_t;
typedef int priv_t;
#else /* _KERNEL */
/*
* Userland type definitions.
*/
#ifdef __STDC__
typedef const char *priv_ptype_t;
typedef const char *priv_t;
#else
typedef char *priv_ptype_t;
typedef char *priv_t;
#endif
#endif /* _KERNEL */
/*
* priv_op_t indicates a privilege operation type
*/
typedef enum priv_op {
} priv_op_t;
/*
* Privilege system call subcodes.
*/
#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
/*
* Maximum length of a user defined privilege name.
*/
#define PRIVNAME_MAX 32
/*
* Privilege interface functions for those parts of the kernel that
* know nothing of the privilege internals.
*
* A privilege implementation can have a varying number of sets; sets
* consist of a number of priv_chunk_t's and the size is expressed as such.
* The privileges can be represented as
*
* priv_chunk_t privs[info.priv_nsets][info.priv_setsize]
* ... priv_infosize of extra information ...
*
* Extra data contained in the privilege information consists of chunks
* of data with specified size and type all headed by a priv_info_t header
* which defines both the type of information as well as the size of the
* information. ((char*)&info)+info->priv_info_size should be rounded up
* to point to the next piece of information.
*/
typedef struct priv_impl_info {
#define PRIV_IMPL_INFO_SIZE(p) \
((p)->priv_headersize + (p)->priv_globalinfosize)
#define PRIV_PRPRIV_INFO_OFFSET(p) \
(sizeof (*(p)) + \
#define PRIV_PRPRIV_SIZE(p) \
(PRIV_PRPRIV_INFO_OFFSET(p) + (p)->pr_infosize)
/*
* Per credential flags.
*/
/* user-settable flags: */
/*
* Header of the privilege info data structure; multiple structures can
* follow the privilege sets and priv_impl_info structures.
*/
typedef struct priv_info {
} priv_info_t;
typedef struct priv_info_uint {
/*
* Global privilege set information item; the actual size of the array is
* {priv_setsize}.
*/
typedef struct priv_info_set {
/*
* names[1] is a place holder which can contain multiple NUL terminated,
* non-empty strings.
*/
typedef struct priv_info_names {
int cnt; /* number of strings */
/*
* Privilege information types.
*/
#define PRIV_INFO_SETNAMES 0x0001
#define PRIV_INFO_PRIVNAMES 0x0002
#define PRIV_INFO_BASICPRIVS 0x0003
#define PRIV_INFO_FLAGS 0x0004
/*
* Special "privileges" used to indicate special conditions in privilege
*/
#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(struct prpriv *);
extern priv_impl_info_t *priv_hold_implinfo(void);
extern void priv_release_implinfo(void);
extern size_t priv_get_implinfo_size(void);
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);
struct cred **, int);
extern void priv_inverse(priv_set_t *);
extern void priv_set_PA(cred_t *);
extern void priv_adjust_PA(cred_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PRIV_H */