Fix bug in access cache that might result in permission being denied

needlessly. From Matthias Drochner.
This commit is contained in:
fvdl 2000-09-19 00:00:18 +00:00
parent e485f6527e
commit 3ec253a800
1 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vnops.c,v 1.117 2000/08/03 20:41:33 thorpej Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.118 2000/09/19 00:00:18 fvdl Exp $ */
/*
* Copyright (c) 1989, 1993
@ -312,8 +312,13 @@ nfs_access(v)
* Check access cache first. If this request has been made for this
* uid shortly before, use the cached result.
*/
if (cachevalid && ((np->n_accmode & ap->a_mode) == ap->a_mode))
if (cachevalid) {
if (!np->n_accerror) {
if ((np->n_accmode & ap->a_mode) == ap->a_mode)
return np->n_accerror;
} else if ((np->n_accmode & ap->a_mode) == np->n_accmode)
return np->n_accerror;
}
/*
* For nfs v3, do an access rpc, otherwise you are stuck emulating
@ -384,9 +389,12 @@ nfs_access(v)
* different request, OR it in. Don't update
* the timestamp in that case.
*/
if (cachevalid && error == np->n_accerror)
if (cachevalid && error == np->n_accerror) {
if (!error)
np->n_accmode |= ap->a_mode;
else {
else if ((np->n_accmode & ap->a_mode) == ap->a_mode)
np->n_accmode = ap->a_mode;
} else {
np->n_accstamp = time.tv_sec;
np->n_accuid = ap->a_cred->cr_uid;
np->n_accmode = ap->a_mode;