Lines Matching refs:cred

41 static struct cred machine_cred = {
52 const struct cred *rpc_machine_cred(void) in rpc_machine_cred()
264 rpcauth_unhash_cred_locked(struct rpc_cred *cred) in rpcauth_unhash_cred_locked() argument
266 if (!test_and_clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) in rpcauth_unhash_cred_locked()
268 hlist_del_rcu(&cred->cr_hash); in rpcauth_unhash_cred_locked()
273 rpcauth_unhash_cred(struct rpc_cred *cred) in rpcauth_unhash_cred() argument
278 if (!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) in rpcauth_unhash_cred()
280 cache_lock = &cred->cr_auth->au_credcache->lock; in rpcauth_unhash_cred()
282 ret = rpcauth_unhash_cred_locked(cred); in rpcauth_unhash_cred()
315 rpcauth_stringify_acceptor(struct rpc_cred *cred) in rpcauth_stringify_acceptor() argument
317 if (!cred->cr_ops->crstringify_acceptor) in rpcauth_stringify_acceptor()
319 return cred->cr_ops->crstringify_acceptor(cred); in rpcauth_stringify_acceptor()
329 struct rpc_cred *cred; in rpcauth_destroy_credlist() local
332 cred = list_entry(head->next, struct rpc_cred, cr_lru); in rpcauth_destroy_credlist()
333 list_del_init(&cred->cr_lru); in rpcauth_destroy_credlist()
334 put_rpccred(cred); in rpcauth_destroy_credlist()
339 rpcauth_lru_add_locked(struct rpc_cred *cred) in rpcauth_lru_add_locked() argument
341 if (!list_empty(&cred->cr_lru)) in rpcauth_lru_add_locked()
344 list_add_tail(&cred->cr_lru, &cred_unused); in rpcauth_lru_add_locked()
348 rpcauth_lru_add(struct rpc_cred *cred) in rpcauth_lru_add() argument
350 if (!list_empty(&cred->cr_lru)) in rpcauth_lru_add()
353 rpcauth_lru_add_locked(cred); in rpcauth_lru_add()
358 rpcauth_lru_remove_locked(struct rpc_cred *cred) in rpcauth_lru_remove_locked() argument
360 if (list_empty(&cred->cr_lru)) in rpcauth_lru_remove_locked()
363 list_del_init(&cred->cr_lru); in rpcauth_lru_remove_locked()
367 rpcauth_lru_remove(struct rpc_cred *cred) in rpcauth_lru_remove() argument
369 if (list_empty(&cred->cr_lru)) in rpcauth_lru_remove()
372 rpcauth_lru_remove_locked(cred); in rpcauth_lru_remove()
385 struct rpc_cred *cred; in rpcauth_clear_credcache() local
394 cred = hlist_entry(head->first, struct rpc_cred, cr_hash); in rpcauth_clear_credcache()
395 rpcauth_unhash_cred_locked(cred); in rpcauth_clear_credcache()
397 rpcauth_lru_remove_locked(cred); in rpcauth_clear_credcache()
398 list_add_tail(&cred->cr_lru, &free); in rpcauth_clear_credcache()
432 struct rpc_cred *cred, *next; in rpcauth_prune_expired() local
436 list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) { in rpcauth_prune_expired()
440 if (refcount_read(&cred->cr_count) > 1) { in rpcauth_prune_expired()
441 rpcauth_lru_remove_locked(cred); in rpcauth_prune_expired()
448 if (time_in_range(cred->cr_expire, expired, jiffies)) in rpcauth_prune_expired()
450 if (!rpcauth_unhash_cred(cred)) in rpcauth_prune_expired()
453 rpcauth_lru_remove_locked(cred); in rpcauth_prune_expired()
455 list_add_tail(&cred->cr_lru, free); in rpcauth_prune_expired()
522 struct rpc_cred *cred = NULL, in rpcauth_lookup_credcache() local
532 cred = get_rpccred(entry); in rpcauth_lookup_credcache()
533 if (cred) in rpcauth_lookup_credcache()
538 if (cred != NULL) in rpcauth_lookup_credcache()
543 cred = new; in rpcauth_lookup_credcache()
551 cred = get_rpccred(entry); in rpcauth_lookup_credcache()
552 if (cred) in rpcauth_lookup_credcache()
555 if (cred == NULL) { in rpcauth_lookup_credcache()
556 cred = new; in rpcauth_lookup_credcache()
557 set_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); in rpcauth_lookup_credcache()
558 refcount_inc(&cred->cr_count); in rpcauth_lookup_credcache()
559 hlist_add_head_rcu(&cred->cr_hash, &cache->hashtable[nr]); in rpcauth_lookup_credcache()
565 if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags) && in rpcauth_lookup_credcache()
566 cred->cr_ops->cr_init != NULL && in rpcauth_lookup_credcache()
568 int res = cred->cr_ops->cr_init(auth, cred); in rpcauth_lookup_credcache()
570 put_rpccred(cred); in rpcauth_lookup_credcache()
571 cred = ERR_PTR(res); in rpcauth_lookup_credcache()
576 return cred; in rpcauth_lookup_credcache()
585 const struct cred *cred = current_cred(); in rpcauth_lookupcred() local
588 acred.cred = cred; in rpcauth_lookupcred()
595 rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, in rpcauth_init_cred() argument
598 INIT_HLIST_NODE(&cred->cr_hash); in rpcauth_init_cred()
599 INIT_LIST_HEAD(&cred->cr_lru); in rpcauth_init_cred()
600 refcount_set(&cred->cr_count, 1); in rpcauth_init_cred()
601 cred->cr_auth = auth; in rpcauth_init_cred()
602 cred->cr_flags = 0; in rpcauth_init_cred()
603 cred->cr_ops = ops; in rpcauth_init_cred()
604 cred->cr_expire = jiffies; in rpcauth_init_cred()
605 cred->cr_cred = get_cred(acred->cred); in rpcauth_init_cred()
614 .cred = get_task_cred(&init_task), in rpcauth_bind_root_cred()
621 put_cred(acred.cred); in rpcauth_bind_root_cred()
631 .cred = init_task.cred, in rpcauth_bind_machine_cred()
650 rpcauth_bindcred(struct rpc_task *task, const struct cred *cred, int flags) in rpcauth_bindcred() argument
657 .cred = cred, in rpcauth_bindcred()
665 else if (cred != NULL && cred != &machine_cred) in rpcauth_bindcred()
667 else if (cred == &machine_cred) in rpcauth_bindcred()
673 else if (cred == &machine_cred) in rpcauth_bindcred()
687 put_rpccred(struct rpc_cred *cred) in put_rpccred() argument
689 if (cred == NULL) in put_rpccred()
692 if (refcount_dec_and_test(&cred->cr_count)) in put_rpccred()
694 if (refcount_read(&cred->cr_count) != 1 || in put_rpccred()
695 !test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) in put_rpccred()
697 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) { in put_rpccred()
698 cred->cr_expire = jiffies; in put_rpccred()
699 rpcauth_lru_add(cred); in put_rpccred()
701 if (unlikely(!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))) in put_rpccred()
702 rpcauth_lru_remove(cred); in put_rpccred()
703 } else if (rpcauth_unhash_cred(cred)) { in put_rpccred()
704 rpcauth_lru_remove(cred); in put_rpccred()
705 if (refcount_dec_and_test(&cred->cr_count)) in put_rpccred()
713 cred->cr_ops->crdestroy(cred); in put_rpccred()
818 struct rpc_cred *cred = task->tk_rqstp->rq_cred; in rpcauth_xmit_need_reencode() local
820 if (!cred || !cred->cr_ops->crneed_reencode) in rpcauth_xmit_need_reencode()
822 return cred->cr_ops->crneed_reencode(task); in rpcauth_xmit_need_reencode()
828 struct rpc_cred *cred; in rpcauth_refreshcred() local
831 cred = task->tk_rqstp->rq_cred; in rpcauth_refreshcred()
832 if (cred == NULL) { in rpcauth_refreshcred()
836 cred = task->tk_rqstp->rq_cred; in rpcauth_refreshcred()
839 err = cred->cr_ops->crrefresh(task); in rpcauth_refreshcred()
849 struct rpc_cred *cred = task->tk_rqstp->rq_cred; in rpcauth_invalcred() local
851 if (cred) in rpcauth_invalcred()
852 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); in rpcauth_invalcred()
858 struct rpc_cred *cred = task->tk_rqstp->rq_cred; in rpcauth_uptodatecred() local
860 return cred == NULL || in rpcauth_uptodatecred()
861 test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0; in rpcauth_uptodatecred()