A new lockd patch

H.J. Lu (hjl@lucon.org)
Tue, 20 Oct 1998 21:23:25 -0700 (PDT)


Hi,

Here is a new lockd patch. I am mounting /var/spool/mail. On server,
it has

# ls -ld /var/spool/mail

drwxrwxr-t 2 root mail 1024 Oct 19 19:26 /var/spool/mail

I am using elm. But elm failed to get lock. The problem is lockd's
credential is too weak to do it. This patch seems to fix it.

Thanks.

H.J.
----
Index: fs/lockd/svcsubs.c
===================================================================
RCS file: /home/work/cvs/linux/linux/fs/lockd/svcsubs.c,v
retrieving revision 1.1.1.6
diff -u -p -r1.1.1.6 svcsubs.c
--- fs/lockd/svcsubs.c 1998/07/29 19:20:00 1.1.1.6
+++ fs/lockd/svcsubs.c 1998/10/21 04:15:33
@@ -52,6 +52,8 @@ nlm_lookup_file(struct svc_rqst *rqstp,
struct nlm_file *file;
unsigned int hash;
u32 nfserr;
+ uid_t saved_cr_uid;
+ struct svc_cred *cred;

dprintk("lockd: nlm_file_lookup(%s/%u)\n",
kdevname(u32_to_kdev_t(fh->fh_dev)), fh->fh_ino);
@@ -80,11 +82,19 @@ nlm_lookup_file(struct svc_rqst *rqstp,

/* Open the file. Note that this must not sleep for too long, else
* we would lock up lockd:-) So no NFS re-exports, folks.
+ *
+ * We have to make sure we have the right credential to open
+ * the file.
*/
+ cred = &rqstp->rq_cred;
+ saved_cr_uid = cred->cr_uid;
+ cred->cr_uid = 0;
if ((nfserr = nlmsvc_ops->fopen(rqstp, fh, &file->f_file)) != 0) {
dprintk("lockd: open failed (nfserr %ld)\n", ntohl(nfserr));
+ cred->cr_uid = saved_cr_uid;
goto out_free;
}
+ cred->cr_uid = saved_cr_uid;

file->f_next = nlm_files[hash];
nlm_files[hash] = file;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/