2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH UCRED 3C "Nov 6, 2014"
8 ucred, ucred_get, ucred_free, ucred_geteuid, ucred_getruid, ucred_getsuid,
9 ucred_getegid, ucred_getrgid, ucred_getsgid, ucred_getgroups, ucred_getprivset,
10 ucred_getpid, ucred_getprojid, ucred_getzoneid, ucred_getpflags,
11 ucred_getlabel, ucred_size \- user credential functions
17 \fBucred_t *\fR\fBucred_get\fR(\fBpid_t\fR \fIpid\fR);
22 \fBvoid\fR \fBucred_free\fR(\fBucred_t *\fR\fIuc\fR);
27 \fBuid_t\fR \fBucred_geteuid\fR(\fBconst ucred_t *\fR\fIuc\fR);
32 \fBuid_t\fR \fBucred_getruid\fR(\fBconst ucred_t *\fR\fIuc\fR);
37 \fBuid_t\fR \fBucred_getsuid\fR(\fBconst ucred_t *\fR\fIuc\fR);
42 \fBgid_t\fR \fBucred_getegid\fR(\fBconst ucred_t *\fR\fIuc\fR);
47 \fBgid_t\fR \fBucred_getrgid\fR(\fBconst ucred_t *\fR\fIuc\fR);
52 \fBgid_t\fR \fBucred_getsgid\fR(\fBconst ucred_t *\fR\fIuc\fR);
57 \fBint\fR \fBucred_getgroups\fR(\fBconst ucred_t *\fR\fIuc\fR, \fBconst gid_t **\fR\fIgroups\fR);
62 \fBconst priv_set_t *\fR\fBucred_getprivset\fR(\fBconst ucred_t *\fR\fIuc\fR,
63 \fBpriv_ptype_t\fR \fIset\fR);
68 \fBpid_t\fR \fBucred_getpid\fR(\fBconst ucred_t *\fR\fIuc\fR);
73 \fBprojid_t\fR \fBucred_getprojid\fR(\fBconst ucred_t *\fR\fIuc\fR);
78 \fBzoneid_t\fR \fBucred_getzoneid\fR(\fBconst ucred_t *\fR\fIuc\fR);
83 \fBuint_t\fR \fBucred_getpflags\fR(\fBconst ucred_t *\fR\fIuc\fR, \fBuint_t\fR \fIflags\fR);
88 \fBm_label_t *\fR\fBucred_getlabel\fR(\fBconst ucred_t *\fR\fIuc\fR);
93 \fBsize_t\fR \fBucred_size\fR(\fBvoid\fR);
98 These functions return or act on a user credential, \fBucred_t\fR. User
99 credentials are returned by various functions and describe the credentials of a
100 process. Information about the process can then be obtained by calling the
101 access functions. Access functions can fail if the underlying mechanism did not
102 return sufficient information.
105 The \fBucred_get()\fR function returns the user credential of the specified
106 \fIpid\fR or \fINULL\fR if none can be obtained. A \fIpid\fR value of
107 \fBP_MYID\fR returns information about the calling process. The return value is
108 dynamically allocated and must be freed using \fBucred_free()\fR.
111 The \fBucred_geteuid()\fR, \fBucred_getruid()\fR, \fBucred_getsuid()\fR,
112 \fBucred_getegid()\fR, \fBucred_getrgid()\fR, and \fBucred_getsgid()\fR
113 functions return the effective UID, real UID, saved UID, effective GID, real
114 GID, saved GID, respectively, or -1 if the user credential does not contain
115 sufficient information.
118 The \fBucred_getgroups()\fR function stores a pointer to the group list in the
119 \fBgid_t *\fR pointed to by the second argument and returns the number of
120 groups in the list. It returns -1 if the information is not available. The
121 returned group list is valid until \fBucred_free()\fR is called on the user
122 credential given as argument.
125 The \fBucred_getpid()\fR function returns the process ID of the process or -1
126 if the process ID is not available. The process ID returned in a user
127 credential is only guaranteed to be correct in a very limited number of cases
128 when returned by \fBdoor_ucred\fR(3C) and \fBucred_get()\fR. In all other
129 cases, the process in question might have handed of the file descriptor, the
130 process might have exited or executed another program, or the process ID might
131 have been reused by a completely unrelated process after the original program
135 The \fBucred_getprojid()\fR function returns the project ID of the process or
136 -1 if the project ID is not available.
139 The \fBucred_getzoneid()\fR function returns the zone ID of the process or
140 \(mi1 if the zone ID is not available.
143 The \fBucred_getprivset()\fR function returns the specified privilege set
144 specified as second argument, or \fINULL\fR if either the requested information
145 is not available or the privilege set name is invalid. The returned privilege
146 set is valid until \fBucred_free()\fR is called on the specified user
150 The \fBucred_getpflags()\fR function returns the value of the specified
151 privilege flags from the \fBucred\fR structure, or (\fBuint_t\fR)-1 if none was
155 The \fBucred_getlabel()\fR function returns the value of the label, or
156 \fINULL\fR if the label is not available. The returned label is valid until
157 \fBucred_free()\fR is called on the specified user credential. This function is
158 available only if the system is configured with Trusted Extensions.
161 The \fBucred_free()\fR function frees the memory allocated for the specified
165 The \fBucred_size()\fR function returns \fBsizeof\fR(\fBucred_t\fR). This value
166 is constant only until the next boot, at which time it could change. The
167 \fBucred_size()\fR function can be used to determine the size of the buffer
168 needed to receive a credential option with \fBSO_RECVUCRED\fR. See
169 \fBsocket.h\fR(3HEAD).
175 The \fBucred_get()\fR function will fail if:
182 There is not enough memory available to allocate sufficient memory to hold a
183 user credential. The application can try again later.
192 The caller does not have sufficient privileges to examine the target process.
205 The calling process cannot open any more files.
214 The physical limits of the system are exceeded by the memory allocation needed
215 to hold a user credential.
224 The target process does not exist.
229 The \fBucred_getprivset()\fR function will fail if:
236 The privilege set argument is invalid.
241 The \fBucred_getlabel()\fR function will fail if:
248 The label is not present.
253 The \fBucred_geteuid()\fR, \fBucred_getruid()\fR, \fBucred_getsuid()\fR,
254 \fBucred_getegid()\fR, \fBucred_getrgid()\fR, \fBucred_getsgid()\fR,
255 \fBucred_getgroups()\fR, \fBucred_getpflags()\fR, \fBucred_getprivset()\fR,
256 \fBucred_getprojid()\fR, \fBucred_getpid()\fR, and \fBucred_getlabel()\fR
257 functions will fail if:
264 The requested user credential attribute is not available in the specified user
270 See \fBattributes\fR(5) for descriptions of the following attributes:
278 ATTRIBUTE TYPE ATTRIBUTE VALUE
280 Interface Stability Committed
287 \fBgetpflags\fR(2), \fBgetppriv\fR(2), \fBdoor_ucred\fR(3C),
288 \fBgetpeerucred\fR(3C), \fBpriv_set\fR(3C), \fBsocket.h\fR(3HEAD),
289 \fBattributes\fR(5), \fBlabels\fR(5), \fBprivileges\fR(5)