FreeBSD/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
/*
 * This simpler interface is used by svc_getcred to copy the cred data
 * into a kernel cred structure.
 */
This simpler interface is used by svc_getcred to copy the cred data
into a kernel cred structure.
This simpler interface is used by svc_getcred to copy the cred data into a kernel cred structure .
static int
rpc_gss_svc_getcred(struct svc_req *req, struct ucred **crp, int *flavorp)
{
	struct ucred *cr;
	struct svc_rpc_gss_cookedcred *cc;
	struct svc_rpc_gss_client *client;
	rpc_gss_ucred_t *uc;
	if (req->rq_cred.oa_flavor != RPCSEC_GSS)
		return (FALSE);
	cc = req->rq_clntcred;
	client = cc->cc_client;
	if (flavorp)
		*flavorp = client->cl_rpcflavor;
	if (client->cl_cred) {
		*crp = crhold(client->cl_cred);
		return (TRUE);
	}
	uc = &client->cl_ucred;
	cr = client->cl_cred = crget();
	cr->cr_uid = cr->cr_ruid = cr->cr_svuid = uc->uid;
	cr->cr_rgid = cr->cr_svgid = uc->gid;
	crsetgroups(cr, uc->gidlen, uc->gidlist);
	cr->cr_prison = &prison0;
	prison_hold(cr->cr_prison);
	*crp = crhold(cr);
	return (TRUE);
}
static int rpc_gss_svc_getcred ( struct svc_req * req , struct ucred * * crp , int * flavorp ) { struct ucred * cr ; struct svc_rpc_gss_cookedcred * cc ; struct svc_rpc_gss_client * client ; rpc_gss_ucred_t * uc ; if ( req -> rq_cred . oa_flavor != RPCSEC_GSS ) return ( FALSE ) ; cc = req -> rq_clntcred ; client = cc -> cc_client ; if ( flavorp ) * flavorp = client -> cl_rpcflavor ; if ( client -> cl_cred ) { * crp = crhold ( client -> cl_cred ) ; return ( TRUE ) ; } uc = & client -> cl_ucred ; cr = client -> cl_cred = crget ( ) ; cr -> cr_uid = cr -> cr_ruid = cr -> cr_svuid = uc -> uid ; cr -> cr_rgid = cr -> cr_svgid = uc -> gid ; crsetgroups ( cr , uc -> gidlen , uc -> gidlist ) ; cr -> cr_prison = & prison0 ; prison_hold ( cr -> cr_prison ) ; * crp = crhold ( cr ) ; return ( TRUE ) ; }
This simpler interface is used by svc_getcred to copy the cred data
 into a kernel cred structure.
This simpler interface is used by svc_getcred to copy the cred data into a kernel cred structure .