Commit 74c98811 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Clean up the auth flavour array mess

What is the point of having a 'auth_flavor_len' field, if it is
always set to 1, and can't be used to determine if the user has
selected an auth flavour?
This cleanup goes back to using auth_flavor_len for its original
intended purpose, and gets rid of the ad-hoc replacements.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 0e20162e
...@@ -253,8 +253,10 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name, ...@@ -253,8 +253,10 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name,
dfprintk(MOUNT, "--> nfs4_try_mount()\n"); dfprintk(MOUNT, "--> nfs4_try_mount()\n");
if (data->auth_flavors[0] == RPC_AUTH_MAXFLAVOR) if (data->auth_flavor_len < 1) {
data->auth_flavors[0] = RPC_AUTH_UNIX; data->auth_flavors[0] = RPC_AUTH_UNIX;
data->auth_flavor_len = 1;
}
export_path = data->nfs_server.export_path; export_path = data->nfs_server.export_path;
data->nfs_server.export_path = "/"; data->nfs_server.export_path = "/";
root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info, root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info,
......
...@@ -923,7 +923,7 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void) ...@@ -923,7 +923,7 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void)
data->nfs_server.port = NFS_UNSPEC_PORT; data->nfs_server.port = NFS_UNSPEC_PORT;
data->nfs_server.protocol = XPRT_TRANSPORT_TCP; data->nfs_server.protocol = XPRT_TRANSPORT_TCP;
data->auth_flavors[0] = RPC_AUTH_MAXFLAVOR; data->auth_flavors[0] = RPC_AUTH_MAXFLAVOR;
data->auth_flavor_len = 1; data->auth_flavor_len = 0;
data->minorversion = 0; data->minorversion = 0;
data->need_mount = true; data->need_mount = true;
data->net = current->nsproxy->net_ns; data->net = current->nsproxy->net_ns;
...@@ -1018,6 +1018,13 @@ static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt) ...@@ -1018,6 +1018,13 @@ static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
} }
} }
static void nfs_set_auth_parsed_mount_data(struct nfs_parsed_mount_data *data,
rpc_authflavor_t pseudoflavor)
{
data->auth_flavors[0] = pseudoflavor;
data->auth_flavor_len = 1;
}
/* /*
* Parse the value of the 'sec=' option. * Parse the value of the 'sec=' option.
*/ */
...@@ -1729,7 +1736,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf ...@@ -1729,7 +1736,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf
* Was a sec= authflavor specified in the options? First, verify * Was a sec= authflavor specified in the options? First, verify
* whether the server supports it, and then just try to use it if so. * whether the server supports it, and then just try to use it if so.
*/ */
if (args->auth_flavors[0] != RPC_AUTH_MAXFLAVOR) { if (args->auth_flavor_len > 0) {
status = nfs_verify_authflavor(args, authlist, authlist_len); status = nfs_verify_authflavor(args, authlist, authlist_len);
dfprintk(MOUNT, "NFS: using auth flavor %u\n", args->auth_flavors[0]); dfprintk(MOUNT, "NFS: using auth flavor %u\n", args->auth_flavors[0]);
if (status) if (status)
...@@ -1760,7 +1767,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf ...@@ -1760,7 +1767,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf
/* Fallthrough */ /* Fallthrough */
} }
dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", flavor); dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", flavor);
args->auth_flavors[0] = flavor; nfs_set_auth_parsed_mount_data(args, flavor);
server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod); server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
if (!IS_ERR(server)) if (!IS_ERR(server))
return server; return server;
...@@ -1776,7 +1783,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf ...@@ -1776,7 +1783,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf
/* Last chance! Try AUTH_UNIX */ /* Last chance! Try AUTH_UNIX */
dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", RPC_AUTH_UNIX); dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", RPC_AUTH_UNIX);
args->auth_flavors[0] = RPC_AUTH_UNIX; nfs_set_auth_parsed_mount_data(args, RPC_AUTH_UNIX);
return nfs_mod->rpc_ops->create_server(mount_info, nfs_mod); return nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
} }
...@@ -1893,6 +1900,7 @@ static int nfs23_validate_mount_data(void *options, ...@@ -1893,6 +1900,7 @@ static int nfs23_validate_mount_data(void *options,
{ {
struct nfs_mount_data *data = (struct nfs_mount_data *)options; struct nfs_mount_data *data = (struct nfs_mount_data *)options;
struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
int extra_flags = NFS_MOUNT_LEGACY_INTERFACE;
if (data == NULL) if (data == NULL)
goto out_no_data; goto out_no_data;
...@@ -1908,6 +1916,8 @@ static int nfs23_validate_mount_data(void *options, ...@@ -1908,6 +1916,8 @@ static int nfs23_validate_mount_data(void *options,
goto out_no_v3; goto out_no_v3;
data->root.size = NFS2_FHSIZE; data->root.size = NFS2_FHSIZE;
memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
/* Turn off security negotiation */
extra_flags |= NFS_MOUNT_SECFLAVOUR;
case 4: case 4:
if (data->flags & NFS_MOUNT_SECFLAVOUR) if (data->flags & NFS_MOUNT_SECFLAVOUR)
goto out_no_sec; goto out_no_sec;
...@@ -1935,7 +1945,7 @@ static int nfs23_validate_mount_data(void *options, ...@@ -1935,7 +1945,7 @@ static int nfs23_validate_mount_data(void *options,
* can deal with. * can deal with.
*/ */
args->flags = data->flags & NFS_MOUNT_FLAGMASK; args->flags = data->flags & NFS_MOUNT_FLAGMASK;
args->flags |= NFS_MOUNT_LEGACY_INTERFACE; args->flags |= extra_flags;
args->rsize = data->rsize; args->rsize = data->rsize;
args->wsize = data->wsize; args->wsize = data->wsize;
args->timeo = data->timeo; args->timeo = data->timeo;
...@@ -1959,9 +1969,10 @@ static int nfs23_validate_mount_data(void *options, ...@@ -1959,9 +1969,10 @@ static int nfs23_validate_mount_data(void *options,
args->namlen = data->namlen; args->namlen = data->namlen;
args->bsize = data->bsize; args->bsize = data->bsize;
args->auth_flavors[0] = RPC_AUTH_UNIX;
if (data->flags & NFS_MOUNT_SECFLAVOUR) if (data->flags & NFS_MOUNT_SECFLAVOUR)
args->auth_flavors[0] = data->pseudoflavor; nfs_set_auth_parsed_mount_data(args, data->pseudoflavor);
else
nfs_set_auth_parsed_mount_data(args, RPC_AUTH_UNIX);
if (!args->nfs_server.hostname) if (!args->nfs_server.hostname)
goto out_nomem; goto out_nomem;
...@@ -2176,7 +2187,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data) ...@@ -2176,7 +2187,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
data->rsize = nfss->rsize; data->rsize = nfss->rsize;
data->wsize = nfss->wsize; data->wsize = nfss->wsize;
data->retrans = nfss->client->cl_timeout->to_retries; data->retrans = nfss->client->cl_timeout->to_retries;
data->auth_flavors[0] = nfss->client->cl_auth->au_flavor; nfs_set_auth_parsed_mount_data(data, nfss->client->cl_auth->au_flavor);
data->acregmin = nfss->acregmin / HZ; data->acregmin = nfss->acregmin / HZ;
data->acregmax = nfss->acregmax / HZ; data->acregmax = nfss->acregmax / HZ;
data->acdirmin = nfss->acdirmin / HZ; data->acdirmin = nfss->acdirmin / HZ;
...@@ -2675,15 +2686,17 @@ static int nfs4_validate_mount_data(void *options, ...@@ -2675,15 +2686,17 @@ static int nfs4_validate_mount_data(void *options,
goto out_no_address; goto out_no_address;
args->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port); args->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port);
args->auth_flavors[0] = RPC_AUTH_UNIX;
if (data->auth_flavourlen) { if (data->auth_flavourlen) {
rpc_authflavor_t pseudoflavor;
if (data->auth_flavourlen > 1) if (data->auth_flavourlen > 1)
goto out_inval_auth; goto out_inval_auth;
if (copy_from_user(&args->auth_flavors[0], if (copy_from_user(&pseudoflavor,
data->auth_flavours, data->auth_flavours,
sizeof(args->auth_flavors[0]))) sizeof(pseudoflavor)))
return -EFAULT; return -EFAULT;
} nfs_set_auth_parsed_mount_data(args, pseudoflavor);
} else
nfs_set_auth_parsed_mount_data(args, RPC_AUTH_UNIX);
c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
if (IS_ERR(c)) if (IS_ERR(c))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment