patch for 2.1.119 RPC utsname capture

Bill Hawes (whawes@star.net)
Fri, 04 Sep 1998 22:15:50 -0400


This is a multi-part message in MIME format.
--------------A372953FCD1883B985640736
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I've attached a small patch to capture the system uts nodename at NFS
mount time, to avoid possible problems with the name changing later.

The name is saved in a buffer in the rpc_clnt structure, which is
created at mount time and is passed to the low-level authentication
routines via a pointer in the rpc_task structure. (The NFS mount point
itself is not available, as the RPC is not necessarily being used for
NFS.)

The patch works OK in testing so far, but let me know if you see any
problems.

Regards,
Bill
--------------A372953FCD1883B985640736
Content-Type: text/plain; charset=us-ascii; name="sunrpc_119-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="sunrpc_119-patch"

--- linux-2.1.119/include/linux/sunrpc/clnt.h.old Fri Sep 4 17:01:36 1998
+++ linux-2.1.119/include/linux/sunrpc/clnt.h Fri Sep 4 18:16:23 1998
@@ -9,6 +9,7 @@
#ifndef _LINUX_SUNRPC_CLNT_H
#define _LINUX_SUNRPC_CLNT_H

+#include <linux/utsname.h>
#include <linux/sunrpc/msg_prot.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/xprt.h>
@@ -52,6 +53,9 @@

struct rpc_portmap cl_pmap; /* port mapping */
struct rpc_wait_queue cl_bindwait; /* waiting on getport() */
+
+ int cl_nodelen; /* nodename length */
+ char cl_nodename[__NEW_UTS_LEN+1];
};
#define cl_timeout cl_xprt->timeout
#define cl_prog cl_pmap.pm_prog
--- linux-2.1.119/net/sunrpc/clnt.c.old Tue Sep 1 21:40:24 1998
+++ linux-2.1.119/net/sunrpc/clnt.c Fri Sep 4 18:21:42 1998
@@ -101,6 +101,10 @@

if (!rpcauth_create(flavor, clnt))
goto out_no_auth;
+
+ /* save the nodename */
+ clnt->cl_nodelen = strlen(system_utsname.nodename);
+ strcpy(clnt->cl_nodename, system_utsname.nodename);
out:
return clnt;

--- linux-2.1.119/net/sunrpc/auth_unix.c.old Tue Sep 1 21:39:21 1998
+++ linux-2.1.119/net/sunrpc/auth_unix.c Fri Sep 4 17:55:59 1998
@@ -28,13 +28,9 @@

#define UNX_CRED_EXPIRE (60 * HZ)

-#ifndef DONT_FILLIN_HOSTNAME
/* # define UNX_MAXNODENAME (sizeof(system_utsname.nodename)-1) */
# define UNX_MAXNODENAME 32
# define UNX_WRITESLACK (21 + (UNX_MAXNODENAME >> 2))
-#else
-# define UNX_WRITESLACK 20
-#endif

#ifdef RPC_DEBUG
# define RPCDBG_FACILITY RPCDBG_AUTH
@@ -170,6 +166,7 @@
static u32 *
unx_marshal(struct rpc_task *task, u32 *p, int ruid)
{
+ struct rpc_clnt *clnt = task->tk_client;
struct unx_cred *cred = (struct unx_cred *) task->tk_cred;
u32 *base, *hold;
int i, n;
@@ -177,20 +174,17 @@
*p++ = htonl(RPC_AUTH_UNIX);
base = p++;
*p++ = htonl(jiffies/HZ);
-#ifndef DONT_FILLIN_HOSTNAME
+
/*
- * Problem: The UTS name could change under us. We can't lock
- * here to handle this. On the other hand we can't really
- * go building a bad RPC!
+ * Copy the UTS nodename captured when the client was created.
*/
- if ((n = strlen((char *) system_utsname.nodename)) > UNX_MAXNODENAME)
+ n = clnt->cl_nodelen;
+ if (n > UNX_MAXNODENAME)
n = UNX_MAXNODENAME;
*p++ = htonl(n);
- memcpy(p, system_utsname.nodename, n);
+ memcpy(p, clnt->cl_nodename, n);
p += (n + 3) >> 2;
-#else
- *p++ = 0;
-#endif
+
if (ruid) {
*p++ = htonl((u32) cred->uc_uid);
*p++ = htonl((u32) cred->uc_gid);

--------------A372953FCD1883B985640736--

-
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/faq.html