From 3ec253a800459bdc9704e219aef9213732e0a5cc Mon Sep 17 00:00:00 2001 From: fvdl Date: Tue, 19 Sep 2000 00:00:18 +0000 Subject: [PATCH] Fix bug in access cache that might result in permission being denied needlessly. From Matthias Drochner. --- sys/nfs/nfs_vnops.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 8c35ddf8fc15..99b0d76d7c00 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -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)) - return np->n_accerror; + 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) - np->n_accmode |= ap->a_mode; - else { + if (cachevalid && error == np->n_accerror) { + if (!error) + np->n_accmode |= ap->a_mode; + 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;