]>
git.saurik.com Git - apple/xnu.git/blob - bsd/kern/sysv_ipc.c
321125c84f835bfa11d763a059ade08cc1fe6735
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */
25 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
26 * All rights reserved.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by Herb Peyerl.
39 * 4. The name of Herb Peyerl may not be used to endorse or promote products
40 * derived from this software without specific prior written permission.
42 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
43 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
44 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
45 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
46 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
48 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
49 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
51 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 #include <sys/param.h>
57 #include <sys/ucred.h>
61 * Check for ipc permission
63 * XXX: Should pass proc argument so that we can pass
64 * XXX: proc->p_acflag to suser()
68 ipcperm(cred
, perm
, mode
)
70 struct ipc_perm
*perm
;
74 if (suser(cred
, (u_short
*)NULL
))
77 /* Check for user match. */
78 if (cred
->cr_uid
!= perm
->cuid
&& cred
->cr_uid
!= perm
->uid
) {
81 /* Check for group match. */
83 if (!groupmember(perm
->gid
, cred
) &&
84 !groupmember(perm
->cgid
, cred
))
85 /* Check for `other' match. */
91 return ((mode
& perm
->mode
) == mode
? 0 : EACCES
);
105 struct semsys_args
*uap
;
117 struct semconfig_args
*uap
;
129 register struct semctl_args
*uap
;
141 register struct semget_args
*uap
;
153 register struct semop_args
*uap
;
161 /* called from kern_exit.c */
179 /* XXX actually varargs. */
181 struct msgsys_args
*uap
;
193 register struct msgctl_args
*uap
;
205 register struct msgget_args
*uap
;
217 register struct msgsnd_args
*uap
;
229 register struct msgrcv_args
*uap
;