aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2003-02-03 09:04:34 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2003-02-03 09:04:34 +0000
commit38356d109742aa367822431fdae511dda1a22e5a (patch)
treeae7c7e95fc4d80312aa125b671960919630ba54c
parent62dae954621fb7cf055ccce05f77a64bb465b8f6 (diff)
downloadsrc-38356d109742aa367822431fdae511dda1a22e5a.tar.gz
src-38356d109742aa367822431fdae511dda1a22e5a.zip
Use vaccess() instead of rolling our own access checks. This fixes a bug
where requests to open a file in append mode were always denied, and will also be useful when capabilities and auditing are implemented.
Notes
Notes: svn path=/head/; revision=110272
-rw-r--r--sys/fs/smbfs/smbfs_vnops.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c
index 23586ad2fd40..744a7d42e42f 100644
--- a/sys/fs/smbfs/smbfs_vnops.c
+++ b/sys/fs/smbfs/smbfs_vnops.c
@@ -139,10 +139,9 @@ smbfs_access(ap)
} */ *ap;
{
struct vnode *vp = ap->a_vp;
- struct ucred *cred = ap->a_cred;
- u_int mode = ap->a_mode;
+ mode_t mode = ap->a_mode;
+ mode_t mpmode;
struct smbmount *smp = VTOSMBFS(vp);
- int error = 0;
SMBVDEBUG("\n");
if ((mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
@@ -153,15 +152,10 @@ smbfs_access(ap)
break;
}
}
- if (cred->cr_uid == 0)
- return 0;
- if (cred->cr_uid != smp->sm_args.uid) {
- mode >>= 3;
- if (!groupmember(smp->sm_args.gid, cred))
- mode >>= 3;
- }
- error = (((vp->v_type == VREG) ? smp->sm_args.file_mode : smp->sm_args.dir_mode) & mode) == mode ? 0 : EACCES;
- return error;
+ mpmode = vp->v_type == VREG ? smp->sm_args.file_mode :
+ smp->sm_args.dir_mode;
+ return (vaccess(vp->v_type, mpmode, smp->sm_args.uid,
+ smp->sm_args.gid, ap->a_mode, ap->a_cred, NULL));
}
/* ARGSUSED */