modules: disable dummy module declarations
[dragonfly.git] / sys / kern / sysv_ipc.c
blob7648f93094acd13abf7b1e236494cbc15c3de15d
1 /* $FreeBSD: src/sys/kern/sysv_ipc.c,v 1.13.2.2 2000/07/01 14:33:49 bsd Exp $ */
2 /* $DragonFly: src/sys/kern/sysv_ipc.c,v 1.8 2005/10/08 14:31:26 corecode Exp $ */
3 /* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */
5 /*
6 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Herb Peyerl.
20 * 4. The name of Herb Peyerl may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "opt_sysvipc.h"
37 #include <sys/param.h>
38 #include <sys/ipc.h>
39 #include <sys/proc.h>
40 #include <sys/priv.h>
41 #include <sys/ucred.h>
43 #if defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG)
46 * Check for ipc permission
49 int
50 ipcperm(struct proc *p, struct ipc_perm *perm, int mode)
52 struct ucred *cred = p->p_ucred;
54 /* Check for user match. */
55 if (cred->cr_uid != perm->cuid && cred->cr_uid != perm->uid) {
56 if (mode & IPC_M)
57 return (priv_check_cred(cred, PRIV_ROOT, 0) == 0 ? 0 : EPERM);
58 /* Check for group match. */
59 mode >>= 3;
60 if (!groupmember(perm->gid, cred) &&
61 !groupmember(perm->cgid, cred))
62 /* Check for `other' match. */
63 mode >>= 3;
66 if (mode & IPC_M)
67 return (0);
68 return ((mode & perm->mode) == mode ||
69 priv_check_cred(cred, PRIV_ROOT, 0) == 0 ? 0 : EACCES);
72 #endif /* defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG) */
75 #if !defined(SYSVSEM) || !defined(SYSVSHM) || !defined(SYSVMSG)
77 #include <sys/proc.h>
78 #include <sys/sem.h>
79 #include <sys/shm.h>
80 #include <sys/syslog.h>
81 #include <sys/sysproto.h>
82 #include <sys/systm.h>
84 static void sysv_nosys (char *s);
86 static void
87 sysv_nosys(char *s)
89 struct thread *td = curthread;
90 struct proc *p = td->td_proc;
92 log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
93 (p ? p->p_comm : td->td_comm),
94 (p ? p->p_pid : -1), s);
97 #if !defined(SYSVSEM)
100 * SYSVSEM stubs
104 semsys(struct semsys_args *uap)
106 sysv_nosys("SYSVSEM");
107 return nosys((struct nosys_args *)uap);
111 __semctl(struct __semctl_args *uap)
113 sysv_nosys("SYSVSEM");
114 return nosys((struct nosys_args *)uap);
118 semget(struct semget_args *uap)
120 sysv_nosys("SYSVSEM");
121 return nosys((struct nosys_args *)uap);
125 semop(struct semop_args *uap)
127 sysv_nosys("SYSVSEM");
128 return nosys((struct nosys_args *)uap);
131 /* called from kern_exit.c */
132 void
133 semexit(struct proc *p)
135 /* empty */
138 #endif /* !defined(SYSVSEM) */
141 #if !defined(SYSVMSG)
144 * SYSVMSG stubs
146 * note: msgsys args actually var-args? YYYY
150 msgsys(struct msgsys_args *uap)
152 sysv_nosys("SYSVMSG");
153 return nosys((struct nosys_args *)uap);
157 msgctl(struct msgctl_args *uap)
159 sysv_nosys("SYSVMSG");
160 return nosys((struct nosys_args *)uap);
164 msgget(struct msgget_args *uap)
166 sysv_nosys("SYSVMSG");
167 return nosys((struct nosys_args *)uap);
171 msgsnd(struct msgsnd_args *uap)
173 sysv_nosys("SYSVMSG");
174 return nosys((struct nosys_args *)uap);
178 msgrcv(struct msgrcv_args *uap)
180 sysv_nosys("SYSVMSG");
181 return nosys((struct nosys_args *)uap);
184 #endif /* !defined(SYSVMSG) */
187 #if !defined(SYSVSHM)
190 * SYSVSHM stubs
194 shmdt(struct shmdt_args *uap)
196 sysv_nosys("SYSVSHM");
197 return nosys((struct nosys_args *)uap);
201 shmat(struct shmat_args *uap)
203 sysv_nosys("SYSVSHM");
204 return nosys((struct nosys_args *)uap);
208 shmctl(struct shmctl_args *uap)
210 sysv_nosys("SYSVSHM");
211 return nosys((struct nosys_args *)uap);
215 shmget(struct shmget_args *uap)
217 sysv_nosys("SYSVSHM");
218 return nosys((struct nosys_args *)uap);
221 /* XXX actually varargs. */
223 shmsys(struct shmsys_args *uap)
225 sysv_nosys("SYSVSHM");
226 return nosys((struct nosys_args *)uap);
229 /* called from kern_fork.c */
230 void
231 shmfork(struct proc *p1, struct proc *p2)
233 /* empty */
236 /* called from kern_exit.c */
237 void
238 shmexit(struct vmspace *vm)
240 /* empty */
243 #endif /* !defined(SYSVSHM) */
245 #endif /* !defined(SYSVSEM) || !defined(SYSVSHM) || !defined(SYSVMSG) */