nfs: shorten and simplify rpc_add_credentials a bit
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
f91c16b8e2
commit
2897531de6
26
fs/nfs.c
26
fs/nfs.c
|
@ -224,34 +224,18 @@ out_overflow:
|
||||||
*/
|
*/
|
||||||
static uint32_t *rpc_add_credentials(uint32_t *p)
|
static uint32_t *rpc_add_credentials(uint32_t *p)
|
||||||
{
|
{
|
||||||
int hl;
|
|
||||||
int hostnamelen = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here's the executive summary on authentication requirements of the
|
* *BSD refuses AUTH_NONE, so use AUTH_UNIX. An empty hostname is OK for
|
||||||
* various NFS server implementations: Linux accepts both AUTH_NONE
|
* both Linux and *BSD.
|
||||||
* 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).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
hl = (hostnamelen + 3) & ~3;
|
|
||||||
|
|
||||||
/* Provide an AUTH_UNIX credential. */
|
/* Provide an AUTH_UNIX credential. */
|
||||||
*p++ = htonl(1); /* AUTH_UNIX */
|
*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(0); /* stamp */
|
||||||
*p++ = htonl(hostnamelen); /* hostname string */
|
*p++ = htonl(0); /* hostname string length */
|
||||||
|
/* memcpy(p, "", 0); p += 0; <- empty host name */
|
||||||
|
|
||||||
if (hostnamelen & 3)
|
|
||||||
*(p + hostnamelen / 4) = 0; /* add zero padding */
|
|
||||||
|
|
||||||
/* memcpy(p, hostname, hostnamelen); */ /* empty hostname */
|
|
||||||
|
|
||||||
p += hl / 4;
|
|
||||||
*p++ = 0; /* uid */
|
*p++ = 0; /* uid */
|
||||||
*p++ = 0; /* gid */
|
*p++ = 0; /* gid */
|
||||||
*p++ = 0; /* auxiliary gid list */
|
*p++ = 0; /* auxiliary gid list */
|
||||||
|
|
Loading…
Reference in New Issue