|
|
1.1 ! root 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 <[email protected]> ! 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: ! 67: int ! 68: ipcperm(cred, perm, mode) ! 69: struct ucred *cred; ! 70: struct ipc_perm *perm; ! 71: int mode; ! 72: { ! 73: ! 74: if (suser(cred, (u_short *)NULL)) ! 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: ! 96: ! 97: /* ! 98: * SYSVSEM stubs ! 99: */ ! 100: ! 101: int ! 102: semsys(p, uap) ! 103: struct proc *p; ! 104: #if 0 ! 105: struct semsys_args *uap; ! 106: #else ! 107: void *uap; ! 108: #endif ! 109: { ! 110: return(EOPNOTSUPP); ! 111: }; ! 112: ! 113: int ! 114: semconfig(p, uap) ! 115: struct proc *p; ! 116: #if 0 ! 117: struct semconfig_args *uap; ! 118: #else ! 119: void *uap; ! 120: #endif ! 121: { ! 122: return(EOPNOTSUPP); ! 123: }; ! 124: ! 125: int ! 126: semctl(p, uap) ! 127: struct proc *p; ! 128: #if 0 ! 129: register struct semctl_args *uap; ! 130: #else ! 131: void *uap; ! 132: #endif ! 133: { ! 134: return(EOPNOTSUPP); ! 135: }; ! 136: ! 137: int ! 138: semget(p, uap) ! 139: struct proc *p; ! 140: #if 0 ! 141: register struct semget_args *uap; ! 142: #else ! 143: void *uap; ! 144: #endif ! 145: { ! 146: return(EOPNOTSUPP); ! 147: }; ! 148: ! 149: int ! 150: semop(p, uap) ! 151: struct proc *p; ! 152: #if 0 ! 153: register struct semop_args *uap; ! 154: #else ! 155: void *uap; ! 156: #endif ! 157: { ! 158: return(EOPNOTSUPP); ! 159: }; ! 160: ! 161: /* called from kern_exit.c */ ! 162: void ! 163: semexit(p) ! 164: struct proc *p; ! 165: { ! 166: return; ! 167: } ! 168: ! 169: ! 170: ! 171: ! 172: /* ! 173: * SYSVMSG stubs ! 174: */ ! 175: ! 176: int ! 177: msgsys(p, uap) ! 178: struct proc *p; ! 179: /* XXX actually varargs. */ ! 180: #if 0 ! 181: struct msgsys_args *uap; ! 182: #else ! 183: void *uap; ! 184: #endif ! 185: { ! 186: return(EOPNOTSUPP); ! 187: }; ! 188: ! 189: int ! 190: msgctl(p, uap) ! 191: struct proc *p; ! 192: #if 0 ! 193: register struct msgctl_args *uap; ! 194: #else ! 195: void *uap; ! 196: #endif ! 197: { ! 198: return(EOPNOTSUPP); ! 199: }; ! 200: ! 201: int ! 202: msgget(p, uap) ! 203: struct proc *p; ! 204: #if 0 ! 205: register struct msgget_args *uap; ! 206: #else ! 207: void *uap; ! 208: #endif ! 209: { ! 210: return(EOPNOTSUPP); ! 211: }; ! 212: ! 213: int ! 214: msgsnd(p, uap) ! 215: struct proc *p; ! 216: #if 0 ! 217: register struct msgsnd_args *uap; ! 218: #else ! 219: void *uap; ! 220: #endif ! 221: { ! 222: return(EOPNOTSUPP); ! 223: }; ! 224: ! 225: int ! 226: msgrcv(p, uap) ! 227: struct proc *p; ! 228: #if 0 ! 229: register struct msgrcv_args *uap; ! 230: #else ! 231: void *uap; ! 232: #endif ! 233: { ! 234: return(EOPNOTSUPP); ! 235: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.