diff options
author | Trond Myklebust <trondmy@gmail.com> | 2019-04-24 17:46:43 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2019-04-26 16:11:54 -0400 |
commit | 1a58e8a0e5c1f188a80eb9e505bc77d78a31a4ec (patch) | |
tree | 0dc31db3ea8ca7ac3b598a7d7fef30a6496b23ac /fs/nfs | |
parent | 79caa5fad47c69874f9efc4ac3128cc3f6d36f6e (diff) |
NFS: Store the credential of the mount process in the nfs_server
Store the credential of the mount process so that we can determine
information such as the user namespace.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/client.c | 8 | ||||
-rw-r--r-- | fs/nfs/internal.h | 1 | ||||
-rw-r--r-- | fs/nfs/nfs3client.c | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4client.c | 6 |
4 files changed, 15 insertions, 1 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index a843cf3f6340..e3baa9f1da76 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -500,7 +500,7 @@ int nfs_create_rpc_client(struct nfs_client *clp, | |||
500 | .program = &nfs_program, | 500 | .program = &nfs_program, |
501 | .version = clp->rpc_ops->version, | 501 | .version = clp->rpc_ops->version, |
502 | .authflavor = flavor, | 502 | .authflavor = flavor, |
503 | .cred = current_cred(), | 503 | .cred = cl_init->cred, |
504 | }; | 504 | }; |
505 | 505 | ||
506 | if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags)) | 506 | if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags)) |
@@ -655,6 +655,7 @@ static int nfs_init_server(struct nfs_server *server, | |||
655 | .proto = data->nfs_server.protocol, | 655 | .proto = data->nfs_server.protocol, |
656 | .net = data->net, | 656 | .net = data->net, |
657 | .timeparms = &timeparms, | 657 | .timeparms = &timeparms, |
658 | .cred = server->cred, | ||
658 | }; | 659 | }; |
659 | struct nfs_client *clp; | 660 | struct nfs_client *clp; |
660 | int error; | 661 | int error; |
@@ -923,6 +924,7 @@ void nfs_free_server(struct nfs_server *server) | |||
923 | ida_destroy(&server->lockowner_id); | 924 | ida_destroy(&server->lockowner_id); |
924 | ida_destroy(&server->openowner_id); | 925 | ida_destroy(&server->openowner_id); |
925 | nfs_free_iostats(server->io_stats); | 926 | nfs_free_iostats(server->io_stats); |
927 | put_cred(server->cred); | ||
926 | kfree(server); | 928 | kfree(server); |
927 | nfs_release_automount_timer(); | 929 | nfs_release_automount_timer(); |
928 | } | 930 | } |
@@ -943,6 +945,8 @@ struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info, | |||
943 | if (!server) | 945 | if (!server) |
944 | return ERR_PTR(-ENOMEM); | 946 | return ERR_PTR(-ENOMEM); |
945 | 947 | ||
948 | server->cred = get_cred(current_cred()); | ||
949 | |||
946 | error = -ENOMEM; | 950 | error = -ENOMEM; |
947 | fattr = nfs_alloc_fattr(); | 951 | fattr = nfs_alloc_fattr(); |
948 | if (fattr == NULL) | 952 | if (fattr == NULL) |
@@ -1009,6 +1013,8 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source, | |||
1009 | if (!server) | 1013 | if (!server) |
1010 | return ERR_PTR(-ENOMEM); | 1014 | return ERR_PTR(-ENOMEM); |
1011 | 1015 | ||
1016 | server->cred = get_cred(source->cred); | ||
1017 | |||
1012 | error = -ENOMEM; | 1018 | error = -ENOMEM; |
1013 | fattr_fsinfo = nfs_alloc_fattr(); | 1019 | fattr_fsinfo = nfs_alloc_fattr(); |
1014 | if (fattr_fsinfo == NULL) | 1020 | if (fattr_fsinfo == NULL) |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 196534634c3a..22232e76df47 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -84,6 +84,7 @@ struct nfs_client_initdata { | |||
84 | u32 minorversion; | 84 | u32 minorversion; |
85 | struct net *net; | 85 | struct net *net; |
86 | const struct rpc_timeout *timeparms; | 86 | const struct rpc_timeout *timeparms; |
87 | const struct cred *cred; | ||
87 | }; | 88 | }; |
88 | 89 | ||
89 | /* | 90 | /* |
diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c index 7879f2a0fcfd..1afdb0f7473f 100644 --- a/fs/nfs/nfs3client.c +++ b/fs/nfs/nfs3client.c | |||
@@ -91,6 +91,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv, | |||
91 | .proto = ds_proto, | 91 | .proto = ds_proto, |
92 | .net = mds_clp->cl_net, | 92 | .net = mds_clp->cl_net, |
93 | .timeparms = &ds_timeout, | 93 | .timeparms = &ds_timeout, |
94 | .cred = mds_srv->cred, | ||
94 | }; | 95 | }; |
95 | struct nfs_client *clp; | 96 | struct nfs_client *clp; |
96 | char buf[INET6_ADDRSTRLEN + 1]; | 97 | char buf[INET6_ADDRSTRLEN + 1]; |
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 1339ede979af..3ce246346f02 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c | |||
@@ -870,6 +870,7 @@ static int nfs4_set_client(struct nfs_server *server, | |||
870 | .minorversion = minorversion, | 870 | .minorversion = minorversion, |
871 | .net = net, | 871 | .net = net, |
872 | .timeparms = timeparms, | 872 | .timeparms = timeparms, |
873 | .cred = server->cred, | ||
873 | }; | 874 | }; |
874 | struct nfs_client *clp; | 875 | struct nfs_client *clp; |
875 | 876 | ||
@@ -931,6 +932,7 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv, | |||
931 | .minorversion = minor_version, | 932 | .minorversion = minor_version, |
932 | .net = mds_clp->cl_net, | 933 | .net = mds_clp->cl_net, |
933 | .timeparms = &ds_timeout, | 934 | .timeparms = &ds_timeout, |
935 | .cred = mds_srv->cred, | ||
934 | }; | 936 | }; |
935 | char buf[INET6_ADDRSTRLEN + 1]; | 937 | char buf[INET6_ADDRSTRLEN + 1]; |
936 | 938 | ||
@@ -1107,6 +1109,8 @@ struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info, | |||
1107 | if (!server) | 1109 | if (!server) |
1108 | return ERR_PTR(-ENOMEM); | 1110 | return ERR_PTR(-ENOMEM); |
1109 | 1111 | ||
1112 | server->cred = get_cred(current_cred()); | ||
1113 | |||
1110 | auth_probe = mount_info->parsed->auth_info.flavor_len < 1; | 1114 | auth_probe = mount_info->parsed->auth_info.flavor_len < 1; |
1111 | 1115 | ||
1112 | /* set up the general RPC client */ | 1116 | /* set up the general RPC client */ |
@@ -1143,6 +1147,8 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, | |||
1143 | parent_server = NFS_SB(data->sb); | 1147 | parent_server = NFS_SB(data->sb); |
1144 | parent_client = parent_server->nfs_client; | 1148 | parent_client = parent_server->nfs_client; |
1145 | 1149 | ||
1150 | server->cred = get_cred(parent_server->cred); | ||
1151 | |||
1146 | /* Initialise the client representation from the parent server */ | 1152 | /* Initialise the client representation from the parent server */ |
1147 | nfs_server_copy_userdata(server, parent_server); | 1153 | nfs_server_copy_userdata(server, parent_server); |
1148 | 1154 | ||