uipc_usrreq.c (23081) | uipc_usrreq.c (24083) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 |
34 * $Id: uipc_usrreq.c,v 1.19 1997/02/22 09:39:29 peter Exp $ | 34 * $Id: uipc_usrreq.c,v 1.20 1997/02/24 20:30:58 wollman Exp $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/queue.h> 39#include <sys/systm.h> 40#include <sys/kernel.h> 41#include <sys/domain.h> 42#include <sys/file.h> --- 649 unchanged lines hidden (view full) --- 692 p->p_fd->fd_ofiles[f] = fp; 693 fp->f_msgcount--; 694 unp_rights--; 695 *(int *)rp++ = f; 696 } 697 return (0); 698} 699 | 35 */ 36 37#include <sys/param.h> 38#include <sys/queue.h> 39#include <sys/systm.h> 40#include <sys/kernel.h> 41#include <sys/domain.h> 42#include <sys/file.h> --- 649 unchanged lines hidden (view full) --- 692 p->p_fd->fd_ofiles[f] = fp; 693 fp->f_msgcount--; 694 unp_rights--; 695 *(int *)rp++ = f; 696 } 697 return (0); 698} 699 |
700#ifndef MIN 701#define MIN(a,b) (((a)<(b))?(a):(b)) 702#endif 703 |
|
700static int 701unp_internalize(control, p) 702 struct mbuf *control; 703 struct proc *p; 704{ 705 struct filedesc *fdp = p->p_fd; 706 register struct cmsghdr *cm = mtod(control, struct cmsghdr *); 707 register struct file **rp; 708 register struct file *fp; 709 register int i, fd; | 704static int 705unp_internalize(control, p) 706 struct mbuf *control; 707 struct proc *p; 708{ 709 struct filedesc *fdp = p->p_fd; 710 register struct cmsghdr *cm = mtod(control, struct cmsghdr *); 711 register struct file **rp; 712 register struct file *fp; 713 register int i, fd; |
714 register struct cmsgcred *cmcred; |
|
710 int oldfds; 711 | 715 int oldfds; 716 |
712 if (cm->cmsg_type != SCM_RIGHTS || cm->cmsg_level != SOL_SOCKET || 713 cm->cmsg_len != control->m_len) | 717 if ((cm->cmsg_type != SCM_RIGHTS && cm->cmsg_type != SCM_CREDS) || 718 cm->cmsg_level != SOL_SOCKET || cm->cmsg_len != control->m_len) |
714 return (EINVAL); | 719 return (EINVAL); |
720 721 /* 722 * Fill in credential information. 723 */ 724 if (cm->cmsg_type == SCM_CREDS) { 725 cmcred = (struct cmsgcred *)(cm + 1); 726 cmcred->cmcred_pid = p->p_pid; 727 cmcred->cmcred_uid = p->p_cred->p_ruid; 728 cmcred->cmcred_gid = p->p_cred->p_rgid; 729 cmcred->cmcred_euid = p->p_ucred->cr_uid; 730 cmcred->cmcred_ngroups = MIN(p->p_ucred->cr_ngroups, 731 CMGROUP_MAX); 732 for (i = 0; i < cmcred->cmcred_ngroups; i++) 733 cmcred->cmcred_groups[i] = p->p_ucred->cr_groups[i]; 734 return(0); 735 } 736 |
|
715 oldfds = (cm->cmsg_len - sizeof (*cm)) / sizeof (int); 716 /* 717 * check that all the FDs passed in refer to legal OPEN files 718 * If not, reject the entire operation. 719 */ 720 rp = (struct file **)(cm + 1); 721 for (i = 0; i < oldfds; i++) { 722 fd = *(int *)rp++; --- 242 unchanged lines hidden --- | 737 oldfds = (cm->cmsg_len - sizeof (*cm)) / sizeof (int); 738 /* 739 * check that all the FDs passed in refer to legal OPEN files 740 * If not, reject the entire operation. 741 */ 742 rp = (struct file **)(cm + 1); 743 for (i = 0; i < oldfds; i++) { 744 fd = *(int *)rp++; --- 242 unchanged lines hidden --- |