Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03a4e1f6 authored by J. Bruce Fields's avatar J. Bruce Fields
Browse files

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: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 631fc9ea
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ void nfs_callback_down(int minorversion)
int
check_gss_callback_principal(struct nfs_client *clp, struct svc_rqst *rqstp)
{
	char *p = svc_gss_principal(rqstp);
	char *p = rqstp->rq_cred.cr_principal;

	if (rqstp->rq_authop->flavour != RPC_AUTH_GSS)
		return 1;
+3 −2
Original line number Diff line number Diff line
@@ -650,9 +650,10 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
	struct rpc_clnt *client;

	if (clp->cl_minorversion == 0) {
		if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5))
		if (!clp->cl_cred.cr_principal &&
				(clp->cl_flavor >= RPC_AUTH_GSS_KRB5))
			return -EINVAL;
		args.client_name = clp->cl_principal;
		args.client_name = clp->cl_cred.cr_principal;
		args.prognumber	= conn->cb_prog,
		args.protocol = XPRT_TRANSPORT_TCP;
		args.authflavor = clp->cl_flavor;
+17 −17
Original line number Diff line number Diff line
@@ -1087,9 +1087,7 @@ free_client(struct nfs4_client *clp)
		list_del(&ses->se_perclnt);
		nfsd4_put_session_locked(ses);
	}
	if (clp->cl_cred.cr_group_info)
		put_group_info(clp->cl_cred.cr_group_info);
	kfree(clp->cl_principal);
	free_svc_cred(&clp->cl_cred);
	kfree(clp->cl_name.data);
	kfree(clp);
}
@@ -1170,12 +1168,20 @@ static void copy_clid(struct nfs4_client *target, struct nfs4_client *source)
	target->cl_clientid.cl_id = source->cl_clientid.cl_id; 
}

static void copy_cred(struct svc_cred *target, struct svc_cred *source)
static int copy_cred(struct svc_cred *target, struct svc_cred *source)
{
	if (source->cr_principal) {
		target->cr_principal =
				kstrdup(source->cr_principal, GFP_KERNEL);
		if (target->cr_principal == NULL)
			return -ENOMEM;
	} else
		target->cr_principal = NULL;
	target->cr_uid = source->cr_uid;
	target->cr_gid = source->cr_gid;
	target->cr_group_info = source->cr_group_info;
	get_group_info(target->cr_group_info);
	return 0;
}

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,
{
	struct nfs4_client *clp;
	struct sockaddr *sa = svc_addr(rqstp);
	char *princ;
	int ret;

	clp = alloc_client(name);
	if (clp == NULL)
		return NULL;

	INIT_LIST_HEAD(&clp->cl_sessions);

	princ = svc_gss_principal(rqstp);
	if (princ) {
		clp->cl_principal = kstrdup(princ, GFP_KERNEL);
		if (clp->cl_principal == NULL) {
	ret = copy_cred(&clp->cl_cred, &rqstp->rq_cred);
	if (ret) {
		spin_lock(&client_lock);
		free_client(clp);
		spin_unlock(&client_lock);
		return NULL;
	}
	}

	idr_init(&clp->cl_stateids);
	memcpy(clp->cl_recdir, recdir, HEXDIR_LEN);
	atomic_set(&clp->cl_refcount, 0);
@@ -1279,7 +1280,6 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir,
	copy_verf(clp, verf);
	rpc_copy_addr((struct sockaddr *) &clp->cl_addr, sa);
	clp->cl_flavor = rqstp->rq_flavor;
	copy_cred(&clp->cl_cred, &rqstp->rq_cred);
	gen_confirm(clp);
	clp->cl_cb_session = NULL;
	return clp;
+0 −1
Original line number Diff line number Diff line
@@ -232,7 +232,6 @@ struct nfs4_client {
	time_t                  cl_time;        /* time of last lease renewal */
	struct sockaddr_storage	cl_addr; 	/* client ipaddress */
	u32			cl_flavor;	/* setclientid pseudoflavor */
	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 */
+9 −0
Original line number Diff line number Diff line
@@ -15,13 +15,22 @@
#include <linux/sunrpc/msg_prot.h>
#include <linux/sunrpc/cache.h>
#include <linux/hash.h>
#include <linux/cred.h>

struct svc_cred {
	uid_t			cr_uid;
	gid_t			cr_gid;
	struct group_info	*cr_group_info;
	char			*cr_principal; /* for gss */
};

static inline void free_svc_cred(struct svc_cred *cred)
{
	if (cred->cr_group_info)
		put_group_info(cred->cr_group_info);
	kfree(cred->cr_principal);
}

struct svc_rqst;		/* forward decl */
struct in6_addr;

Loading