FreeBSD Bugzilla – Attachment 15993 Details for
Bug 29499
it is not possible to send creditionals and descriptors in one message through AF_UNIX socket
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 5.51 KB, created by
vova
on 2001-08-07 16:30:05 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
vova
Created:
2001-08-07 16:30:05 UTC
Size:
5.51 KB
patch
obsolete
>--- /usr/src/sys/kern/uipc_usrreq.c.orig Thu May 10 11:56:25 2001 >+++ /usr/src/sys/kern/uipc_usrreq.c Sun Aug 5 17:37:32 2001 >@@ -897,6 +901,8 @@ > } > return (EMSGSIZE); > } >+ >+#if 0 > /* > * now change each pointer to an fd in the global table to > * an integer that is the index to the local fd table entry >@@ -909,6 +915,7 @@ > * do it in reverse order. > */ > if (sizeof (struct file *) >= sizeof (int)) { >+#endif > fdp = (int *)(cm + 1); > rp = (struct file **)CMSG_DATA(cm); > for (i = 0; i < newfds; i++) { >@@ -920,6 +927,7 @@ > unp_rights--; > *fdp++ = f; > } >+#if 0 > } else { > fdp = (int *)(cm + 1) + newfds - 1; > rp = (struct file **)CMSG_DATA(cm) + newfds - 1; >@@ -940,6 +948,7 @@ > */ > cm->cmsg_len = CMSG_LEN(newfds * sizeof(int)); > rights->m_len = cm->cmsg_len; >+#endif > return (0); > } > >@@ -969,40 +978,56 @@ > register int i, fd, *fdp; > register struct cmsgcred *cmcred; > int oldfds; >- u_int newlen; >+/* u_int newlen; */ >+ struct cmsghdr *cmend; > >+#if 0 > if ((cm->cmsg_type != SCM_RIGHTS && cm->cmsg_type != SCM_CREDS) || >- cm->cmsg_level != SOL_SOCKET || cm->cmsg_len != control->m_len) >+ cm->cmsg_level != SOL_SOCKET || cm->cmsg_len != control->m_len) { >+uprintf("cmsg_type %d, cmsg_level %d, cmsg_len %d, m_len %d\n", cm->cmsg_type, cm->cmsg_level, cm->cmsg_len, control->m_len); >+ return (EINVAL); >+ } >+#else >+ if (cm->cmsg_level != SOL_SOCKET) { > return (EINVAL); >+ } >+#endif > >+ cmend = (struct cmsghdr *)(((char*)cm) + control->m_len); >+ for(; cm < cmend; >+ cm = (struct cmsghdr *)(((char*)cm)+cm->cmsg_len)) { > /* > * Fill in credential information. > */ >- if (cm->cmsg_type == SCM_CREDS) { >- cmcred = (struct cmsgcred *)(cm + 1); >- cmcred->cmcred_pid = p->p_pid; >- cmcred->cmcred_uid = p->p_cred->p_ruid; >- cmcred->cmcred_gid = p->p_cred->p_rgid; >- cmcred->cmcred_euid = p->p_ucred->cr_uid; >- cmcred->cmcred_ngroups = MIN(p->p_ucred->cr_ngroups, >+/*uprintf("cm = %p, cmsg_type = %d\n", cm, cm->cmsg_type);*/ >+ switch(cm->cmsg_type) { >+ case SCM_CREDS: >+ cmcred = (struct cmsgcred *)(cm + 1); >+ cmcred->cmcred_pid = p->p_pid; >+ cmcred->cmcred_uid = p->p_cred->p_ruid; >+ cmcred->cmcred_gid = p->p_cred->p_rgid; >+ cmcred->cmcred_euid = p->p_ucred->cr_uid; >+ cmcred->cmcred_ngroups = MIN(p->p_ucred->cr_ngroups, > CMGROUP_MAX); >- for (i = 0; i < cmcred->cmcred_ngroups; i++) >- cmcred->cmcred_groups[i] = p->p_ucred->cr_groups[i]; >- return(0); >- } >+ for (i = 0; i < cmcred->cmcred_ngroups; i++) >+ cmcred->cmcred_groups[i] = p->p_ucred->cr_groups[i]; >+ break; >+ case SCM_RIGHTS: > >- oldfds = (cm->cmsg_len - sizeof (*cm)) / sizeof (int); >- /* >- * check that all the FDs passed in refer to legal OPEN files >- * If not, reject the entire operation. >- */ >- fdp = (int *)(cm + 1); >- for (i = 0; i < oldfds; i++) { >- fd = *fdp++; >- if ((unsigned)fd >= fdescp->fd_nfiles || >- fdescp->fd_ofiles[fd] == NULL) >- return (EBADF); >- } >+ oldfds = (cm->cmsg_len - sizeof (*cm)) / sizeof (int); >+ /* >+ * check that all the FDs passed in refer to legal OPEN files >+ * If not, reject the entire operation. >+ */ >+ fdp = (int *)(cm + 1); >+ for (i = 0; i < oldfds; i++) { >+ fd = *fdp++; >+ if ((unsigned)fd >= fdescp->fd_nfiles || >+ fdescp->fd_ofiles[fd] == NULL) >+ return (EBADF); >+ } >+ >+#if 0 > /* > * Now replace the integer FDs with pointers to > * the associated global file table entry.. >@@ -1010,6 +1035,7 @@ > * enough, return E2BIG. > */ > newlen = CMSG_LEN(oldfds * sizeof(struct file *)); >+/*uprintf("newlen %d, m_len %d\n", newlen, control->m_len);*/ > if (newlen > MCLBYTES) > return (E2BIG); > if (newlen - control->m_len > M_TRAILINGSPACE(control)) { >@@ -1029,34 +1055,42 @@ > * differs. > */ > control->m_len = cm->cmsg_len = newlen; >+#endif > >- /* >- * Transform the file descriptors into struct file pointers. >- * If sizeof (struct file *) is bigger than or equal to sizeof int, >- * then do it in reverse order so that the int won't get until >- * we're done. >- * If sizeof (struct file *) is smaller than sizeof int, then >- * do it in forward order. >- */ >- if (sizeof (struct file *) >= sizeof (int)) { >- fdp = (int *)(cm + 1) + oldfds - 1; >- rp = (struct file **)CMSG_DATA(cm) + oldfds - 1; >- for (i = 0; i < oldfds; i++) { >- fp = fdescp->fd_ofiles[*fdp--]; >- *rp-- = fp; >- fp->f_count++; >- fp->f_msgcount++; >- unp_rights++; >- } >- } else { >- fdp = (int *)(cm + 1); >- rp = (struct file **)CMSG_DATA(cm); >- for (i = 0; i < oldfds; i++) { >- fp = fdescp->fd_ofiles[*fdp++]; >- *rp++ = fp; >- fp->f_count++; >- fp->f_msgcount++; >- unp_rights++; >+#if 0 >+ /* >+ * Transform the file descriptors into struct file pointers. >+ * If sizeof (struct file *) is bigger than or equal to sizeof int, >+ * then do it in reverse order so that the int won't get until >+ * we're done. >+ * If sizeof (struct file *) is smaller than sizeof int, then >+ * do it in forward order. >+ */ >+ if (sizeof (struct file *) >= sizeof (int)) { >+#endif >+ fdp = (int *)(cm + 1) + oldfds - 1; >+ rp = (struct file **)CMSG_DATA(cm) + oldfds - 1; >+ for (i = 0; i < oldfds; i++) { >+ fp = fdescp->fd_ofiles[*fdp--]; >+ *rp-- = fp; >+ fp->f_count++; >+ fp->f_msgcount++; >+ unp_rights++; >+ } >+#if 0 >+ } else { >+ fdp = (int *)(cm + 1); >+ rp = (struct file **)CMSG_DATA(cm); >+ for (i = 0; i < oldfds; i++) { >+ fp = fdescp->fd_ofiles[*fdp++]; >+ *rp++ = fp; >+ fp->f_count++; >+ fp->f_msgcount++; >+ unp_rights++; >+ } >+ } >+#endif >+ break; > } > } > return (0);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 29499
: 15993