]> git.saurik.com Git - apple/xnu.git/blame - bsd/kern/sysv_ipc.c
xnu-344.tar.gz
[apple/xnu.git] / bsd / kern / sysv_ipc.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */
23
24/*
25 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
26 * All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
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.
41 *
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.
52 */
53
54
55#include <sys/param.h>
56#include <sys/ipc.h>
57#include <sys/ucred.h>
58
59
60/*
61 * Check for ipc permission
62 *
63 * XXX: Should pass proc argument so that we can pass
64 * XXX: proc->p_acflag to suser()
65 */
66
67int
68ipcperm(cred, perm, mode)
69 struct ucred *cred;
70 struct ipc_perm *perm;
71 int mode;
72{
73
9bccf70c 74 if (!suser(cred, (u_short *)NULL))
1c79356b
A
75 return (0);
76
77 /* Check for user match. */
78 if (cred->cr_uid != perm->cuid && cred->cr_uid != perm->uid) {
79 if (mode & IPC_M)
80 return (EPERM);
81 /* Check for group match. */
82 mode >>= 3;
83 if (!groupmember(perm->gid, cred) &&
84 !groupmember(perm->cgid, cred))
85 /* Check for `other' match. */
86 mode >>= 3;
87 }
88
89 if (mode & IPC_M)
90 return (0);
91 return ((mode & perm->mode) == mode ? 0 : EACCES);
92}
93
94
95
1c79356b
A
96/*
97 * SYSVMSG stubs
98 */
99
100int
101msgsys(p, uap)
102 struct proc *p;
103 /* XXX actually varargs. */
104#if 0
105 struct msgsys_args *uap;
106#else
107 void *uap;
108#endif
109{
110 return(EOPNOTSUPP);
111};
112
113int
114msgctl(p, uap)
115 struct proc *p;
116#if 0
117 register struct msgctl_args *uap;
118#else
119 void *uap;
120#endif
121{
122 return(EOPNOTSUPP);
123};
124
125int
126msgget(p, uap)
127 struct proc *p;
128#if 0
129 register struct msgget_args *uap;
130#else
131 void *uap;
132#endif
133{
134 return(EOPNOTSUPP);
135};
136
137int
138msgsnd(p, uap)
139 struct proc *p;
140#if 0
141 register struct msgsnd_args *uap;
142#else
143 void *uap;
144#endif
145{
146 return(EOPNOTSUPP);
147};
148
149int
150msgrcv(p, uap)
151 struct proc *p;
152#if 0
153 register struct msgrcv_args *uap;
154#else
155 void *uap;
156#endif
157{
158 return(EOPNOTSUPP);
159};