xref: /illumos-gate/usr/src/lib/libc/port/sys/ppriv.c (revision 0250c53ad267726f2438e3c6556199a0bbf588a2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma weak _setppriv = setppriv
28 #pragma weak _getppriv = getppriv
29 #pragma weak _setpflags = setpflags
30 #pragma weak _getpflags = getpflags
31 
32 #include "lint.h"
33 #include <sys/types.h>
34 #include <sys/syscall.h>
35 #include "priv_private.h"
36 #include <priv.h>
37 
38 int
39 setppriv(priv_op_t op, priv_ptype_t type, const priv_set_t *pset)
40 {
41 	priv_data_t *d;
42 	int set;
43 
44 	LOADPRIVDATA(d);
45 
46 	set = priv_getsetbyname(type);
47 
48 	return (syscall(SYS_privsys, PRIVSYS_SETPPRIV, op, set, (void *)pset,
49 	    d->pd_setsize));
50 }
51 
52 int
53 getppriv(priv_ptype_t type, priv_set_t *pset)
54 {
55 	priv_data_t *d;
56 	int set;
57 
58 	LOADPRIVDATA(d);
59 
60 	set = priv_getsetbyname(type);
61 
62 	return (syscall(SYS_privsys, PRIVSYS_GETPPRIV, 0, set, (void *)pset,
63 	    d->pd_setsize));
64 }
65 
66 int
67 getprivinfo(priv_impl_info_t *buf, size_t bufsize)
68 {
69 	return (syscall(SYS_privsys, PRIVSYS_GETIMPLINFO, 0, 0, (void *)buf,
70 	    bufsize));
71 }
72 
73 int
74 setpflags(uint_t flag, uint_t val)
75 {
76 	return (syscall(SYS_privsys, PRIVSYS_SETPFLAGS, (priv_op_t)flag,
77 	    (priv_ptype_t)(uintptr_t)val, 0, 0));
78 }
79 
80 uint_t
81 getpflags(uint_t flag)
82 {
83 	return (syscall(SYS_privsys, PRIVSYS_GETPFLAGS, flag, 0, 0, 0));
84 }
85