- if (u.u_uid && u.u_uid != shp->shm_perm.uid &&
- u.u_uid != shp->shm_perm.cuid) {
- u.u_error = EPERM;
- break;
- }
- u.u_error = copyin(uap->buf, (caddr_t)&sbuf, sizeof sbuf);
- if (!u.u_error) {
- shp->shm_perm.uid = sbuf.shm_perm.uid;
- shp->shm_perm.gid = sbuf.shm_perm.gid;
- shp->shm_perm.mode = (shp->shm_perm.mode & ~0777)
- | (sbuf.shm_perm.mode & 0777);
- shp->shm_ctime = time.tv_sec;
- }
+ if (cred->cr_uid && cred->cr_uid != shp->shm_perm.uid &&
+ cred->cr_uid != shp->shm_perm.cuid)
+ return (EPERM);
+ if (error = copyin(uap->buf, (caddr_t)&sbuf, sizeof sbuf))
+ return (error);
+ shp->shm_perm.uid = sbuf.shm_perm.uid;
+ shp->shm_perm.gid = sbuf.shm_perm.gid;
+ shp->shm_perm.mode = (shp->shm_perm.mode & ~0777)
+ | (sbuf.shm_perm.mode & 0777);
+ shp->shm_ctime = time.tv_sec;