Lines Matching full:client
120 enum svc_rpc_gss_client_state cl_state; /* client state */
124 gss_name_t cl_cname; /* client name */
320 struct svc_rpc_gss_client *client; in rpc_gss_getcred() local
325 client = req->rq_clntcred; in rpc_gss_getcred()
327 *rcred = &client->cl_rawcred; in rpc_gss_getcred()
329 *ucred = &client->cl_ucred; in rpc_gss_getcred()
331 *cookie = client->cl_cookie; in rpc_gss_getcred()
338 struct svc_rpc_gss_client *client = req->rq_clntcred; in rpc_gss_svc_max_data_length() local
344 switch (client->cl_rawcred.service) { in rpc_gss_svc_max_data_length()
362 maj_stat = gss_wrap_size_limit(&min_stat, client->cl_ctx, want_conf, in rpc_gss_svc_max_data_length()
363 client->cl_qop, max_tp_unit_len, &max); in rpc_gss_svc_max_data_length()
371 log_status("gss_wrap_size_limit", client->cl_mech, in rpc_gss_svc_max_data_length()
380 struct svc_rpc_gss_client *client; in svc_rpc_gss_find_client() local
387 TAILQ_FOREACH(client, list, cl_link) { in svc_rpc_gss_find_client()
388 if (client->cl_id == clientid) { in svc_rpc_gss_find_client()
390 * Move this client to the front of the LRU in svc_rpc_gss_find_client()
393 TAILQ_REMOVE(&svc_rpc_gss_clients, client, cl_alllink); in svc_rpc_gss_find_client()
394 TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, in svc_rpc_gss_find_client()
396 return client; in svc_rpc_gss_find_client()
406 struct svc_rpc_gss_client *client; in svc_rpc_gss_create_client() local
411 client = mem_alloc(sizeof(struct svc_rpc_gss_client)); in svc_rpc_gss_create_client()
412 memset(client, 0, sizeof(struct svc_rpc_gss_client)); in svc_rpc_gss_create_client()
413 client->cl_id = svc_rpc_gss_next_clientid++; in svc_rpc_gss_create_client()
414 list = &svc_rpc_gss_client_hash[client->cl_id % CLIENT_HASH_SIZE]; in svc_rpc_gss_create_client()
415 TAILQ_INSERT_HEAD(list, client, cl_link); in svc_rpc_gss_create_client()
416 TAILQ_INSERT_HEAD(&svc_rpc_gss_clients, client, cl_alllink); in svc_rpc_gss_create_client()
419 * Start the client off with a short expiration time. We will in svc_rpc_gss_create_client()
420 * try to get a saner value from the client creds later. in svc_rpc_gss_create_client()
422 client->cl_state = CLIENT_NEW; in svc_rpc_gss_create_client()
423 client->cl_locked = FALSE; in svc_rpc_gss_create_client()
424 client->cl_expiration = time(0) + 5*60; in svc_rpc_gss_create_client()
427 return (client); in svc_rpc_gss_create_client()
431 svc_rpc_gss_destroy_client(struct svc_rpc_gss_client *client) in svc_rpc_gss_destroy_client() argument
438 if (client->cl_ctx) in svc_rpc_gss_destroy_client()
440 &client->cl_ctx, GSS_C_NO_BUFFER); in svc_rpc_gss_destroy_client()
442 if (client->cl_cname) in svc_rpc_gss_destroy_client()
443 gss_release_name(&min_stat, &client->cl_cname); in svc_rpc_gss_destroy_client()
445 if (client->cl_rawcred.client_principal) in svc_rpc_gss_destroy_client()
446 mem_free(client->cl_rawcred.client_principal, in svc_rpc_gss_destroy_client()
447 sizeof(*client->cl_rawcred.client_principal) in svc_rpc_gss_destroy_client()
448 + client->cl_rawcred.client_principal->len); in svc_rpc_gss_destroy_client()
450 if (client->cl_verf.value) in svc_rpc_gss_destroy_client()
451 gss_release_buffer(&min_stat, &client->cl_verf); in svc_rpc_gss_destroy_client()
453 list = &svc_rpc_gss_client_hash[client->cl_id % CLIENT_HASH_SIZE]; in svc_rpc_gss_destroy_client()
454 TAILQ_REMOVE(list, client, cl_link); in svc_rpc_gss_destroy_client()
455 TAILQ_REMOVE(&svc_rpc_gss_clients, client, cl_alllink); in svc_rpc_gss_destroy_client()
457 mem_free(client, sizeof(*client)); in svc_rpc_gss_destroy_client()
463 struct svc_rpc_gss_client *client; in svc_rpc_gss_timeout_clients() local
469 * First enforce the max client limit. We keep in svc_rpc_gss_timeout_clients()
475 TAILQ_FOREACH_SAFE(client, &svc_rpc_gss_clients, cl_alllink, nclient) { in svc_rpc_gss_timeout_clients()
476 if (client->cl_state == CLIENT_STALE in svc_rpc_gss_timeout_clients()
477 || now > client->cl_expiration) { in svc_rpc_gss_timeout_clients()
478 log_debug("expiring client %p", client); in svc_rpc_gss_timeout_clients()
479 svc_rpc_gss_destroy_client(client); in svc_rpc_gss_timeout_clients()
561 svc_rpc_gss_build_ucred(struct svc_rpc_gss_client *client, in svc_rpc_gss_build_ucred() argument
568 rpc_gss_ucred_t *uc = &client->cl_ucred; in svc_rpc_gss_build_ucred()
573 uc->gidlist = client->cl_gid_storage; in svc_rpc_gss_build_ucred()
575 maj_stat = gss_pname_to_uid(&min_stat, name, client->cl_mech, &uid); in svc_rpc_gss_build_ucred()
584 uc->gidlist = client->cl_gid_storage; in svc_rpc_gss_build_ucred()
591 svc_rpc_gss_accept_sec_context(struct svc_rpc_gss_client *client, in svc_rpc_gss_accept_sec_context() argument
610 client->cl_state = CLIENT_STALE; in svc_rpc_gss_accept_sec_context()
618 if (!client->cl_sname) { in svc_rpc_gss_accept_sec_context()
624 &client->cl_ctx, in svc_rpc_gss_accept_sec_context()
628 &client->cl_cname, in svc_rpc_gss_accept_sec_context()
633 &client->cl_creds); in svc_rpc_gss_accept_sec_context()
634 client->cl_sname = sname; in svc_rpc_gss_accept_sec_context()
646 &client->cl_ctx, in svc_rpc_gss_accept_sec_context()
647 client->cl_sname->sn_cred, in svc_rpc_gss_accept_sec_context()
650 &client->cl_cname, in svc_rpc_gss_accept_sec_context()
662 * reply anyway so that the client gets a chance to see what in svc_rpc_gss_accept_sec_context()
667 log_status("accept_sec_context", client->cl_mech, in svc_rpc_gss_accept_sec_context()
669 client->cl_state = CLIENT_STALE; in svc_rpc_gss_accept_sec_context()
673 gr->gr_handle.value = &client->cl_id; in svc_rpc_gss_accept_sec_context()
674 gr->gr_handle.length = sizeof(client->cl_id); in svc_rpc_gss_accept_sec_context()
677 /* Save client info. */ in svc_rpc_gss_accept_sec_context()
678 client->cl_mech = mech; in svc_rpc_gss_accept_sec_context()
679 client->cl_qop = GSS_C_QOP_DEFAULT; in svc_rpc_gss_accept_sec_context()
680 client->cl_seq = gc->gc_seq; in svc_rpc_gss_accept_sec_context()
681 client->cl_win = gr->gr_win; in svc_rpc_gss_accept_sec_context()
682 client->cl_done_callback = FALSE; in svc_rpc_gss_accept_sec_context()
688 * Change client expiration time to be near when the in svc_rpc_gss_accept_sec_context()
689 * client creds expire (or 24 hours if we can't figure in svc_rpc_gss_accept_sec_context()
695 client->cl_expiration = time(0) + cred_lifetime; in svc_rpc_gss_accept_sec_context()
700 client->cl_rawcred.version = RPCSEC_GSS_VERSION; in svc_rpc_gss_accept_sec_context()
701 rpc_gss_oid_to_mech(mech, &client->cl_rawcred.mechanism); in svc_rpc_gss_accept_sec_context()
702 maj_stat = gss_export_name(&min_stat, client->cl_cname, in svc_rpc_gss_accept_sec_context()
705 log_status("gss_export_name", client->cl_mech, in svc_rpc_gss_accept_sec_context()
709 client->cl_rawcred.client_principal = in svc_rpc_gss_accept_sec_context()
710 mem_alloc(sizeof(*client->cl_rawcred.client_principal) in svc_rpc_gss_accept_sec_context()
712 client->cl_rawcred.client_principal->len = export_name.length; in svc_rpc_gss_accept_sec_context()
713 memcpy(client->cl_rawcred.client_principal->name, in svc_rpc_gss_accept_sec_context()
716 client->cl_rawcred.svc_principal = in svc_rpc_gss_accept_sec_context()
717 client->cl_sname->sn_principal; in svc_rpc_gss_accept_sec_context()
718 client->cl_rawcred.service = gc->gc_svc; in svc_rpc_gss_accept_sec_context()
724 svc_rpc_gss_build_ucred(client, client->cl_cname); in svc_rpc_gss_accept_sec_context()
725 gss_release_name(&min_stat, &client->cl_cname); in svc_rpc_gss_accept_sec_context()
735 client->cl_rawcred.client_principal->name, in svc_rpc_gss_accept_sec_context()
737 client->cl_qop, client->rawcred.service); in svc_rpc_gss_accept_sec_context()
747 svc_rpc_gss_validate(struct svc_rpc_gss_client *client, struct rpc_msg *msg, in svc_rpc_gss_validate() argument
782 maj_stat = gss_verify_mic(&min_stat, client->cl_ctx, &rpcbuf, &checksum, in svc_rpc_gss_validate()
786 log_status("gss_verify_mic", client->cl_mech, in svc_rpc_gss_validate()
788 client->cl_state = CLIENT_STALE; in svc_rpc_gss_validate()
796 svc_rpc_gss_nextverf(struct svc_rpc_gss_client *client, in svc_rpc_gss_nextverf() argument
809 if (client->cl_verf.value) in svc_rpc_gss_nextverf()
810 gss_release_buffer(&min_stat, &client->cl_verf); in svc_rpc_gss_nextverf()
812 maj_stat = gss_get_mic(&min_stat, client->cl_ctx, client->cl_qop, in svc_rpc_gss_nextverf()
813 &signbuf, &client->cl_verf); in svc_rpc_gss_nextverf()
816 log_status("gss_get_mic", client->cl_mech, maj_stat, min_stat); in svc_rpc_gss_nextverf()
817 client->cl_state = CLIENT_STALE; in svc_rpc_gss_nextverf()
821 rqst->rq_xprt->xp_verf.oa_base = (caddr_t)client->cl_verf.value; in svc_rpc_gss_nextverf()
822 rqst->rq_xprt->xp_verf.oa_length = (u_int)client->cl_verf.length; in svc_rpc_gss_nextverf()
828 svc_rpc_gss_callback(struct svc_rpc_gss_client *client, struct svc_req *rqst) in svc_rpc_gss_callback() argument
848 lock.raw_cred = &client->cl_rawcred; in svc_rpc_gss_callback()
850 client->cl_creds, in svc_rpc_gss_callback()
851 client->cl_ctx, in svc_rpc_gss_callback()
856 client->cl_state = CLIENT_STALE; in svc_rpc_gss_callback()
863 * is responsible for freeing client->cl_creds in svc_rpc_gss_callback()
866 client->cl_creds = GSS_C_NO_CREDENTIAL; in svc_rpc_gss_callback()
867 client->cl_locked = lock.locked; in svc_rpc_gss_callback()
868 client->cl_cookie = cookie; in svc_rpc_gss_callback()
876 * clean up the delegated client creds, if any. in svc_rpc_gss_callback()
878 if (client->cl_creds) { in svc_rpc_gss_callback()
880 gss_release_cred(&min_ver, &client->cl_creds); in svc_rpc_gss_callback()
886 svc_rpc_gss_check_replay(struct svc_rpc_gss_client *client, uint32_t seq) in svc_rpc_gss_check_replay() argument
891 if (seq <= client->cl_seqlast) { in svc_rpc_gss_check_replay()
899 offset = client->cl_seqlast - seq; in svc_rpc_gss_check_replay()
904 if (client->cl_seqmask[word] & (1 << bit)) in svc_rpc_gss_check_replay()
912 svc_rpc_gss_update_seq(struct svc_rpc_gss_client *client, uint32_t seq) in svc_rpc_gss_update_seq() argument
918 maskp = client->cl_seqmask; in svc_rpc_gss_update_seq()
919 if (seq > client->cl_seqlast) { in svc_rpc_gss_update_seq()
927 offset = seq - client->cl_seqlast; in svc_rpc_gss_update_seq()
945 client->cl_seqlast = seq; in svc_rpc_gss_update_seq()
947 offset = client->cl_seqlast - seq; in svc_rpc_gss_update_seq()
961 struct svc_rpc_gss_client *client; in svc_rpc_gss() local
976 /* Deserialize client credentials. */ in svc_rpc_gss()
997 /* Check the proc and find the client (or create it) */ in svc_rpc_gss()
1003 client = svc_rpc_gss_create_client(); in svc_rpc_gss()
1010 client = svc_rpc_gss_find_client(*p); in svc_rpc_gss()
1011 if (!client) { in svc_rpc_gss()
1013 * Can't find the client - we may have in svc_rpc_gss()
1021 rqst->rq_clntcred = client; in svc_rpc_gss()
1036 client->cl_seq = gc.gc_seq; in svc_rpc_gss()
1060 if (!svc_rpc_gss_accept_sec_context(client, rqst, &gr, &gc)) { in svc_rpc_gss()
1066 if (!svc_rpc_gss_nextverf(client, rqst, gr.gr_win)) { in svc_rpc_gss()
1087 client->cl_state = CLIENT_ESTABLISHED; in svc_rpc_gss()
1094 if (!svc_rpc_gss_check_replay(client, gc.gc_seq)) { in svc_rpc_gss()
1099 if (!svc_rpc_gss_validate(client, msg, &qop)) { in svc_rpc_gss()
1104 if (!svc_rpc_gss_nextverf(client, rqst, gc.gc_seq)) { in svc_rpc_gss()
1109 svc_rpc_gss_update_seq(client, gc.gc_seq); in svc_rpc_gss()
1119 SVC_AUTH(rqst->rq_xprt).svc_ah_private = client; in svc_rpc_gss()
1126 if (!client->cl_done_callback) { in svc_rpc_gss()
1127 client->cl_done_callback = TRUE; in svc_rpc_gss()
1128 client->cl_qop = qop; in svc_rpc_gss()
1129 client->cl_rawcred.qop = _rpc_gss_num_to_qop( in svc_rpc_gss()
1130 client->cl_rawcred.mechanism, qop); in svc_rpc_gss()
1131 if (!svc_rpc_gss_callback(client, rqst)) { in svc_rpc_gss()
1138 * If the server has locked this client to a in svc_rpc_gss()
1142 if (client->cl_locked) { in svc_rpc_gss()
1143 if (client->cl_rawcred.service != gc.gc_svc) { in svc_rpc_gss()
1146 } else if (client->cl_qop != qop) { in svc_rpc_gss()
1156 if (client->cl_qop != qop) { in svc_rpc_gss()
1157 client->cl_qop = qop; in svc_rpc_gss()
1158 client->cl_rawcred.qop = _rpc_gss_num_to_qop( in svc_rpc_gss()
1159 client->cl_rawcred.mechanism, qop); in svc_rpc_gss()
1166 client->cl_rawcred.service = gc.gc_svc; in svc_rpc_gss()
1183 svc_rpc_gss_destroy_client(client); in svc_rpc_gss()
1202 struct svc_rpc_gss_client *client; in svc_rpc_gss_wrap() local
1206 client = (struct svc_rpc_gss_client *) auth->svc_ah_private; in svc_rpc_gss_wrap()
1207 if (client->cl_state != CLIENT_ESTABLISHED in svc_rpc_gss_wrap()
1208 || client->cl_rawcred.service == rpc_gss_svc_none) { in svc_rpc_gss_wrap()
1212 client->cl_ctx, client->cl_qop, in svc_rpc_gss_wrap()
1213 client->cl_rawcred.service, client->cl_seq)); in svc_rpc_gss_wrap()
1219 struct svc_rpc_gss_client *client; in svc_rpc_gss_unwrap() local
1223 client = (struct svc_rpc_gss_client *) auth->svc_ah_private; in svc_rpc_gss_unwrap()
1224 if (client->cl_state != CLIENT_ESTABLISHED in svc_rpc_gss_unwrap()
1225 || client->cl_rawcred.service == rpc_gss_svc_none) { in svc_rpc_gss_unwrap()
1229 client->cl_ctx, client->cl_qop, in svc_rpc_gss_unwrap()
1230 client->cl_rawcred.service, client->cl_seq)); in svc_rpc_gss_unwrap()