PERFORCE change 14756 for review

Robert Watson rwatson at freebsd.org
Tue Jul 23 03:26:22 GMT 2002


http://people.freebsd.org/~peter/p4db/chv.cgi?CH=14756

Change 14756 by rwatson at 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 at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list