sysv_msg.c (46112) | sysv_msg.c (46116) |
---|---|
1/* $Id: sysv_msg.c,v 1.20 1999/04/21 13:30:01 sada Exp $ */ | 1/* $Id: sysv_msg.c,v 1.21 1999/04/27 11:16:16 phk Exp $ */ |
2 3/* 4 * Implementation of SVID messages 5 * 6 * Author: Daniel Boulet 7 * 8 * Copyright 1993 Daniel Boulet and RTMX Inc. 9 * --- 163 unchanged lines hidden (view full) --- 173int 174msgctl(p, uap) 175 struct proc *p; 176 register struct msgctl_args *uap; 177{ 178 int msqid = uap->msqid; 179 int cmd = uap->cmd; 180 struct msqid_ds *user_msqptr = uap->buf; | 2 3/* 4 * Implementation of SVID messages 5 * 6 * Author: Daniel Boulet 7 * 8 * Copyright 1993 Daniel Boulet and RTMX Inc. 9 * --- 163 unchanged lines hidden (view full) --- 173int 174msgctl(p, uap) 175 struct proc *p; 176 register struct msgctl_args *uap; 177{ 178 int msqid = uap->msqid; 179 int cmd = uap->cmd; 180 struct msqid_ds *user_msqptr = uap->buf; |
181 struct ucred *cred = p->p_ucred; | |
182 int rval, eval; 183 struct msqid_ds msqbuf; 184 register struct msqid_ds *msqptr; 185 186#ifdef MSG_DEBUG_OK 187 printf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr); 188#endif 189 --- 25 unchanged lines hidden (view full) --- 215 eval = 0; 216 rval = 0; 217 218 switch (cmd) { 219 220 case IPC_RMID: 221 { 222 struct msg *msghdr; | 181 int rval, eval; 182 struct msqid_ds msqbuf; 183 register struct msqid_ds *msqptr; 184 185#ifdef MSG_DEBUG_OK 186 printf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr); 187#endif 188 --- 25 unchanged lines hidden (view full) --- 214 eval = 0; 215 rval = 0; 216 217 switch (cmd) { 218 219 case IPC_RMID: 220 { 221 struct msg *msghdr; |
223 if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M))) | 222 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_M))) |
224 return(eval); 225 /* Free the message headers */ 226 msghdr = msqptr->msg_first; 227 while (msghdr != NULL) { 228 struct msg *msghdr_tmp; 229 230 /* Free the segments of each message */ 231 msqptr->msg_cbytes -= msghdr->msg_ts; --- 11 unchanged lines hidden (view full) --- 243 msqptr->msg_qbytes = 0; /* Mark it as free */ 244 245 wakeup((caddr_t)msqptr); 246 } 247 248 break; 249 250 case IPC_SET: | 223 return(eval); 224 /* Free the message headers */ 225 msghdr = msqptr->msg_first; 226 while (msghdr != NULL) { 227 struct msg *msghdr_tmp; 228 229 /* Free the segments of each message */ 230 msqptr->msg_cbytes -= msghdr->msg_ts; --- 11 unchanged lines hidden (view full) --- 242 msqptr->msg_qbytes = 0; /* Mark it as free */ 243 244 wakeup((caddr_t)msqptr); 245 } 246 247 break; 248 249 case IPC_SET: |
251 if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M))) | 250 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_M))) |
252 return(eval); 253 if ((eval = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0) 254 return(eval); 255 if (msqbuf.msg_qbytes > msqptr->msg_qbytes) { | 251 return(eval); 252 if ((eval = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0) 253 return(eval); 254 if (msqbuf.msg_qbytes > msqptr->msg_qbytes) { |
256 eval = suser_xxx(cred, &p->p_acflag); | 255 eval = suser(p); |
257 if (eval) 258 return(eval); 259 } 260 if (msqbuf.msg_qbytes > msginfo.msgmnb) { 261#ifdef MSG_DEBUG_OK 262 printf("can't increase msg_qbytes beyond %d (truncating)\n", 263 msginfo.msgmnb); 264#endif --- 9 unchanged lines hidden (view full) --- 274 msqptr->msg_perm.gid = msqbuf.msg_perm.gid; /* change the owner */ 275 msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) | 276 (msqbuf.msg_perm.mode & 0777); 277 msqptr->msg_qbytes = msqbuf.msg_qbytes; 278 msqptr->msg_ctime = time_second; 279 break; 280 281 case IPC_STAT: | 256 if (eval) 257 return(eval); 258 } 259 if (msqbuf.msg_qbytes > msginfo.msgmnb) { 260#ifdef MSG_DEBUG_OK 261 printf("can't increase msg_qbytes beyond %d (truncating)\n", 262 msginfo.msgmnb); 263#endif --- 9 unchanged lines hidden (view full) --- 273 msqptr->msg_perm.gid = msqbuf.msg_perm.gid; /* change the owner */ 274 msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) | 275 (msqbuf.msg_perm.mode & 0777); 276 msqptr->msg_qbytes = msqbuf.msg_qbytes; 277 msqptr->msg_ctime = time_second; 278 break; 279 280 case IPC_STAT: |
282 if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_R))) { | 281 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) { |
283#ifdef MSG_DEBUG_OK 284 printf("requester doesn't have read access\n"); 285#endif 286 return(eval); 287 } 288 eval = copyout((caddr_t)msqptr, user_msqptr, 289 sizeof(struct msqid_ds)); 290 break; --- 44 unchanged lines hidden (view full) --- 335 printf("found public key\n"); 336#endif 337 if ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) { 338#ifdef MSG_DEBUG_OK 339 printf("not exclusive\n"); 340#endif 341 return(EEXIST); 342 } | 282#ifdef MSG_DEBUG_OK 283 printf("requester doesn't have read access\n"); 284#endif 285 return(eval); 286 } 287 eval = copyout((caddr_t)msqptr, user_msqptr, 288 sizeof(struct msqid_ds)); 289 break; --- 44 unchanged lines hidden (view full) --- 334 printf("found public key\n"); 335#endif 336 if ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) { 337#ifdef MSG_DEBUG_OK 338 printf("not exclusive\n"); 339#endif 340 return(EEXIST); 341 } |
343 if ((eval = ipcperm(cred, &msqptr->msg_perm, msgflg & 0700 ))) { | 342 if ((eval = ipcperm(p, &msqptr->msg_perm, msgflg & 0700 ))) { |
344#ifdef MSG_DEBUG_OK 345 printf("requester doesn't have 0%o access\n", 346 msgflg & 0700); 347#endif 348 return(eval); 349 } 350 goto found; 351 } --- 69 unchanged lines hidden (view full) --- 421 struct proc *p; 422 register struct msgsnd_args *uap; 423{ 424 int msqid = uap->msqid; 425 void *user_msgp = uap->msgp; 426 size_t msgsz = uap->msgsz; 427 int msgflg = uap->msgflg; 428 int segs_needed, eval; | 343#ifdef MSG_DEBUG_OK 344 printf("requester doesn't have 0%o access\n", 345 msgflg & 0700); 346#endif 347 return(eval); 348 } 349 goto found; 350 } --- 69 unchanged lines hidden (view full) --- 420 struct proc *p; 421 register struct msgsnd_args *uap; 422{ 423 int msqid = uap->msqid; 424 void *user_msgp = uap->msgp; 425 size_t msgsz = uap->msgsz; 426 int msgflg = uap->msgflg; 427 int segs_needed, eval; |
429 struct ucred *cred = p->p_ucred; | |
430 register struct msqid_ds *msqptr; 431 register struct msg *msghdr; 432 short next; 433 434#ifdef MSG_DEBUG_OK 435 printf("call to msgsnd(%d, 0x%x, %d, %d)\n", msqid, user_msgp, msgsz, 436 msgflg); 437#endif --- 17 unchanged lines hidden (view full) --- 455 } 456 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { 457#ifdef MSG_DEBUG_OK 458 printf("wrong sequence number\n"); 459#endif 460 return(EINVAL); 461 } 462 | 428 register struct msqid_ds *msqptr; 429 register struct msg *msghdr; 430 short next; 431 432#ifdef MSG_DEBUG_OK 433 printf("call to msgsnd(%d, 0x%x, %d, %d)\n", msqid, user_msgp, msgsz, 434 msgflg); 435#endif --- 17 unchanged lines hidden (view full) --- 453 } 454 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { 455#ifdef MSG_DEBUG_OK 456 printf("wrong sequence number\n"); 457#endif 458 return(EINVAL); 459 } 460 |
463 if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_W))) { | 461 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_W))) { |
464#ifdef MSG_DEBUG_OK 465 printf("requester doesn't have write access\n"); 466#endif 467 return(eval); 468 } 469 470 segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz; 471#ifdef MSG_DEBUG_OK --- 286 unchanged lines hidden (view full) --- 758 register struct msgrcv_args *uap; 759{ 760 int msqid = uap->msqid; 761 void *user_msgp = uap->msgp; 762 size_t msgsz = uap->msgsz; 763 long msgtyp = uap->msgtyp; 764 int msgflg = uap->msgflg; 765 size_t len; | 462#ifdef MSG_DEBUG_OK 463 printf("requester doesn't have write access\n"); 464#endif 465 return(eval); 466 } 467 468 segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz; 469#ifdef MSG_DEBUG_OK --- 286 unchanged lines hidden (view full) --- 756 register struct msgrcv_args *uap; 757{ 758 int msqid = uap->msqid; 759 void *user_msgp = uap->msgp; 760 size_t msgsz = uap->msgsz; 761 long msgtyp = uap->msgtyp; 762 int msgflg = uap->msgflg; 763 size_t len; |
766 struct ucred *cred = p->p_ucred; | |
767 register struct msqid_ds *msqptr; 768 register struct msg *msghdr; 769 int eval; 770 short next; 771 772#ifdef MSG_DEBUG_OK 773 printf("call to msgrcv(%d, 0x%x, %d, %ld, %d)\n", msqid, user_msgp, 774 msgsz, msgtyp, msgflg); --- 18 unchanged lines hidden (view full) --- 793 } 794 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { 795#ifdef MSG_DEBUG_OK 796 printf("wrong sequence number\n"); 797#endif 798 return(EINVAL); 799 } 800 | 764 register struct msqid_ds *msqptr; 765 register struct msg *msghdr; 766 int eval; 767 short next; 768 769#ifdef MSG_DEBUG_OK 770 printf("call to msgrcv(%d, 0x%x, %d, %ld, %d)\n", msqid, user_msgp, 771 msgsz, msgtyp, msgflg); --- 18 unchanged lines hidden (view full) --- 790 } 791 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) { 792#ifdef MSG_DEBUG_OK 793 printf("wrong sequence number\n"); 794#endif 795 return(EINVAL); 796 } 797 |
801 if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_R))) { | 798 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) { |
802#ifdef MSG_DEBUG_OK 803 printf("requester doesn't have read access\n"); 804#endif 805 return(eval); 806 } 807 808 msghdr = NULL; 809 while (msghdr == NULL) { --- 221 unchanged lines hidden --- | 799#ifdef MSG_DEBUG_OK 800 printf("requester doesn't have read access\n"); 801#endif 802 return(eval); 803 } 804 805 msghdr = NULL; 806 while (msghdr == NULL) { --- 221 unchanged lines hidden --- |