Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124764
b: refs/heads/master
c: 68e76ad
h: refs/heads/master
v: v3
  • Loading branch information
Olga Kornievskaia authored and Trond Myklebust committed Dec 23, 2008
1 parent 683bad7 commit 0233ada
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 34769fc488b463cb753fc632f8f5ba56c918b7cb
refs/heads/master: 68e76ad0baf8f5d5060377c2423ee6eed5c63057
11 changes: 11 additions & 0 deletions trunk/fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <linux/mutex.h>
#include <linux/lockd/bind.h>
#include <linux/module.h>
#include <linux/sunrpc/svcauth_gss.h>

#define NFSDDBG_FACILITY NFSDDBG_PROC

Expand Down Expand Up @@ -377,6 +378,7 @@ free_client(struct nfs4_client *clp)
shutdown_callback_client(clp);
if (clp->cl_cred.cr_group_info)
put_group_info(clp->cl_cred.cr_group_info);
kfree(clp->cl_principal);
kfree(clp->cl_name.data);
kfree(clp);
}
Expand Down Expand Up @@ -696,6 +698,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
unsigned int strhashval;
struct nfs4_client *conf, *unconf, *new;
__be32 status;
char *princ;
char dname[HEXDIR_LEN];

if (!check_name(clname))
Expand Down Expand Up @@ -783,6 +786,14 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
}
copy_verf(new, &clverifier);
new->cl_addr = sin->sin_addr.s_addr;
princ = svc_gss_principal(rqstp);
if (princ) {
new->cl_principal = kstrdup(princ, GFP_KERNEL);
if (new->cl_principal == NULL) {
free_client(new);
goto out;
}
}
copy_cred(&new->cl_cred, &rqstp->rq_cred);
gen_confirm(new);
gen_callback(new, setclid);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/nfsd/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct nfs4_client {
nfs4_verifier cl_verifier; /* generated by client */
time_t cl_time; /* time of last lease renewal */
__be32 cl_addr; /* client ipaddress */
char *cl_principal; /* setclientid principal name */
struct svc_cred cl_cred; /* setclientid principal */
clientid_t cl_clientid; /* generated by server */
nfs4_verifier cl_confirm; /* generated by server */
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/sunrpc/svcauth_gss.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ int gss_svc_init(void);
void gss_svc_shutdown(void);
int svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name);
u32 svcauth_gss_flavor(struct auth_domain *dom);
char *svc_gss_principal(struct svc_rqst *);

#endif /* __KERNEL__ */
#endif /* _LINUX_SUNRPC_SVCAUTH_GSS_H */
23 changes: 23 additions & 0 deletions trunk/net/sunrpc/auth_gss/svcauth_gss.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ struct rsc {
struct svc_cred cred;
struct gss_svc_seq_data seqdata;
struct gss_ctx *mechctx;
char *client_name;
};

static struct cache_head *rsc_table[RSC_HASHMAX];
Expand All @@ -346,6 +347,7 @@ static void rsc_free(struct rsc *rsci)
gss_delete_sec_context(&rsci->mechctx);
if (rsci->cred.cr_group_info)
put_group_info(rsci->cred.cr_group_info);
kfree(rsci->client_name);
}

static void rsc_put(struct kref *ref)
Expand Down Expand Up @@ -383,6 +385,7 @@ rsc_init(struct cache_head *cnew, struct cache_head *ctmp)
tmp->handle.data = NULL;
new->mechctx = NULL;
new->cred.cr_group_info = NULL;
new->client_name = NULL;
}

static void
Expand All @@ -397,6 +400,8 @@ update_rsc(struct cache_head *cnew, struct cache_head *ctmp)
spin_lock_init(&new->seqdata.sd_lock);
new->cred = tmp->cred;
tmp->cred.cr_group_info = NULL;
new->client_name = tmp->client_name;
tmp->client_name = NULL;
}

static struct cache_head *
Expand Down Expand Up @@ -486,6 +491,15 @@ static int rsc_parse(struct cache_detail *cd,
status = gss_import_sec_context(buf, len, gm, &rsci.mechctx);
if (status)
goto out;

/* get client name */
len = qword_get(&mesg, buf, mlen);
if (len > 0) {
rsci.client_name = kstrdup(buf, GFP_KERNEL);
if (!rsci.client_name)
goto out;
}

}
rsci.h.expiry_time = expiry;
rscp = rsc_update(&rsci, rscp);
Expand Down Expand Up @@ -913,6 +927,15 @@ struct gss_svc_data {
struct rsc *rsci;
};

char *svc_gss_principal(struct svc_rqst *rqstp)
{
struct gss_svc_data *gd = (struct gss_svc_data *)rqstp->rq_auth_data;

if (gd && gd->rsci)
return gd->rsci->client_name;
return NULL;
}

static int
svcauth_gss_set_client(struct svc_rqst *rqstp)
{
Expand Down

0 comments on commit 0233ada

Please sign in to comment.