mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/9] nfs: shorten and simplify rpc_add_credentials a bit
Date: Thu,  6 Feb 2014 17:40:48 +0100	[thread overview]
Message-ID: <1391704854-3141-4-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <1391704854-3141-1-git-send-email-u.kleine-koenig@pengutronix.de>

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 fs/nfs.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/fs/nfs.c b/fs/nfs.c
index e9a6eede06bd..a6a47f22934c 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -224,34 +224,18 @@ out_overflow:
  */
 static uint32_t *rpc_add_credentials(uint32_t *p)
 {
-	int hl;
-	int hostnamelen = 0;
-
 	/*
-	 * Here's the executive summary on authentication requirements of the
-	 * various NFS server implementations:	Linux accepts both AUTH_NONE
-	 * and AUTH_UNIX authentication (also accepts an empty hostname field
-	 * in the AUTH_UNIX scheme).  *BSD refuses AUTH_NONE, but accepts
-	 * AUTH_UNIX (also accepts an empty hostname field in the AUTH_UNIX
-	 * scheme).  To be safe, use AUTH_UNIX and pass the hostname if we have
-	 * it (if the BOOTP/DHCP reply didn't give one, just use an empty
-	 * hostname).
+	 * *BSD refuses AUTH_NONE, so use AUTH_UNIX. An empty hostname is OK for
+	 * both Linux and *BSD.
 	 */
 
-	hl = (hostnamelen + 3) & ~3;
-
 	/* Provide an AUTH_UNIX credential.  */
 	*p++ = htonl(1);		/* AUTH_UNIX */
-	*p++ = htonl(hl + 20);		/* auth length */
+	*p++ = htonl(20);		/* auth length: 20 + strlen(hostname) */
 	*p++ = htonl(0);		/* stamp */
-	*p++ = htonl(hostnamelen);	/* hostname string */
-
-	if (hostnamelen & 3)
-		*(p + hostnamelen / 4) = 0; /* add zero padding */
-
-	/* memcpy(p, hostname, hostnamelen); */ /* empty hostname */
+	*p++ = htonl(0);		/* hostname string length */
+	/* memcpy(p, "", 0); p += 0; <- empty host name */
 
-	p += hl / 4;
 	*p++ = 0;			/* uid */
 	*p++ = 0;			/* gid */
 	*p++ = 0;			/* auxiliary gid list */
-- 
1.8.5.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-02-06 16:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 16:40 [PATCH 0/9] nfs3 support Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 1/9] net: net_read_uint32: assert that only 32 bit are read Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 2/9] nfs: skip over stale rpc packets Uwe Kleine-König
2014-02-07  8:20   ` Uwe Kleine-König
2014-02-06 16:40 ` Uwe Kleine-König [this message]
2014-02-06 16:40 ` [PATCH 4/9] nfs: simplify rpc_lookup_req Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 5/9] nfs: drop an unneeded variable from nfs_do_open() Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 6/9] net: new function net_read_uint64 Uwe Kleine-König
2014-02-07  8:17   ` Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 7/9] mount: support filesystem options passed via -o Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 8/9] nfs: switch to nfs3 Uwe Kleine-König
2014-02-07  6:48   ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-07  8:52     ` Uwe Kleine-König
2014-02-07  9:50       ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-07 10:23         ` Uwe Kleine-König
2014-02-06 16:40 ` [PATCH 9/9] nfs: parse nfsport and mount port from file system options Uwe Kleine-König
2014-02-07  6:50   ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-07  8:22     ` Uwe Kleine-König
2014-02-07  8:45       ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-07 10:06         ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391704854-3141-4-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox