Lines Matching refs:cred
41 static struct cred machine_cred = {
52 const struct cred *rpc_machine_cred(void) in rpc_machine_cred()
313 rpcauth_unhash_cred_locked(struct rpc_cred *cred) in rpcauth_unhash_cred_locked() argument
315 if (!test_and_clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) in rpcauth_unhash_cred_locked()
317 hlist_del_rcu(&cred->cr_hash); in rpcauth_unhash_cred_locked()
322 rpcauth_unhash_cred(struct rpc_cred *cred) in rpcauth_unhash_cred() argument
327 if (!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) in rpcauth_unhash_cred()
329 cache_lock = &cred->cr_auth->au_credcache->lock; in rpcauth_unhash_cred()
331 ret = rpcauth_unhash_cred_locked(cred); in rpcauth_unhash_cred()
364 rpcauth_stringify_acceptor(struct rpc_cred *cred) in rpcauth_stringify_acceptor() argument
366 if (!cred->cr_ops->crstringify_acceptor) in rpcauth_stringify_acceptor()
368 return cred->cr_ops->crstringify_acceptor(cred); in rpcauth_stringify_acceptor()
378 struct rpc_cred *cred; in rpcauth_destroy_credlist() local
381 cred = list_entry(head->next, struct rpc_cred, cr_lru); in rpcauth_destroy_credlist()
382 list_del_init(&cred->cr_lru); in rpcauth_destroy_credlist()
383 put_rpccred(cred); in rpcauth_destroy_credlist()
388 rpcauth_lru_add_locked(struct rpc_cred *cred) in rpcauth_lru_add_locked() argument
390 if (!list_empty(&cred->cr_lru)) in rpcauth_lru_add_locked()
393 list_add_tail(&cred->cr_lru, &cred_unused); in rpcauth_lru_add_locked()
397 rpcauth_lru_add(struct rpc_cred *cred) in rpcauth_lru_add() argument
399 if (!list_empty(&cred->cr_lru)) in rpcauth_lru_add()
402 rpcauth_lru_add_locked(cred); in rpcauth_lru_add()
407 rpcauth_lru_remove_locked(struct rpc_cred *cred) in rpcauth_lru_remove_locked() argument
409 if (list_empty(&cred->cr_lru)) in rpcauth_lru_remove_locked()
412 list_del_init(&cred->cr_lru); in rpcauth_lru_remove_locked()
416 rpcauth_lru_remove(struct rpc_cred *cred) in rpcauth_lru_remove() argument
418 if (list_empty(&cred->cr_lru)) in rpcauth_lru_remove()
421 rpcauth_lru_remove_locked(cred); in rpcauth_lru_remove()
434 struct rpc_cred *cred; in rpcauth_clear_credcache() local
443 cred = hlist_entry(head->first, struct rpc_cred, cr_hash); in rpcauth_clear_credcache()
444 rpcauth_unhash_cred_locked(cred); in rpcauth_clear_credcache()
446 rpcauth_lru_remove_locked(cred); in rpcauth_clear_credcache()
447 list_add_tail(&cred->cr_lru, &free); in rpcauth_clear_credcache()
481 struct rpc_cred *cred, *next; in rpcauth_prune_expired() local
485 list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { in rpcauth_prune_expired()
489 if (refcount_read(&cred->cr_count) > 1) { in rpcauth_prune_expired()
490 rpcauth_lru_remove_locked(cred); in rpcauth_prune_expired()
497 if (!time_in_range(cred->cr_expire, expired, jiffies)) in rpcauth_prune_expired()
499 if (!rpcauth_unhash_cred(cred)) in rpcauth_prune_expired()
502 rpcauth_lru_remove_locked(cred); in rpcauth_prune_expired()
504 list_add_tail(&cred->cr_lru, free); in rpcauth_prune_expired()
571 struct rpc_cred *cred = NULL, in rpcauth_lookup_credcache() local
581 cred = get_rpccred(entry); in rpcauth_lookup_credcache()
582 if (cred) in rpcauth_lookup_credcache()
587 if (cred != NULL) in rpcauth_lookup_credcache()
592 cred = new; in rpcauth_lookup_credcache()
600 cred = get_rpccred(entry); in rpcauth_lookup_credcache()
601 if (cred) in rpcauth_lookup_credcache()
604 if (cred == NULL) { in rpcauth_lookup_credcache()
605 cred = new; in rpcauth_lookup_credcache()
606 set_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); in rpcauth_lookup_credcache()
607 refcount_inc(&cred->cr_count); in rpcauth_lookup_credcache()
608 hlist_add_head_rcu(&cred->cr_hash, &cache->hashtable[nr]); in rpcauth_lookup_credcache()
614 if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags) && in rpcauth_lookup_credcache()
615 cred->cr_ops->cr_init != NULL && in rpcauth_lookup_credcache()
617 int res = cred->cr_ops->cr_init(auth, cred); in rpcauth_lookup_credcache()
619 put_rpccred(cred); in rpcauth_lookup_credcache()
620 cred = ERR_PTR(res); in rpcauth_lookup_credcache()
625 return cred; in rpcauth_lookup_credcache()
634 const struct cred *cred = current_cred(); in rpcauth_lookupcred() local
637 acred.cred = cred; in rpcauth_lookupcred()
644 rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, in rpcauth_init_cred() argument
647 INIT_HLIST_NODE(&cred->cr_hash); in rpcauth_init_cred()
648 INIT_LIST_HEAD(&cred->cr_lru); in rpcauth_init_cred()
649 refcount_set(&cred->cr_count, 1); in rpcauth_init_cred()
650 cred->cr_auth = auth; in rpcauth_init_cred()
651 cred->cr_flags = 0; in rpcauth_init_cred()
652 cred->cr_ops = ops; in rpcauth_init_cred()
653 cred->cr_expire = jiffies; in rpcauth_init_cred()
654 cred->cr_cred = get_cred(acred->cred); in rpcauth_init_cred()
663 .cred = get_task_cred(&init_task), in rpcauth_bind_root_cred()
668 put_cred(acred.cred); in rpcauth_bind_root_cred()
678 .cred = init_task.cred, in rpcauth_bind_machine_cred()
695 rpcauth_bindcred(struct rpc_task *task, const struct cred *cred, int flags) in rpcauth_bindcred() argument
702 .cred = cred, in rpcauth_bindcred()
710 else if (cred != NULL && cred != &machine_cred) in rpcauth_bindcred()
712 else if (cred == &machine_cred) in rpcauth_bindcred()
718 else if (cred == &machine_cred || (flags & RPC_TASK_ROOTCREDS)) in rpcauth_bindcred()
732 put_rpccred(struct rpc_cred *cred) in put_rpccred() argument
734 if (cred == NULL) in put_rpccred()
737 if (refcount_dec_and_test(&cred->cr_count)) in put_rpccred()
739 if (refcount_read(&cred->cr_count) != 1 || in put_rpccred()
740 !test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) in put_rpccred()
742 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) { in put_rpccred()
743 cred->cr_expire = jiffies; in put_rpccred()
744 rpcauth_lru_add(cred); in put_rpccred()
746 if (unlikely(!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))) in put_rpccred()
747 rpcauth_lru_remove(cred); in put_rpccred()
748 } else if (rpcauth_unhash_cred(cred)) { in put_rpccred()
749 rpcauth_lru_remove(cred); in put_rpccred()
750 if (refcount_dec_and_test(&cred->cr_count)) in put_rpccred()
758 cred->cr_ops->crdestroy(cred); in put_rpccred()
863 struct rpc_cred *cred = task->tk_rqstp->rq_cred; in rpcauth_xmit_need_reencode() local
865 if (!cred || !cred->cr_ops->crneed_reencode) in rpcauth_xmit_need_reencode()
867 return cred->cr_ops->crneed_reencode(task); in rpcauth_xmit_need_reencode()
873 struct rpc_cred *cred; in rpcauth_refreshcred() local
876 cred = task->tk_rqstp->rq_cred; in rpcauth_refreshcred()
877 if (cred == NULL) { in rpcauth_refreshcred()
881 cred = task->tk_rqstp->rq_cred; in rpcauth_refreshcred()
884 err = cred->cr_ops->crrefresh(task); in rpcauth_refreshcred()
894 struct rpc_cred *cred = task->tk_rqstp->rq_cred; in rpcauth_invalcred() local
896 if (cred) in rpcauth_invalcred()
897 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); in rpcauth_invalcred()
903 struct rpc_cred *cred = task->tk_rqstp->rq_cred; in rpcauth_uptodatecred() local
905 return cred == NULL || in rpcauth_uptodatecred()
906 test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; in rpcauth_uptodatecred()