MCPcopy Create free account
hub / github.com/F-Stack/f-stack / unp_internalize

Function unp_internalize

freebsd/kern/uipc_usrreq.c:2192–2387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2190}
2191
2192static int
2193unp_internalize(struct mbuf **controlp, struct thread *td)
2194{
2195 struct mbuf *control, **initial_controlp;
2196 struct proc *p;
2197 struct filedesc *fdesc;
2198 struct bintime *bt;
2199 struct cmsghdr *cm;
2200 struct cmsgcred *cmcred;
2201 struct filedescent *fde, **fdep, *fdev;
2202 struct file *fp;
2203 struct timeval *tv;
2204 struct timespec *ts;
2205 void *data;
2206 socklen_t clen, datalen;
2207 int i, j, error, *fdp, oldfds;
2208 u_int newlen;
2209
2210 UNP_LINK_UNLOCK_ASSERT();
2211
2212 p = td->td_proc;
2213 fdesc = p->p_fd;
2214 error = 0;
2215 control = *controlp;
2216 clen = control->m_len;
2217 *controlp = NULL;
2218 initial_controlp = controlp;
2219 for (cm = mtod(control, struct cmsghdr *); cm != NULL;) {
2220 if (sizeof(*cm) > clen || cm->cmsg_level != SOL_SOCKET
2221 || cm->cmsg_len > clen || cm->cmsg_len < sizeof(*cm)) {
2222 error = EINVAL;
2223 goto out;
2224 }
2225 data = CMSG_DATA(cm);
2226 datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data;
2227
2228 switch (cm->cmsg_type) {
2229 /*
2230 * Fill in credential information.
2231 */
2232 case SCM_CREDS:
2233 *controlp = sbcreatecontrol(NULL, sizeof(*cmcred),
2234 SCM_CREDS, SOL_SOCKET);
2235 if (*controlp == NULL) {
2236 error = ENOBUFS;
2237 goto out;
2238 }
2239 cmcred = (struct cmsgcred *)
2240 CMSG_DATA(mtod(*controlp, struct cmsghdr *));
2241 cmcred->cmcred_pid = p->p_pid;
2242 cmcred->cmcred_uid = td->td_ucred->cr_ruid;
2243 cmcred->cmcred_gid = td->td_ucred->cr_rgid;
2244 cmcred->cmcred_euid = td->td_ucred->cr_uid;
2245 cmcred->cmcred_ngroups = MIN(td->td_ucred->cr_ngroups,
2246 CMGROUP_MAX);
2247 for (i = 0; i < cmcred->cmcred_ngroups; i++)
2248 cmcred->cmcred_groups[i] =
2249 td->td_ucred->cr_groups[i];

Callers 1

uipc_sendFunction · 0.85

Calls 12

sbcreatecontrolFunction · 0.85
fget_lockedFunction · 0.85
fholdFunction · 0.85
mallocFunction · 0.85
filecaps_copyFunction · 0.85
unp_internalize_fpFunction · 0.85
microtimeFunction · 0.85
nanotimeFunction · 0.85
nanouptimeFunction · 0.85
bintimeClass · 0.70
m_freemFunction · 0.70

Tested by

no test coverage detected