Replace open-coded vaccess() in ntfs_access() with a call to vaccess().
Similarly to msdosfs, always add the exec bit to keep the current behavior. Mailing list reference: http://mail-index.netbsd.org/tech-kern/2009/04/21/msg004881.html
This commit is contained in:
parent
215e6d35e2
commit
69db27dc69
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntfs_vnops.c,v 1.42 2008/12/17 20:51:35 cegger Exp $ */
|
||||
/* $NetBSD: ntfs_vnops.c,v 1.43 2009/04/29 22:33:33 elad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_vnops.c,v 1.42 2008/12/17 20:51:35 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ntfs_vnops.c,v 1.43 2009/04/29 22:33:33 elad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -405,11 +405,7 @@ ntfs_access(void *v)
|
|||
} */ *ap = v;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct ntnode *ip = VTONT(vp);
|
||||
kauth_cred_t cred = ap->a_cred;
|
||||
mode_t mask, mode = ap->a_mode;
|
||||
gid_t grp;
|
||||
int i;
|
||||
uint16_t ngroups;
|
||||
mode_t file_mode, mode = ap->a_mode;
|
||||
|
||||
dprintf(("ntfs_access: %llu\n", (unsigned long long)ip->i_number));
|
||||
|
||||
|
@ -429,46 +425,10 @@ ntfs_access(void *v)
|
|||
}
|
||||
}
|
||||
|
||||
/* Otherwise, user id 0 always gets access. */
|
||||
if (kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL) == 0)
|
||||
return (0);
|
||||
file_mode = ip->i_mp->ntm_mode | (S_IXUSR|S_IXGRP|S_IXOTH);
|
||||
|
||||
mask = 0;
|
||||
|
||||
/* Otherwise, check the owner. */
|
||||
if (kauth_cred_geteuid(cred) == ip->i_mp->ntm_uid) {
|
||||
if (mode & VEXEC)
|
||||
mask |= S_IXUSR;
|
||||
if (mode & VREAD)
|
||||
mask |= S_IRUSR;
|
||||
if (mode & VWRITE)
|
||||
mask |= S_IWUSR;
|
||||
return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
|
||||
}
|
||||
|
||||
/* Otherwise, check the groups. */
|
||||
ngroups = kauth_cred_ngroups(cred);
|
||||
for (i = 0; i < ngroups; i++) {
|
||||
grp = kauth_cred_group(cred, i);
|
||||
if (ip->i_mp->ntm_gid == grp) {
|
||||
if (mode & VEXEC)
|
||||
mask |= S_IXGRP;
|
||||
if (mode & VREAD)
|
||||
mask |= S_IRGRP;
|
||||
if (mode & VWRITE)
|
||||
mask |= S_IWGRP;
|
||||
return ((ip->i_mp->ntm_mode&mask) == mask ? 0 : EACCES);
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise, check everyone else. */
|
||||
if (mode & VEXEC)
|
||||
mask |= S_IXOTH;
|
||||
if (mode & VREAD)
|
||||
mask |= S_IROTH;
|
||||
if (mode & VWRITE)
|
||||
mask |= S_IWOTH;
|
||||
return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
|
||||
return (vaccess(vp->v_type, file_mode, ip->i_mp->ntm_uid,
|
||||
ip->i_mp->ntm_gid, mode, ap->a_cred));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue