From owner-p4-projects@FreeBSD.ORG Fri Jul 14 16:01:30 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4C3AD16A4E1; Fri, 14 Jul 2006 16:01:30 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0DEDB16A4DF for ; Fri, 14 Jul 2006 16:01:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B2EF443D45 for ; Fri, 14 Jul 2006 16:01:29 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6EG1TuM002708 for ; Fri, 14 Jul 2006 16:01:29 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6EG1TJf002705 for perforce@freebsd.org; Fri, 14 Jul 2006 16:01:29 GMT (envelope-from jhb@freebsd.org) Date: Fri, 14 Jul 2006 16:01:29 GMT Message-Id: <200607141601.k6EG1TJf002705@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 101567 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jul 2006 16:01:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=101567 Change 101567 by jhb@jhb_mutex on 2006/07/14 16:01:09 Use change_dir() in fchdir() instead of duplicating the logic. Affected files ... .. //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#50 edit .. //depot/projects/smpng/sys/compat/svr4/syscalls.master#18 edit .. //depot/projects/smpng/sys/kern/vfs_syscalls.c#111 edit Differences ... ==== //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#50 (text+ko) ==== @@ -606,34 +606,31 @@ struct svr4_sys_fchroot_args *uap; { struct filedesc *fdp = td->td_proc->p_fd; - struct vnode *vp, *vpold; + struct vnode *vp; struct file *fp; - int error; + int error, vfslocked; if ((error = suser(td)) != 0) return error; + AUDIT_ARG(fd, uap->fd); if ((error = getvnode(fdp, uap->fd, &fp)) != 0) return error; vp = fp->f_vnode; + VREF(vp); + fdrop(fp, td); + vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); - if (vp->v_type != VDIR) - error = ENOTDIR; - else - error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td); + AUDIT_ARG(vnode, vp, ARG_VNODE1); + error = change_dir(vp, td); +#ifdef MAC + if (error == 0) + error = mac_check_vnode_chroot(td->td_ucred, vp); +#endif VOP_UNLOCK(vp, 0, td); - if (error) { - fdrop(fp, td); - return error; - } - VREF(vp); - FILEDESC_LOCK_FAST(fdp); - vpold = fdp->fd_rdir; - fdp->fd_rdir = vp; - FILEDESC_UNLOCK_FAST(fdp); - if (vpold != NULL) - vrele(vpold); - fdrop(fp, td); - return 0; + if (error == 0) + error = change_root(vp, td); + VFS_UNLOCK_GIANT(vfslocked); + return (error); } ==== //depot/projects/smpng/sys/compat/svr4/syscalls.master#18 (text+ko) ==== @@ -250,7 +250,7 @@ 150 AUE_NULL UNIMPL notused 151 AUE_NULL UNIMPL notused 152 AUE_NULL UNIMPL modctl -153 AUE_NULL STD { int svr4_sys_fchroot(int fd); } +153 AUE_NULL MSTD { int svr4_sys_fchroot(int fd); } 154 AUE_NULL MSTD { int svr4_sys_utimes(char *path, \ struct timeval *tptr); } 155 AUE_NULL MSTD { int svr4_sys_vhangup(void); } ==== //depot/projects/smpng/sys/kern/vfs_syscalls.c#111 (text+ko) ==== @@ -697,14 +697,7 @@ vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); AUDIT_ARG(vnode, vp, ARG_VNODE1); - if (vp->v_type != VDIR) - error = ENOTDIR; -#ifdef MAC - else if ((error = mac_check_vnode_chdir(td->td_ucred, vp)) != 0) { - } -#endif - else - error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td); + error = change_dir(vp, td); while (!error && (mp = vp->v_mountedhere) != NULL) { int tvfslocked; if (vfs_busy(mp, 0, 0, td))