| 222 | } |
| 223 | |
| 224 | static int |
| 225 | ksem_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; |
| 249 | out: |
| 250 | mtx_unlock(&sem_lock); |
| 251 | return (error); |
| 252 | } |
| 253 | |
| 254 | static int |
| 255 | ksem_closef(struct file *fp, struct thread *td) |
nothing calls this directly
no test coverage detected