MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ksem_chown

Function ksem_chown

freebsd/kern/uipc_sem.c:224–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224static int
225ksem_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
226 struct thread *td)
227{
228 struct ksem *ks;
229 int error;
230
231 error = 0;
232 ks = fp->f_data;
233 mtx_lock(&sem_lock);
234#ifdef MAC
235 error = mac_posixsem_check_setowner(active_cred, ks, uid, gid);
236 if (error != 0)
237 goto out;
238#endif
239 if (uid == (uid_t)-1)
240 uid = ks->ks_uid;
241 if (gid == (gid_t)-1)
242 gid = ks->ks_gid;
243 if (((uid != ks->ks_uid && uid != active_cred->cr_uid) ||
244 (gid != ks->ks_gid && !groupmember(gid, active_cred))) &&
245 (error = priv_check_cred(active_cred, PRIV_VFS_CHOWN)))
246 goto out;
247 ks->ks_uid = uid;
248 ks->ks_gid = gid;
249out:
250 mtx_unlock(&sem_lock);
251 return (error);
252}
253
254static int
255ksem_closef(struct file *fp, struct thread *td)

Callers

nothing calls this directly

Calls 5

mtx_lockFunction · 0.70
groupmemberFunction · 0.70
priv_check_credFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected