4 check_perm(struct ipc_perm
* req
, endpoint_t who
, int mode
)
14 /* Root is allowed to do anything. */
18 if (uid
== req
->uid
|| uid
== req
->cuid
) {
20 req_mode
= req
->mode
& 0700;
21 } else if (gid
== req
->gid
|| gid
== req
->cgid
) {
23 req_mode
= req
->mode
& 0070;
26 /* Other user and group. */
27 req_mode
= req
->mode
& 0007;
31 return (mode
&& ((mode
& req_mode
) == mode
));
35 * Copy over an ipc_perm structure to an ipc_perm_sysctl structure.
38 prepare_mib_perm(struct ipc_perm_sysctl
* perms
, const struct ipc_perm
* perm
)
41 memset(perms
, 0, sizeof(*perms
));
42 perms
->_key
= perm
->_key
;
43 perms
->uid
= perm
->uid
;
44 perms
->gid
= perm
->gid
;
45 perms
->cuid
= perm
->cuid
;
46 perms
->cgid
= perm
->cgid
;
47 perms
->mode
= perm
->mode
;
48 perms
->_seq
= perm
->_seq
;