From d5c148af810209896971cbd02996cd2850917e4b Mon Sep 17 00:00:00 2001 From: yamt Date: Thu, 21 Jul 2005 10:39:46 +0000 Subject: [PATCH] use a correct credential for readlink. discussed on source-changes@. --- sys/nfs/nfs_bio.c | 6 +++--- sys/nfs/nfs_vnops.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index 24fd44eccd6d..786732390e33 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_bio.c,v 1.131 2005/07/21 10:37:36 yamt Exp $ */ +/* $NetBSD: nfs_bio.c,v 1.132 2005/07/21 10:39:46 yamt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.131 2005/07/21 10:37:36 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.132 2005/07/21 10:39:46 yamt Exp $"); #include "opt_nfs.h" #include "opt_ddb.h" @@ -962,7 +962,7 @@ nfs_doio_read(bp, uiop) case VLNK: KASSERT(uiop->uio_offset == (off_t)0); nfsstats.readlink_bios++; - error = nfs_readlinkrpc(vp, uiop, curproc->p_ucred); + error = nfs_readlinkrpc(vp, uiop, np->n_rcred); break; case VDIR: nfsstats.readdir_bios++; diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index bb3fbde45a42..d1c742c713e2 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_vnops.c,v 1.223 2005/07/07 02:05:03 christos Exp $ */ +/* $NetBSD: nfs_vnops.c,v 1.224 2005/07/21 10:39:46 yamt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.223 2005/07/07 02:05:03 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.224 2005/07/21 10:39:46 yamt Exp $"); #include "opt_inet.h" #include "opt_nfs.h" @@ -1165,9 +1165,17 @@ nfs_readlink(v) struct ucred *a_cred; } */ *ap = v; struct vnode *vp = ap->a_vp; + struct nfsnode *np = VTONFS(vp); if (vp->v_type != VLNK) return (EPERM); + + if (np->n_rcred != NULL) { + crfree(np->n_rcred); + } + np->n_rcred = ap->a_cred; + crhold(np->n_rcred); + return (nfs_bioread(vp, ap->a_uio, 0, ap->a_cred, 0)); }