sysv_ipc.c (cf9fa8e72541441be08abdd3a8475449da7d7995) | sysv_ipc.c (78525ce3185cb7196d629f4b1ec2fa2a5039129b) |
---|---|
1/* $FreeBSD$ */ 2/* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */ 3 4/* 5 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 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. 32 */ 33 34#include "opt_sysvipc.h" 35 36#include <sys/param.h> 37#include <sys/systm.h> | 1/* $FreeBSD$ */ 2/* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */ 3 4/* 5 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 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. 32 */ 33 34#include "opt_sysvipc.h" 35 36#include <sys/param.h> 37#include <sys/systm.h> |
38#include <sys/sem.h> 39#include <sys/shm.h> |
|
38#include <sys/ipc.h> 39#include <sys/proc.h> 40#include <sys/ucred.h> 41 | 40#include <sys/ipc.h> 41#include <sys/proc.h> 42#include <sys/ucred.h> 43 |
42#if defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG) | 44void (*semexit_hook)(struct proc *) = NULL; 45void (*shmfork_hook)(struct proc *, struct proc *) = NULL; 46void (*shmexit_hook)(struct proc *) = NULL; |
43 | 47 |
48/* called from kern_exit.c */ 49void 50semexit(p) 51 struct proc *p; 52{ 53 54 if (semexit_hook != NULL) 55 semexit_hook(p); 56 return; 57} 58 59/* called from kern_fork.c */ 60void 61shmfork(p1, p2) 62 struct proc *p1, *p2; 63{ 64 65 if (shmfork_hook != NULL) 66 shmfork_hook(p1, p2); 67 return; 68} 69 70/* called from kern_exit.c */ 71void 72shmexit(p) 73 struct proc *p; 74{ 75 76 if (shmexit_hook != NULL) 77 shmexit_hook(p); 78 return; 79} 80 |
|
44/* 45 * Check for ipc permission 46 */ 47 48int 49ipcperm(p, perm, mode) 50 struct proc *p; 51 struct ipc_perm *perm; --- 12 unchanged lines hidden (view full) --- 64 /* Check for `other' match. */ 65 mode >>= 3; 66 } 67 68 if (mode & IPC_M) 69 return (0); 70 return ((mode & perm->mode) == mode || suser(p) == 0 ? 0 : EACCES); 71} | 81/* 82 * Check for ipc permission 83 */ 84 85int 86ipcperm(p, perm, mode) 87 struct proc *p; 88 struct ipc_perm *perm; --- 12 unchanged lines hidden (view full) --- 101 /* Check for `other' match. */ 102 mode >>= 3; 103 } 104 105 if (mode & IPC_M) 106 return (0); 107 return ((mode & perm->mode) == mode || suser(p) == 0 ? 0 : EACCES); 108} |
72 73#endif /* defined(SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG) */ 74 75 76#if !defined(SYSVSEM) || !defined(SYSVSHM) || !defined(SYSVMSG) 77 78#include <sys/proc.h> 79#include <sys/sem.h> 80#include <sys/shm.h> 81#include <sys/syslog.h> 82#include <sys/sysproto.h> 83#include <sys/systm.h> 84 85static void sysv_nosys __P((struct proc *p, char *s)); 86 87static void 88sysv_nosys(p, s) 89 struct proc *p; 90 char *s; 91{ 92 log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n", 93 p->p_comm, p->p_pid, s); 94} 95 96#if !defined(SYSVSEM) 97 98/* 99 * SYSVSEM stubs 100 */ 101 102int 103semsys(p, uap) 104 struct proc *p; 105 struct semsys_args *uap; 106{ 107 sysv_nosys(p, "SYSVSEM"); 108 return nosys(p, (struct nosys_args *)uap); 109}; 110 111int 112__semctl(p, uap) 113 struct proc *p; 114 register struct __semctl_args *uap; 115{ 116 sysv_nosys(p, "SYSVSEM"); 117 return nosys(p, (struct nosys_args *)uap); 118}; 119 120int 121semget(p, uap) 122 struct proc *p; 123 register struct semget_args *uap; 124{ 125 sysv_nosys(p, "SYSVSEM"); 126 return nosys(p, (struct nosys_args *)uap); 127}; 128 129int 130semop(p, uap) 131 struct proc *p; 132 register struct semop_args *uap; 133{ 134 sysv_nosys(p, "SYSVSEM"); 135 return nosys(p, (struct nosys_args *)uap); 136}; 137 138/* called from kern_exit.c */ 139void 140semexit(p) 141 struct proc *p; 142{ 143 return; 144} 145 146#endif /* !defined(SYSVSEM) */ 147 148 149#if !defined(SYSVMSG) 150 151/* 152 * SYSVMSG stubs 153 */ 154 155int 156msgsys(p, uap) 157 struct proc *p; 158 /* XXX actually varargs. */ 159 struct msgsys_args *uap; 160{ 161 sysv_nosys(p, "SYSVMSG"); 162 return nosys(p, (struct nosys_args *)uap); 163}; 164 165int 166msgctl(p, uap) 167 struct proc *p; 168 register struct msgctl_args *uap; 169{ 170 sysv_nosys(p, "SYSVMSG"); 171 return nosys(p, (struct nosys_args *)uap); 172}; 173 174int 175msgget(p, uap) 176 struct proc *p; 177 register struct msgget_args *uap; 178{ 179 sysv_nosys(p, "SYSVMSG"); 180 return nosys(p, (struct nosys_args *)uap); 181}; 182 183int 184msgsnd(p, uap) 185 struct proc *p; 186 register struct msgsnd_args *uap; 187{ 188 sysv_nosys(p, "SYSVMSG"); 189 return nosys(p, (struct nosys_args *)uap); 190}; 191 192int 193msgrcv(p, uap) 194 struct proc *p; 195 register struct msgrcv_args *uap; 196{ 197 sysv_nosys(p, "SYSVMSG"); 198 return nosys(p, (struct nosys_args *)uap); 199}; 200 201#endif /* !defined(SYSVMSG) */ 202 203 204#if !defined(SYSVSHM) 205 206/* 207 * SYSVSHM stubs 208 */ 209 210int 211shmdt(p, uap) 212 struct proc *p; 213 struct shmdt_args *uap; 214{ 215 sysv_nosys(p, "SYSVSHM"); 216 return nosys(p, (struct nosys_args *)uap); 217}; 218 219int 220shmat(p, uap) 221 struct proc *p; 222 struct shmat_args *uap; 223{ 224 sysv_nosys(p, "SYSVSHM"); 225 return nosys(p, (struct nosys_args *)uap); 226}; 227 228int 229shmctl(p, uap) 230 struct proc *p; 231 struct shmctl_args *uap; 232{ 233 sysv_nosys(p, "SYSVSHM"); 234 return nosys(p, (struct nosys_args *)uap); 235}; 236 237int 238shmget(p, uap) 239 struct proc *p; 240 struct shmget_args *uap; 241{ 242 sysv_nosys(p, "SYSVSHM"); 243 return nosys(p, (struct nosys_args *)uap); 244}; 245 246int 247shmsys(p, uap) 248 struct proc *p; 249 /* XXX actually varargs. */ 250 struct shmsys_args *uap; 251{ 252 sysv_nosys(p, "SYSVSHM"); 253 return nosys(p, (struct nosys_args *)uap); 254}; 255 256/* called from kern_fork.c */ 257void 258shmfork(p1, p2) 259 struct proc *p1, *p2; 260{ 261 return; 262} 263 264/* called from kern_exit.c */ 265void 266shmexit(p) 267 struct proc *p; 268{ 269 return; 270} 271 272#endif /* !defined(SYSVSHM) */ 273 274#endif /* !defined(SYSVSEM) || !defined(SYSVSHM) || !defined(SYSVMSG) */ | |