-#ifndef NeXT
- VOP_LOCK(ttyvp);
-#else
- /*
- * This is the only place that NeXT Guarding has been used for
- * VOP_.*LOCK style calls. Note all of the other diffs should
- * use the three paramater lock/unlock.
- */
- vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY, p);
-#endif
-
-#ifdef PARANOID
- /*
- * Since group is tty and mode is 620 on most terminal lines
- * and since sessions protect terminals from processes outside
- * your session, this check is probably no longer necessary.
- * Since it inhibits setuid root programs that later switch
- * to another user from accessing /dev/tty, we have decided
- * to delete this test. (mckusick 5/93)
- */
- error = VOP_ACCESS(ttyvp,
- (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred, p);
- if (!error)
-#endif /* PARANOID */
- error = VOP_OPEN(ttyvp, flag, NOCRED, p);
- VOP_UNLOCK(ttyvp, 0, p);
+
+ context.vc_thread = current_thread();
+ context.vc_ucred = kauth_cred_proc_ref(p);
+
+ error = VNOP_OPEN(ttyvp, flag, &context);
+ vnode_put(ttyvp);
+ kauth_cred_unref(&context.vc_ucred);
+