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/nfsd/nfs4state.c | |
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/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 34 |
1 files changed, 17 insertions, 17 deletions
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; |