/*
* 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 _PRIV_PRIVATE_H
#define _PRIV_PRIVATE_H
#include <limits.h>
#include <note.h>
/*
* Libc private privilege data.
*/
#ifdef __cplusplus
extern "C" {
#endif
#define LOCKPRIVDATA() { \
/* Data already allocated */ \
(void) lock_data(); \
(void) refresh_data(); \
}
#define WITHPRIVLOCKED(t, b, x) do { \
t __result; \
if (lock_data() != 0) \
return (b); \
__result = (x); \
if (__result == (b) && refresh_data()) \
__result = (x); \
unlock_data(); \
return (__result); \
NOTE(NOTREACHED);\
} while (__lintzero)
/*
* Privilege mask macros.
*/
/*
* Same as the functions, but for numeric privileges.
*/
privmask(p)
~privmask(p)
privmask(p)) != 0)
/*
* The structure is static except for the setsort, privnames and nprivs
* field. The pinfo structure initially has sufficient room and the kernel
* guarantees no offset changes so we can copy a new structure on top of it.
* The locking stratgegy is this: we lock it when we need to reference any
* of the volatile fields.
*/
typedef struct priv_data {
char **pd_setnames;
char **pd_privnames;
int *pd_setsort;
} priv_data_t;
extern priv_data_t *__priv_getdata(void);
extern void __priv_free_info(priv_data_t *);
extern priv_data_t *privdata;
extern int lock_data(void);
extern boolean_t refresh_data(void);
extern void unlock_data(void);
const priv_set_t *);
extern const char *__priv_getbynum(const priv_data_t *, int);
extern priv_set_t *priv_basic(void);
#ifdef __cplusplus
}
#endif
#endif /* _PRIV_PRIVATE_H */