summaryrefslogtreecommitdiff
path: root/usr/src/man/man3project/setproject.3project
blob: eaba8aa0496a9f18c92978e0b1f49bd3c1d57101 (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
'\" te
.\" Copyright (c) 2007, 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]
.TH SETPROJECT 3PROJECT "Apr 10, 2007"
.SH NAME
setproject \- associate a user process with a project
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag \&.\|.\|.\fR ] \fIfile\fR\&.\|.\|. \fB-lproject\fR [ \fIlibrary \&.\|.\|.\fR ]
#include <project.h>

\fBint\fR \fBsetproject\fR(\fBconst char *\fR\fIproject_name\fR, \fBconst char *\fR\fIuser_name\fR,
     \fBuint_t\fR \fIflags\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBsetproject()\fR function provides a simplified method for the
association of a user process with a project and its various resource
management attributes, as stored in the \fBproject\fR(5) name service database.
These attributes include resource control settings, resource pool membership,
and third party attributes (which are ignored by \fBsetproject()\fR.)
.sp
.LP
If \fIuser_name\fR is a valid member of the project specified by
\fIproject_name\fR, as determined by \fBinproj\fR(3PROJECT), \fBsetproject()\fR
will create a new task with \fBsettaskid\fR(2) using task flags specified by
\fIflags\fR, use \fBsetrctl\fR(2) to associate various resource controls with
the process, task, and project, and bind the calling process to the appropriate
resource pool with \fBpool_set_binding\fR(3POOL).  Resource controls not
explicitly specified in the project entry will be preserved. If \fIuser_name\fR
is a name of the superuser (user with UID equal to 0), the \fBsetproject()\fR
function skips the \fBinproj\fR(3PROJECT) check described above and allows the
superuser to join any project.
.sp
.LP
The current process will not be bound to a resource pool if the resource pools
facility (see \fBpooladm\fR(8)) is inactive. The \fBsetproject()\fR function
will succeed whether or not the project specified by \fIproject_name\fR
specifies a \fBproject.pool\fR attribute. If the resource pools facility is
active, \fBsetproject()\fR will fail if the project does not specify a
\fBproject.pool\fR attribute and there is no designated pool accepting default
assignments. The \fBsetproject()\fR function will also fail if there is a
specified \fBproject.pool\fR attribute for a nonexistent pool.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBsetproject()\fR returns 0. If any of the
resource control assignments failed but the project assignment, pool binding,
and task creation succeeded, an integer value corresponding to the offset into
the key-value pair list of the failed attribute assignment is returned. If the
project assignment or task creation was not successful, \fBsetproject()\fR
returns \fBSETPROJ_ERR_TASK\fR and sets \fBerrno\fR to indicate the error. In
the event of a pool binding failure, \fBsetproject()\fR returns
\fBSETPROJ_ERR_POOL\fR and sets \fBerrno\fR to indicate the error. Additional
error information can be retrieved from \fBpool_error\fR(3POOL).
.SH ERRORS
.sp
.LP
The \fBsetproject()\fR function will fail during project assignment or task
creation if:
.sp
.ne 2
.na
\fB\fBEACCES\fR\fR
.ad
.RS 10n
The invoking task was created with the \fBTASK_FINAL\fR flag.
.RE

.sp
.ne 2
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 10n
A resource control limiting the number of LWPs or tasks in the target project
or zone has been exceeded.
.sp
A resource control on the given project would be exceeded.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The project ID associated with the given project is not within the range of
valid project IDs, invalid flags were specified, or \fIuser_name\fR is
\fINULL\fR.
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
The effective user of the calling process is not superuser.
.RE

.sp
.ne 2
.na
\fB\fBESRCH\fR\fR
.ad
.RS 10n
The specified user is not a valid user of the given project, \fIuser_name\fR is
not valid user name, or \fIproject_name\fR is not valid project name.
.RE

.sp
.LP
The \fBsetproject()\fR function will fail during pool binding if:
.sp
.ne 2
.na
\fB\fBEACCES\fR\fR
.ad
.RS 10n
No resource pool accepting default bindings exists.
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
The effective user of the calling process is not superuser.
.RE

.sp
.ne 2
.na
\fB\fBESRCH\fR\fR
.ad
.RS 10n
The specified resource pool is unknown
.RE

.sp
.LP
If \fBsetproject()\fR returns an offset into the key-value pair list, the
returned error value is associated with \fBsetrctl\fR(2) for resource control
attributes.
.SH USAGE
.sp
.LP
The \fBsetproject()\fR function recognizes a name-structured value pair for the
attributes in the \fBproject\fR(5) database with the following format:
.sp
.in +2
.nf
entity.control=(\fIprivilege\fR,\fIvalue\fR,\fIaction\fR,\fIaction\fR,\&.\|.\|.),\&.\|.\|.
.fi
.in -2

.sp
.LP
where \fIprivilege\fR is one of \fBBASIC\fR or \fBPRIVILEGED\fR, \fIvalue\fR is
a numeric value with optional units, and \fIaction\fR is one of \fBnone\fR,
\fBdeny\fR, and \fBsignal\fR=\fIsignum\fR or \fBsignal\fR=\fISIGNAME\fR. For
instance, to set a series of progressively more assertive control values on a
project's per-process CPU time, specify
.sp
.in +2
.nf
process.max-cpu-time=(PRIVILEGED,1000s,signal=SIGXRES), \e
(PRIVILEGED,1250, signal=SIGTERM),(PRIVILEGED,1500,
     signal=SIGKILL)
.fi
.in -2

.sp
.LP
To prevent a task from exceeding a total of 128 LWPs, specify a resource
control with
.sp
.in +2
.nf
task.max-lwps=(PRIVILEGED,128,deny)
.fi
.in -2

.sp
.LP
Specifying a resource control name with no values causes all resource control
values for that name to be cleared on the given project, leaving only the
system resource control value on the specified resource control name.
.sp
.LP
For example, to remove all resource control values on shared memory, specify:
.sp
.in +2
.nf
project.max-shm-memory
.fi
.in -2

.sp
.LP
The project attribute, \fBproject.pool\fR, specifies the pool to which
processes associated with the project entry should be bound. Its format is:
.sp
.in +2
.nf
project.pool=pool_name
.fi
.in -2

.sp
.LP
where \fBpool_name\fR is a valid resource pool within the active configuration
enabled with \fBpooladm\fR(8).
.sp
.LP
The final attribute is used to finalize the task created by \fBsetproject()\fR.
See \fBsettaskid\fR(2).
.sp
.in +2
.nf
task.final
.fi
.in -2

.sp
.LP
All further attempts to create new tasks, such as using \fBnewtask\fR(1) and
\fBsu\fR(8), will fail.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Evolving
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR setrctl (2),
.BR settaskid (2),
.BR libproject (3LIB),
.BR pool_error (3POOL),
.BR pool_set_binding (3POOL),
.BR inproj (3PROJECT),
.BR passwd (5),
.BR project (5),
.BR attributes (7),
.BR pooladm (8)