36 #include <sys/cdefs.h>
39 #include "opt_compat.h"
40 #include "opt_sysvipc.h"
42 #include <sys/param.h>
43 #include <sys/systm.h>
49 #include <sys/ucred.h>
86 ipcperm(
struct thread *td,
struct ipc_perm *perm,
int acc_mode)
88 struct ucred *cred = td->td_ucred;
89 int error, obj_mode, dac_granted, priv_granted;
92 if (cred->cr_uid == perm->cuid || cred->cr_uid == perm->uid) {
93 obj_mode = perm->mode;
97 obj_mode = perm->mode;
100 obj_mode = perm->mode;
110 if (obj_mode & IPC_M)
111 dac_granted |= IPC_M;
113 if (obj_mode & IPC_R)
114 dac_granted |= IPC_R;
115 if (obj_mode & IPC_W)
116 dac_granted |= IPC_W;
121 if ((dac_granted & acc_mode) == acc_mode)
128 if ((acc_mode & IPC_M) && !(dac_granted & IPC_M)) {
131 priv_granted |= IPC_M;
134 if ((acc_mode & IPC_R) && !(dac_granted & IPC_R)) {
137 priv_granted |= IPC_R;
140 if ((acc_mode & IPC_W) && !(dac_granted & IPC_W)) {
143 priv_granted |= IPC_W;
146 if (((dac_granted | priv_granted) & acc_mode) == acc_mode)
152 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
153 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
155 ipcperm_old2new(
struct ipc_perm_old *old,
struct ipc_perm *
new)
158 new->cuid = old->cuid;
159 new->cgid = old->cgid;
162 new->mode = old->mode;
168 ipcperm_new2old(
struct ipc_perm *
new,
struct ipc_perm_old *old)
172 old->cuid =
new->cuid;
173 old->cgid =
new->cgid;
176 old->mode =
new->mode;
183 #include <sys/mount.h>
184 #include <sys/socket.h>
185 #include <compat/compat32bit/compat32bit.h>
186 #include <compat/compat32bit/compat32bit_ipc.h>
187 #include <compat/compat32bit/compat32bit_proto.h>
188 #include <compat/compat32bit/compat32bit_signal.h>
189 #include <compat/compat32bit/compat32bit_syscall.h>
190 #include <compat/compat32bit/compat32bit_util.h>
192 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
193 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
195 compat32bit_ipcperm_old_in(
struct ipc_perm32_old *ip32,
struct ipc_perm *ip)
198 CP(*ip32, *ip, cuid);
199 CP(*ip32, *ip, cgid);
202 CP(*ip32, *ip,
mode);
208 compat32bit_ipcperm_old_out(
struct ipc_perm *ip,
struct ipc_perm32_old *ip32)
211 CP(*ip, *ip32, cuid);
212 CP(*ip, *ip32, cgid);
215 CP(*ip, *ip32,
mode);
222 compat32bit_ipcperm_in(
struct ipc_perm32 *ip32,
struct ipc_perm *ip)
225 CP(*ip32, *ip, cuid);
226 CP(*ip32, *ip, cgid);
229 CP(*ip32, *ip,
mode);
235 compat32bit_ipcperm_out(
struct ipc_perm *ip,
struct ipc_perm32 *ip32)
238 CP(*ip, *ip32, cuid);
239 CP(*ip, *ip32, cgid);
242 CP(*ip, *ip32,
mode);
int ipcperm(struct thread *td, struct ipc_perm *perm, int acc_mode)
void(* shmexit_hook)(struct vmspace *)
int priv_check(struct thread *td, int priv)
void(* shmfork_hook)(struct proc *, struct proc *)
int groupmember(gid_t gid, struct ucred *cred)
void shmfork(struct proc *p1, struct proc *p2)
void shmexit(struct vmspace *vm)