1ucred_get(3C) Standard C Library Functions ucred_get(3C)
2
3
4
6 ucred_get, ucred_free, ucred_geteuid, ucred_getruid, ucred_getsuid,
7 ucred_getegid, ucred_getrgid, ucred_getsgid, ucred_getgroups,
8 ucred_getprivset, ucred_getpid, ucred_getprojid, ucred_getzoneid,
9 ucred_getpflags, ucred_getlabel, ucred_size - user credential functions
10
12 #include <ucred.h>
13
14 ucred_t *ucred_get(pid_t pid);
15
16
17 void ucred_free(ucred_t *uc);
18
19
20 uid_t ucred_geteuid(const ucred_t *uc);
21
22
23 uid_t ucred_getruid(const ucred_t *uc);
24
25
26 uid_t ucred_getsuid(const ucred_t *uc);
27
28
29 gid_t ucred_getegid(const ucred_t *uc);
30
31
32 gid_t ucred_getrgid(const ucred_t *uc);
33
34
35 gid_t ucred_getsgid(const ucred_t *uc);
36
37
38 int ucred_getgroups(const ucred_t *uc, const gid_t **groups);
39
40
41 const priv_set_t *ucred_getprivset(const ucred_t *uc,
42 priv_ptype_t set);
43
44
45 pid_t ucred_getpid(const ucred_t *uc);
46
47
48 projid_t ucred_getprojid(const ucred_t *uc);
49
50
51 zoneid_t ucred_getzoneid(const ucred_t *uc);
52
53
54 uint_t ucred_getpflags(const ucred_t *uc, uint_t flags);
55
56
57 m_label_t *ucred_getlabel(const ucred_t *uc);
58
59
60 size_t ucred_size(void);
61
62
64 These functions return or act on a user credential, ucred_t. User cre‐
65 dentials are returned by various functions and describe the credentials
66 of a process. Information about the process can then be obtained by
67 calling the access functions. Access functions can fail if the underly‐
68 ing mechanism did not return sufficient information.
69
70
71 The ucred_get() function returns the user credential of the specified
72 pid or NULL if none can be obtained. A pid value of P_MYID returns
73 information about the calling process. The return value is dynamically
74 allocated and must be freed using ucred_free().
75
76
77 The ucred_geteuid(), ucred_getruid(), ucred_getsuid(), ucred_getegid(),
78 ucred_getrgid(), and ucred_getsgid() functions return the effective
79 UID, real UID, saved UID, effective GID, real GID, saved GID, respec‐
80 tively, or -1 if the user credential does not contain sufficient infor‐
81 mation.
82
83
84 The ucred_getgroups() function stores a pointer to the group list in
85 the gid_t * pointed to by the second argument and returns the number of
86 groups in the list. It returns -1 if the information is not available.
87 The returned group list is valid until ucred_free() is called on the
88 user credential given as argument.
89
90
91 The ucred_getpid() function returns the process ID of the process or -1
92 if the process ID is not available. The process ID returned in a user
93 credential is only guaranteed to be correct in a very limited number of
94 cases when returned by door_ucred(3C) and ucred_get(). In all other
95 cases, the process in question might have handed of the file descrip‐
96 tor, the process might have exited or executed another program, or the
97 process ID might have been reused by a completely unrelated process
98 after the original program exited.
99
100
101 The ucred_getprojid() function returns the project ID of the process or
102 -1 if the project ID is not available.
103
104
105 The ucred_getzoneid() function returns the zone ID of the process or −1
106 if the zone ID is not available.
107
108
109 The ucred_getprivset() function returns the specified privilege set
110 specified as second argument, or NULL if either the requested informa‐
111 tion is not available or the privilege set name is invalid. The
112 returned privilege set is valid until ucred_free() is called on the
113 specified user credential.
114
115
116 The ucred_getpflags() function returns the value of the specified priv‐
117 ilege flags from the ucred structure, or (uint_t)-1 if none was
118 present.
119
120
121 The ucred_getlabel() function returns the value of the label, or NULL
122 if the label is not available. The returned label is valid until
123 ucred_free() is called on the specified user credential. This function
124 is available only if the system is configured with Trusted Extensions.
125
126
127 The ucred_free() function frees the memory allocated for the specified
128 user credential.
129
130
131 The ucred_size() function returns sizeof(ucred_t). This value is con‐
132 stant only until the next boot, at which time it could change. The
133 ucred_size() function can be used to determine the size of the buffer
134 needed to receive a credential option with SO_RECVUCRED. See
135 socket.h(3HEAD).
136
138 See DESCRIPTION.
139
141 The ucred_get() function will fail if:
142
143 EAGAIN There is not enough memory available to allocate sufficient
144 memory to hold a user credential. The application can try
145 again later.
146
147
148 EACCES The caller does not have sufficient privileges to examine the
149 target process.
150
151
152 EMFILE The calling process cannot open any more files.
153 ENFILE
154
155 ENOMEM The physical limits of the system are exceeded by the memory
156 allocation needed to hold a user credential.
157
158
159 ESRCH The target process does not exist.
160
161
162
163 The ucred_getprivset() function will fail if:
164
165 EINVAL The privilege set argument is invalid.
166
167
168
169 The ucred_getlabel() function will fail if:
170
171 EINVAL The label is not present.
172
173
174
175 The ucred_geteuid(), ucred_getruid(), ucred_getsuid(), ucred_getegid(),
176 ucred_getrgid(), ucred_getsgid(), ucred_getgroups(), ucred_getpflags(),
177 ucred_getprivset(), ucred_getprojid(), ucred_getpid(), and ucred_getla‐
178 bel() functions will fail if:
179
180 EINVAL The requested user credential attribute is not available in
181 the specified user credential.
182
183
185 See attributes(5) for descriptions of the following attributes:
186
187
188
189
190 ┌─────────────────────────────┬─────────────────────────────┐
191 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
192 ├─────────────────────────────┼─────────────────────────────┤
193 │Interface Stability │Committed │
194 ├─────────────────────────────┼─────────────────────────────┤
195 │MT-Level │MT-Safe │
196 └─────────────────────────────┴─────────────────────────────┘
197
199 getpflags(2), getppriv(2), door_ucred(3C), getpeerucred(3C),
200 priv_set(3C), socket.h(3HEAD), attributes(5), labels(5), privileges(5)
201
202
203
204SunOS 5.11 4 Apr 2008 ucred_get(3C)