From owner-p4-projects Mon Jul 22 20:26:44 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 82E8C37B405; Mon, 22 Jul 2002 20:26:23 -0700 (PDT) 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 B875A37B405 for ; Mon, 22 Jul 2002 20:26:22 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 51EDA43E3B for ; Mon, 22 Jul 2002 20:26:22 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g6N3QMJU055845 for ; Mon, 22 Jul 2002 20:26:22 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g6N3QMcm055842 for perforce@freebsd.org; Mon, 22 Jul 2002 20:26:22 -0700 (PDT) Date: Mon, 22 Jul 2002 20:26:22 -0700 (PDT) Message-Id: <200207230326.g6N3QMcm055842@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 14756 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=14756 Change 14756 by rwatson@rwatson_tislabs on 2002/07/22 20:26:07 Revert vnaccess() change such that file systems call vaccess() or vaccess_acl_posix1e(). This restores the ACL VOP operations to within UFS (the only file system currently using POSIX.1e ACLs). Slight performance optimization. vnaccess() is actually a good idea we should reconsider later once the MAC framework is merged, just not part of the MAC framework merge. Affected files ... .. //depot/projects/trustedbsd/mac/sys/fs/devfs/devfs_vnops.c#18 edit .. //depot/projects/trustedbsd/mac/sys/fs/hpfs/hpfs_vnops.c#9 edit .. //depot/projects/trustedbsd/mac/sys/fs/msdosfs/msdosfs_vnops.c#7 edit .. //depot/projects/trustedbsd/mac/sys/fs/ntfs/ntfs_vnops.c#6 edit .. //depot/projects/trustedbsd/mac/sys/fs/pseudofs/pseudofs_vnops.c#14 edit .. //depot/projects/trustedbsd/mac/sys/fs/udf/udf_vnops.c#6 edit .. //depot/projects/trustedbsd/mac/sys/isofs/cd9660/cd9660_vnops.c#5 edit .. //depot/projects/trustedbsd/mac/sys/kern/vfs_subr.c#27 edit .. //depot/projects/trustedbsd/mac/sys/sys/vnode.h#29 edit .. //depot/projects/trustedbsd/mac/sys/ufs/ufs/ufs_vnops.c#40 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/fs/devfs/devfs_vnops.c#18 (text+ko) ==== @@ -186,7 +186,7 @@ if (vp->v_type == VDIR) de = de->de_dir; - return (vnaccess(vp, de->de_mode, de->de_uid, de->de_gid, + return (vaccess(vp->v_type, de->de_mode, de->de_uid, de->de_gid, ap->a_mode, ap->a_cred, NULL)); } ==== //depot/projects/trustedbsd/mac/sys/fs/hpfs/hpfs_vnops.c#9 (text+ko) ==== @@ -741,7 +741,7 @@ } } - return (vnaccess(vp, hp->h_mode, hp->h_uid, hp->h_gid, + return (vaccess(vp->v_type, hp->h_mode, hp->h_uid, hp->h_gid, ap->a_mode, ap->a_cred, NULL)); } ==== //depot/projects/trustedbsd/mac/sys/fs/msdosfs/msdosfs_vnops.c#7 (text+ko) ==== @@ -263,7 +263,7 @@ } } - return (vnaccess(vp, file_mode, pmp->pm_uid, pmp->pm_gid, + return (vaccess(vp->v_type, file_mode, pmp->pm_uid, pmp->pm_gid, ap->a_mode, ap->a_cred, NULL)); } ==== //depot/projects/trustedbsd/mac/sys/fs/ntfs/ntfs_vnops.c#6 (text+ko) ==== @@ -389,7 +389,7 @@ } } - return (vnaccess(vp, ip->i_mp->ntm_mode, ip->i_mp->ntm_uid, + return (vaccess(vp->v_type, ip->i_mp->ntm_mode, ip->i_mp->ntm_uid, ip->i_mp->ntm_gid, ap->a_mode, ap->a_cred, NULL)); } ==== //depot/projects/trustedbsd/mac/sys/fs/pseudofs/pseudofs_vnops.c#14 (text+ko) ==== @@ -112,7 +112,7 @@ error = VOP_GETATTR(vn, &vattr, va->a_cred, va->a_td); if (error) PFS_RETURN (error); - error = vnaccess(vn, vattr.va_mode, vattr.va_uid, + error = vaccess(vn->v_type, vattr.va_mode, vattr.va_uid, vattr.va_gid, va->a_mode, va->a_cred, NULL); PFS_RETURN (error); } ==== //depot/projects/trustedbsd/mac/sys/fs/udf/udf_vnops.c#6 (text+ko) ==== @@ -215,7 +215,7 @@ mode = udf_permtomode(node); - return (vnaccess(vp, mode, node->fentry->uid, node->fentry->gid, + return (vaccess(vp->v_type, mode, node->fentry->uid, node->fentry->gid, a_mode, a->a_cred, NULL)); } ==== //depot/projects/trustedbsd/mac/sys/isofs/cd9660/cd9660_vnops.c#5 (text+ko) ==== @@ -151,7 +151,7 @@ } } - return (vnaccess(vp, ip->inode.iso_mode, ip->inode.iso_uid, + return (vaccess(vp->v_type, ip->inode.iso_mode, ip->inode.iso_uid, ip->inode.iso_gid, ap->a_mode, ap->a_cred, NULL)); } ==== //depot/projects/trustedbsd/mac/sys/kern/vfs_subr.c#27 (text+ko) ==== @@ -3156,75 +3156,15 @@ } /* - * Common file system object access control check routine. Accepts a - * locked vnode, cached file mode, owner, group, mode, subject credential - * requesting the operation, and optional call-by-reference privused - * argument allowing vnaccess() to indicate to the caller whether privilege - * was used to satisfy the request (obsoleted). Returns 0 on success, or - * an error value on failure. + * Common filesystem object access control check routine. Accepts a + * vnode's type, "mode", uid and gid, requested access mode, credentials, + * and optional call-by-reference privused argument allowing vaccess() + * to indicate to the caller whether privilege was used to satisfy the + * request (obsoleted). Returns 0 on success, or an error value on + * failure. */ int -vnaccess(vp, file_mode, file_uid, file_gid, acc_mode, cred, privused) - struct vnode *vp; - mode_t file_mode; - uid_t file_uid; - gid_t file_gid; - mode_t acc_mode; - struct ucred *cred; - int *privused; -{ - struct acl acl; - int error; - -#if 0 - if (error) { - char *fullpath = "unknown"; - char *freepath = NULL; - - vn_fullpath(curthread, vp, &fullpath, &freepath); - printf("vaccess_mac returned %d for %d (%s) on %s\n", error, - curthread->td_proc->p_pid, curthread->td_proc->p_comm, - fullpath); - - if (freepath) - free(freepath, M_TEMP); - - return (error); - } -#endif - error = VOP_GETACL(vp, ACL_TYPE_ACCESS, &acl, cred, curthread); - switch (error) { - case EOPNOTSUPP: - case EINVAL: /* Includes "ACL type not supported". */ - error = vaccess_dac(vp->v_type, file_mode, file_uid, - file_gid, acc_mode, cred, privused); - break; - case 0: - error = vaccess_acl_posix1e(vp->v_type, file_uid, file_gid, - &acl, acc_mode, cred, privused); - break; - default: - printf("vaccess(): Error retrieving ACL on object (%d).\n", - error); - /* - * XXX: Fall back until debugged. Should eventually - * possibly log an error, and return EPERM for safety. - */ - error = vaccess_dac(vp->v_type, file_mode, file_uid, - file_gid, acc_mode, cred, privused); - } - return (error); -} - -/* - * Common file system object discretionary access control check routine. - * Accepts a vnode's type, "mode", uid and gid, requested access mode, - * credentials, and optional call-by-reference privused argument allowing - * vaccess_dac() to indicate to the caller whether privilege was used to - * satisfy the request. Returns 0 on success, or an errno on failure. - */ -int -vaccess_dac(type, file_mode, file_uid, file_gid, acc_mode, cred, privused) +vaccess(type, file_mode, file_uid, file_gid, acc_mode, cred, privused) enum vtype type; mode_t file_mode; uid_t file_uid; ==== //depot/projects/trustedbsd/mac/sys/sys/vnode.h#29 (text+ko) ==== @@ -608,12 +608,10 @@ (p)->p_textvp, rb, rfb) int vn_fullpath(struct thread *td, struct vnode *optional_dvp, struct vnode *vn, char **retbuf, char **freebuf); -int vnaccess(struct vnode *vp, mode_t file_mode, uid_t uid, gid_t gid, - mode_t acc_mode, struct ucred *cred, int *privused); int vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, struct acl *acl, mode_t acc_mode, struct ucred *cred, int *privused); -int vaccess_dac(enum vtype type, mode_t file_mode, uid_t uid, +int vaccess(enum vtype type, mode_t file_mode, uid_t uid, gid_t gid, mode_t acc_mode, struct ucred *cred, int *privused); void vattr_null(struct vattr *vap); int vcount(struct vnode *vp); ==== //depot/projects/trustedbsd/mac/sys/ufs/ufs/ufs_vnops.c#40 (text+ko) ==== @@ -340,6 +340,9 @@ struct inode *ip = VTOI(vp); mode_t mode = ap->a_mode; int error; +#ifdef UFS_ACL + struct acl *acl; +#endif /* * Disallow write attempts on read-only filesystems; @@ -372,8 +375,27 @@ if ((mode & VWRITE) && (ip->i_flags & (IMMUTABLE | SF_SNAPSHOT))) return (EPERM); - error = vnaccess(vp, ip->i_mode, ip->i_uid, ip->i_gid, +#ifdef UFS_ACL + MALLOC(acl, struct acl *, sizeof(*acl), M_ACL, M_WAITOK); + error = VOP_GETACL(vp, ACL_TYPE_ACCESS, acl, ap->a_cred, ap->a_td); + switch (error) { + case EOPNOTSUPP: + error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, + ap->a_mode, ap->a_cred, NULL); + break; + case 0: + error = vaccess_acl_posix1e(vp->v_type, ip->i_uid, ip->i_gid, + acl, ap->a_mode, ap->a_cred, NULL); + break; + default: + printf("ufs_access(): error retrieving ACL on object (%d)\n", + error); + } + FREE(acl, M_ACL); +#else + error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, ap->a_mode, ap->a_cred, NULL); +#endif return (error); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message