Save creds on nfs_open() for later read/write/etc.
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 20 May 2009 02:44:00 +0000 (19:44 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 20 May 2009 02:44:00 +0000 (19:44 -0700)
Recent commits removed an unnecessary access() call in the open path.
However, this broke NFS's saving of creds for future use.  Replicate
the cred code in nfs_open().

Reported-by: Thomas Nikolajsen <thomas.nikolajsen@mail.dk>
sys/vfs/nfs/nfs_vnops.c

index 2c59ed4..666d04a 100644 (file)
@@ -473,6 +473,22 @@ nfs_open(struct vop_open_args *ap)
        }
 
        /*
+        * Save valid creds for reading and writing for later RPCs.
+        */
+       if ((ap->a_mode & FREAD) && ap->a_cred != np->n_rucred) {
+               crhold(ap->a_cred);
+               if (np->n_rucred)
+                       crfree(np->n_rucred);
+               np->n_rucred = ap->a_cred;
+       }
+       if ((ap->a_mode & FWRITE) && ap->a_cred != np->n_wucred) {
+               crhold(ap->a_cred);
+               if (np->n_wucred)
+                       crfree(np->n_wucred);
+               np->n_wucred = ap->a_cred;
+       }
+
+       /*
         * Clear the attribute cache only if opening with write access.  It
         * is unclear if we should do this at all here, but we certainly
         * should not clear the cache unconditionally simply because a file