diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-05-14 19:55:22 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-05-31 20:29:55 -0400 |
commit | 03a4e1f6ddf25f48848e1bddcffc0ad489648331 (patch) | |
tree | f140e3deb767d092eca997037ebb7b098d8afce9 /fs | |
parent | 631fc9ea05c97e5d1d14ea58a7347be4857d09da (diff) |
nfsd4: move principal name into svc_cred
Instead of keeping the principal name associated with a request in a
structure that's private to auth_gss and using an accessor function,
move it to svc_cred.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/callback.c | 2 | ||||
-rw-r--r-- | fs/nfsd/nfs4callback.c | 5 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 34 | ||||
-rw-r--r-- | fs/nfsd/state.h | 1 |
4 files changed, 21 insertions, 21 deletions
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index cff39406f965..970659daa323 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -343,7 +343,7 @@ void nfs_callback_down(int minorversion) | |||
343 | int | 343 | int |
344 | check_gss_callback_principal(struct nfs_client *clp, struct svc_rqst *rqstp) | 344 | check_gss_callback_principal(struct nfs_client *clp, struct svc_rqst *rqstp) |
345 | { | 345 | { |
346 | char *p = svc_gss_principal(rqstp); | 346 | char *p = rqstp->rq_cred.cr_principal; |
347 | 347 | ||
348 | if (rqstp->rq_authop->flavour != RPC_AUTH_GSS) | 348 | if (rqstp->rq_authop->flavour != RPC_AUTH_GSS) |
349 | return 1; | 349 | return 1; |
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index c8e9f637153a..a5fd6b982f27 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -650,9 +650,10 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c | |||
650 | struct rpc_clnt *client; | 650 | struct rpc_clnt *client; |
651 | 651 | ||
652 | if (clp->cl_minorversion == 0) { | 652 | if (clp->cl_minorversion == 0) { |
653 | if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5)) | 653 | if (!clp->cl_cred.cr_principal && |
654 | (clp->cl_flavor >= RPC_AUTH_GSS_KRB5)) | ||
654 | return -EINVAL; | 655 | return -EINVAL; |
655 | args.client_name = clp->cl_principal; | 656 | args.client_name = clp->cl_cred.cr_principal; |
656 | args.prognumber = conn->cb_prog, | 657 | args.prognumber = conn->cb_prog, |
657 | args.protocol = XPRT_TRANSPORT_TCP; | 658 | args.protocol = XPRT_TRANSPORT_TCP; |
658 | args.authflavor = clp->cl_flavor; | 659 | args.authflavor = clp->cl_flavor; |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 5415550a63a9..37bafb290c11 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -1087,9 +1087,7 @@ free_client(struct nfs4_client *clp) | |||
1087 | list_del(&ses->se_perclnt); | 1087 | list_del(&ses->se_perclnt); |
1088 | nfsd4_put_session_locked(ses); | 1088 | nfsd4_put_session_locked(ses); |
1089 | } | 1089 | } |
1090 | if (clp->cl_cred.cr_group_info) | 1090 | free_svc_cred(&clp->cl_cred); |
1091 | put_group_info(clp->cl_cred.cr_group_info); | ||
1092 | kfree(clp->cl_principal); | ||
1093 | kfree(clp->cl_name.data); | 1091 | kfree(clp->cl_name.data); |
1094 | kfree(clp); | 1092 | kfree(clp); |
1095 | } | 1093 | } |
@@ -1170,12 +1168,20 @@ static void copy_clid(struct nfs4_client *target, struct nfs4_client *source) | |||
1170 | target->cl_clientid.cl_id = source->cl_clientid.cl_id; | 1168 | target->cl_clientid.cl_id = source->cl_clientid.cl_id; |
1171 | } | 1169 | } |
1172 | 1170 | ||
1173 | static void copy_cred(struct svc_cred *target, struct svc_cred *source) | 1171 | static int copy_cred(struct svc_cred *target, struct svc_cred *source) |
1174 | { | 1172 | { |
1173 | if (source->cr_principal) { | ||
1174 | target->cr_principal = | ||
1175 | kstrdup(source->cr_principal, GFP_KERNEL); | ||
1176 | if (target->cr_principal == NULL) | ||
1177 | return -ENOMEM; | ||
1178 | } else | ||
1179 | target->cr_principal = NULL; | ||
1175 | target->cr_uid = source->cr_uid; | 1180 | target->cr_uid = source->cr_uid; |
1176 | target->cr_gid = source->cr_gid; | 1181 | target->cr_gid = source->cr_gid; |
1177 | target->cr_group_info = source->cr_group_info; | 1182 | target->cr_group_info = source->cr_group_info; |
1178 | get_group_info(target->cr_group_info); | 1183 | get_group_info(target->cr_group_info); |
1184 | return 0; | ||
1179 | } | 1185 | } |
1180 | 1186 | ||
1181 | static int same_name(const char *n1, const char *n2) | 1187 | static int same_name(const char *n1, const char *n2) |
@@ -1242,25 +1248,20 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir, | |||
1242 | { | 1248 | { |
1243 | struct nfs4_client *clp; | 1249 | struct nfs4_client *clp; |
1244 | struct sockaddr *sa = svc_addr(rqstp); | 1250 | struct sockaddr *sa = svc_addr(rqstp); |
1245 | char *princ; | 1251 | int ret; |
1246 | 1252 | ||
1247 | clp = alloc_client(name); | 1253 | clp = alloc_client(name); |
1248 | if (clp == NULL) | 1254 | if (clp == NULL) |
1249 | return NULL; | 1255 | return NULL; |
1250 | 1256 | ||
1251 | INIT_LIST_HEAD(&clp->cl_sessions); | 1257 | INIT_LIST_HEAD(&clp->cl_sessions); |
1252 | 1258 | ret = copy_cred(&clp->cl_cred, &rqstp->rq_cred); | |
1253 | princ = svc_gss_principal(rqstp); | 1259 | if (ret) { |
1254 | if (princ) { | 1260 | spin_lock(&client_lock); |
1255 | clp->cl_principal = kstrdup(princ, GFP_KERNEL); | 1261 | free_client(clp); |
1256 | if (clp->cl_principal == NULL) { | 1262 | spin_unlock(&client_lock); |
1257 | spin_lock(&client_lock); | 1263 | return NULL; |
1258 | free_client(clp); | ||
1259 | spin_unlock(&client_lock); | ||
1260 | return NULL; | ||
1261 | } | ||
1262 | } | 1264 | } |
1263 | |||
1264 | idr_init(&clp->cl_stateids); | 1265 | idr_init(&clp->cl_stateids); |
1265 | memcpy(clp->cl_recdir, recdir, HEXDIR_LEN); | 1266 | memcpy(clp->cl_recdir, recdir, HEXDIR_LEN); |
1266 | atomic_set(&clp->cl_refcount, 0); | 1267 | atomic_set(&clp->cl_refcount, 0); |
@@ -1279,7 +1280,6 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir, | |||
1279 | copy_verf(clp, verf); | 1280 | copy_verf(clp, verf); |
1280 | rpc_copy_addr((struct sockaddr *) &clp->cl_addr, sa); | 1281 | rpc_copy_addr((struct sockaddr *) &clp->cl_addr, sa); |
1281 | clp->cl_flavor = rqstp->rq_flavor; | 1282 | clp->cl_flavor = rqstp->rq_flavor; |
1282 | copy_cred(&clp->cl_cred, &rqstp->rq_cred); | ||
1283 | gen_confirm(clp); | 1283 | gen_confirm(clp); |
1284 | clp->cl_cb_session = NULL; | 1284 | clp->cl_cb_session = NULL; |
1285 | return clp; | 1285 | return clp; |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 89ab137d379a..849091e16ea6 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -232,7 +232,6 @@ struct nfs4_client { | |||
232 | time_t cl_time; /* time of last lease renewal */ | 232 | time_t cl_time; /* time of last lease renewal */ |
233 | struct sockaddr_storage cl_addr; /* client ipaddress */ | 233 | struct sockaddr_storage cl_addr; /* client ipaddress */ |
234 | u32 cl_flavor; /* setclientid pseudoflavor */ | 234 | u32 cl_flavor; /* setclientid pseudoflavor */ |
235 | char *cl_principal; /* setclientid principal name */ | ||
236 | struct svc_cred cl_cred; /* setclientid principal */ | 235 | struct svc_cred cl_cred; /* setclientid principal */ |
237 | clientid_t cl_clientid; /* generated by server */ | 236 | clientid_t cl_clientid; /* generated by server */ |
238 | nfs4_verifier cl_confirm; /* generated by server */ | 237 | nfs4_verifier cl_confirm; /* generated by server */ |