summaryrefslogtreecommitdiff
path: root/usr/src/man/man3c/priv_set.3c
blob: b748d4a1b7b693c4b24e283bcbd6fe8403621503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
.\" 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 or
.\" http://www.opensolaris.org/os/licensing.  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]
.\"
.\" Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
.\"
.Dd June 3, 2022
.Dt PRIV_SET 3C
.Os
.Sh NAME
.Nm priv_set ,
.Nm priv_ineffect
.Nd change privilege sets and check whether privileges are set
.Sh SYNOPSIS
.In priv.h
.Ft int
.Fo priv_set
.Fa "priv_op_t op"
.Fa "priv_ptype_t which"
.Fa "..."
.Fc
.Ft boolean_t
.Fo priv_ineffect
.Fa "const char *priv"
.Fc
.Sh DESCRIPTION
.Fn priv_set
is a convenient wrapper for the
.Xr setppriv 2
function.
It takes three or more arguments.
The operation argument,
.Ar op ,
can be one of
.Dv PRIV_OFF , PRIV_ON
or
.Dv PRIV_SET .
The
.Ar which
argument is the name of the privilege set to change, one of
.Dv PRIV_EFFECTIVE , PRIV_INHERITABLE , PRIV_PERMITTED , PRIV_LIMIT
or the special pseudo set
.Dv PRIV_ALLSETS
if the operation should be applied to all privilege sets.
Subsequent arguments provide zero or more privilege names, terminated with a
.Dv NULL
pointer.
See
.Sx EXAMPLES .
.Pp
The specified privileges are converted to a binary privilege set and
.Xr setppriv 2
is called with the same
.Ar op
and
.Ar which
arguments.
When called with
.Dv PRIV_ALLSETS
as the value for the
.Ar which
argument,
.Xr setppriv 2
is called for each set in turn, aborting on the first failed call.
.Pp
.Fn priv_ineffect
is a convenient wrapper for the
.Xr getppriv 2
function.
The
.Ar priv
argument specifies the name of a privilege, and this function checks for its
presence in the effective set.
.Sh RETURN VALUES
Upon successful completion,
.Fn priv_set
return 0.
Otherwise, -1  is returned and
.Dv errno
is set to indicate the error.
.Pp
If
.Ar priv
is a valid privilege that is a member of the effective set,
.Fn priv_ineffect
returns
.Dv B_TRUE .
Otherwise, it returns
.Dv B_FALSE
and sets
.Dv errno
to indicate the error.
.Sh EXAMPLES
.Sy Example 1
Using
.Fn priv_set
.Bd -literal -offset 6n
#include <priv.h>
\&...
/* Remove basic privileges we don't need */
(void) priv_set(PRIV_OFF, PRIV_PERMITTED, PRIV_PROC_EXEC,
    PRIV_PROC_INFO, PRIV_FILE_LINK_ANY, PRIV_PROC_SESSION,
    NULL);
.Ed
.Sh ERRORS
The
.Fn priv_set
function will fail if:
.Bl -tag -width Ds
.It Er EINVAL
The value of
.Ar op
or
.Ar which
is out of range.
.It Er ENOMEM
Insufficient memory was allocated.
.It Er EPERM
The application attempted to add privileges to
.Dv PRIV_LIMIT
or
.Dv PRIV_PERMITTED ,
or the application attempted to add privileges to
.Dv PRIV_INHERITABLE
or
.Dv PRIV_EFFECTIVE
that were not in
.Dv PRIV_PERMITTED .
.El
.Pp
The
.Fn priv_ineffect
function will fail if:
.Bl -tag -width Ds
.It Er EINVAL
The privilege specified by
.Ar priv
is invalid.
.It Er ENOMEM
Insufficient memory was allocated.
.El
.Sh INTERFACE STABILITY
.Sy Uncommitted
.Sh MT-LEVEL
.Sy MT-Safe
.Sh SEE ALSO
.Xr setppriv 2 ,
.Xr priv_str_to_set 3C ,
.Xr attributes 7 ,
.Xr privileges 7