Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 374816
b: refs/heads/master
c: d497ab9
h: refs/heads/master
v: v3
  • Loading branch information
Weston Andros Adamson authored and Trond Myklebust committed May 6, 2013
1 parent 48f155b commit 62e1281
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c8b2d0bfd3370a5e19e64ddb23f8bc1276410b6c
refs/heads/master: d497ab975141666e674e7bd8729e00095ec23c9d
48 changes: 41 additions & 7 deletions trunk/fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,16 +1607,15 @@ static int nfs_parse_mount_options(char *raw,
/*
* Select a security flavor for this mount. The selected flavor
* is planted in args->auth_flavors[0].
*
* Returns 0 on success, -EACCES on failure.
*/
static void nfs_select_flavor(struct nfs_parsed_mount_data *args,
static int nfs_select_flavor(struct nfs_parsed_mount_data *args,
struct nfs_mount_request *request)
{
unsigned int i, count = *(request->auth_flav_len);
rpc_authflavor_t flavor;

if (args->auth_flavors[0] != RPC_AUTH_MAXFLAVOR)
goto out;

/*
* The NFSv2 MNT operation does not return a flavor list.
*/
Expand All @@ -1630,6 +1629,25 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args,
if (count == 0)
goto out_default;

/*
* If the sec= mount option is used, the specified flavor or AUTH_NULL
* must be in the list returned by the server.
*
* AUTH_NULL has a special meaning when it's in the server list - it
* means that the server will ignore the rpc creds, so any flavor
* can be used.
*/
if (args->auth_flavors[0] != RPC_AUTH_MAXFLAVOR) {
for (i = 0; i < count; i++) {
if (args->auth_flavors[0] == request->auth_flavs[i] ||
request->auth_flavs[i] == RPC_AUTH_NULL)
goto out;
}
dfprintk(MOUNT, "NFS: auth flavor %d not supported by server\n",
args->auth_flavors[0]);
goto out_err;
}

/*
* RFC 2623, section 2.7 suggests we SHOULD prefer the
* flavor listed first. However, some servers list
Expand All @@ -1650,12 +1668,29 @@ static void nfs_select_flavor(struct nfs_parsed_mount_data *args,
}
}

/*
* As a last chance, see if the server list contains AUTH_NULL -
* if it does, use the default flavor.
*/
for (i = 0; i < count; i++) {
if (request->auth_flavs[i] == RPC_AUTH_NULL)
goto out_default;
}

dfprintk(MOUNT, "NFS: no auth flavors in common with server\n");
goto out_err;

out_default:
flavor = RPC_AUTH_UNIX;
/* use default if flavor not already set */
flavor = (args->auth_flavors[0] == RPC_AUTH_MAXFLAVOR) ?
RPC_AUTH_UNIX : args->auth_flavors[0];
out_set:
args->auth_flavors[0] = flavor;
out:
dfprintk(MOUNT, "NFS: using auth flavor %d\n", args->auth_flavors[0]);
return 0;
out_err:
return -EACCES;
}

/*
Expand Down Expand Up @@ -1718,8 +1753,7 @@ static int nfs_request_mount(struct nfs_parsed_mount_data *args,
return status;
}

nfs_select_flavor(args, &request);
return 0;
return nfs_select_flavor(args, &request);
}

struct dentry *nfs_try_mount(int flags, const char *dev_name,
Expand Down

0 comments on commit 62e1281

Please sign in to comment.