1 /* $FreeBSD: src/sys/kern/sysv_ipc.c,v 1.13.2.2 2000/07/01 14:33:49 bsd Exp $ */
2 /* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */
5 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Herb Peyerl.
19 * 4. The name of Herb Peyerl may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "opt_sysvipc.h"
36 #include <sys/param.h>
39 #include <sys/ucred.h>
41 #if defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG)
44 * Check for ipc permission
48 ipcperm(p, perm, mode)
50 struct ipc_perm *perm;
53 struct ucred *cred = p->p_ucred;
55 /* Check for user match. */
56 if (cred->cr_uid != perm->cuid && cred->cr_uid != perm->uid) {
58 return (suser(p) == 0 ? 0 : EPERM);
59 /* Check for group match. */
61 if (!groupmember(perm->gid, cred) &&
62 !groupmember(perm->cgid, cred))
63 /* Check for `other' match. */
69 return ((mode & perm->mode) == mode || suser(p) == 0 ? 0 : EACCES);
72 #endif /* defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG) */
75 #if !defined(SYSVSEM) || !defined(SYSVSHM) || !defined(SYSVMSG)
80 #include <sys/syslog.h>
81 #include <sys/sysproto.h>
82 #include <sys/systm.h>
84 static void sysv_nosys __P((struct proc *p, char *s));
91 log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
92 p->p_comm, p->p_pid, s);
104 struct semsys_args *uap;
106 sysv_nosys(p, "SYSVSEM");
107 return nosys(p, (struct nosys_args *)uap);
113 register struct __semctl_args *uap;
115 sysv_nosys(p, "SYSVSEM");
116 return nosys(p, (struct nosys_args *)uap);
122 register struct semget_args *uap;
124 sysv_nosys(p, "SYSVSEM");
125 return nosys(p, (struct nosys_args *)uap);
131 register struct semop_args *uap;
133 sysv_nosys(p, "SYSVSEM");
134 return nosys(p, (struct nosys_args *)uap);
137 /* called from kern_exit.c */
145 #endif /* !defined(SYSVSEM) */
148 #if !defined(SYSVMSG)
157 /* XXX actually varargs. */
158 struct msgsys_args *uap;
160 sysv_nosys(p, "SYSVMSG");
161 return nosys(p, (struct nosys_args *)uap);
167 register struct msgctl_args *uap;
169 sysv_nosys(p, "SYSVMSG");
170 return nosys(p, (struct nosys_args *)uap);
176 register struct msgget_args *uap;
178 sysv_nosys(p, "SYSVMSG");
179 return nosys(p, (struct nosys_args *)uap);
185 register struct msgsnd_args *uap;
187 sysv_nosys(p, "SYSVMSG");
188 return nosys(p, (struct nosys_args *)uap);
194 register struct msgrcv_args *uap;
196 sysv_nosys(p, "SYSVMSG");
197 return nosys(p, (struct nosys_args *)uap);
200 #endif /* !defined(SYSVMSG) */
203 #if !defined(SYSVSHM)
212 struct shmdt_args *uap;
214 sysv_nosys(p, "SYSVSHM");
215 return nosys(p, (struct nosys_args *)uap);
221 struct shmat_args *uap;
223 sysv_nosys(p, "SYSVSHM");
224 return nosys(p, (struct nosys_args *)uap);
230 struct shmctl_args *uap;
232 sysv_nosys(p, "SYSVSHM");
233 return nosys(p, (struct nosys_args *)uap);
239 struct shmget_args *uap;
241 sysv_nosys(p, "SYSVSHM");
242 return nosys(p, (struct nosys_args *)uap);
248 /* XXX actually varargs. */
249 struct shmsys_args *uap;
251 sysv_nosys(p, "SYSVSHM");
252 return nosys(p, (struct nosys_args *)uap);
255 /* called from kern_fork.c */
258 struct proc *p1, *p2;
263 /* called from kern_exit.c */
271 #endif /* !defined(SYSVSHM) */
273 #endif /* !defined(SYSVSEM) || !defined(SYSVSHM) || !defined(SYSVMSG) */