Lines Matching refs:cred
12 #include <linux/cred.h>
41 static struct cred machine_cred = {
52 const struct cred *rpc_machine_cred(void)
264 rpcauth_unhash_cred_locked(struct rpc_cred *cred)
266 if (!test_and_clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
268 hlist_del_rcu(&cred->cr_hash);
273 rpcauth_unhash_cred(struct rpc_cred *cred)
278 if (!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
280 cache_lock = &cred->cr_auth->au_credcache->lock;
282 ret = rpcauth_unhash_cred_locked(cred);
315 rpcauth_stringify_acceptor(struct rpc_cred *cred)
317 if (!cred->cr_ops->crstringify_acceptor)
319 return cred->cr_ops->crstringify_acceptor(cred);
329 struct rpc_cred *cred;
332 cred = list_entry(head->next, struct rpc_cred, cr_lru);
333 list_del_init(&cred->cr_lru);
334 put_rpccred(cred);
339 rpcauth_lru_add_locked(struct rpc_cred *cred)
341 if (!list_empty(&cred->cr_lru))
344 list_add_tail(&cred->cr_lru, &cred_unused);
348 rpcauth_lru_add(struct rpc_cred *cred)
350 if (!list_empty(&cred->cr_lru))
353 rpcauth_lru_add_locked(cred);
358 rpcauth_lru_remove_locked(struct rpc_cred *cred)
360 if (list_empty(&cred->cr_lru))
363 list_del_init(&cred->cr_lru);
367 rpcauth_lru_remove(struct rpc_cred *cred)
369 if (list_empty(&cred->cr_lru))
372 rpcauth_lru_remove_locked(cred);
385 struct rpc_cred *cred;
394 cred = hlist_entry(head->first, struct rpc_cred, cr_hash);
395 rpcauth_unhash_cred_locked(cred);
396 /* Note: We now hold a reference to cred */
397 rpcauth_lru_remove_locked(cred);
398 list_add_tail(&cred->cr_lru, &free);
432 struct rpc_cred *cred, *next;
436 list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) {
440 if (refcount_read(&cred->cr_count) > 1) {
441 rpcauth_lru_remove_locked(cred);
448 if (time_in_range(cred->cr_expire, expired, jiffies))
450 if (!rpcauth_unhash_cred(cred))
453 rpcauth_lru_remove_locked(cred);
455 list_add_tail(&cred->cr_lru, free);
522 struct rpc_cred *cred = NULL,
532 cred = get_rpccred(entry);
533 if (cred)
538 if (cred != NULL)
543 cred = new;
551 cred = get_rpccred(entry);
552 if (cred)
555 if (cred == NULL) {
556 cred = new;
557 set_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags);
558 refcount_inc(&cred->cr_count);
559 hlist_add_head_rcu(&cred->cr_hash, &cache->hashtable[nr]);
565 if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags) &&
566 cred->cr_ops->cr_init != NULL &&
568 int res = cred->cr_ops->cr_init(auth, cred);
570 put_rpccred(cred);
571 cred = ERR_PTR(res);
576 return cred;
585 const struct cred *cred = current_cred();
588 acred.cred = cred;
595 rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
598 INIT_HLIST_NODE(&cred->cr_hash);
599 INIT_LIST_HEAD(&cred->cr_lru);
600 refcount_set(&cred->cr_count, 1);
601 cred->cr_auth = auth;
602 cred->cr_flags = 0;
603 cred->cr_ops = ops;
604 cred->cr_expire = jiffies;
605 cred->cr_cred = get_cred(acred->cred);
614 .cred = get_task_cred(&init_task),
619 put_cred(acred.cred);
629 .cred = init_task.cred,
646 rpcauth_bindcred(struct rpc_task *task, const struct cred *cred, int flags)
653 .cred = cred,
661 else if (cred != NULL && cred != &machine_cred)
663 else if (cred == &machine_cred)
666 /* If machine cred couldn't be bound, try a root cred */
669 else if (cred == &machine_cred || (flags & RPC_TASK_ROOTCREDS))
683 put_rpccred(struct rpc_cred *cred)
685 if (cred == NULL)
688 if (refcount_dec_and_test(&cred->cr_count))
690 if (refcount_read(&cred->cr_count) != 1 ||
691 !test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
693 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) {
694 cred->cr_expire = jiffies;
695 rpcauth_lru_add(cred);
697 if (unlikely(!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)))
698 rpcauth_lru_remove(cred);
699 } else if (rpcauth_unhash_cred(cred)) {
700 rpcauth_lru_remove(cred);
701 if (refcount_dec_and_test(&cred->cr_count))
709 cred->cr_ops->crdestroy(cred);
797 * rpcauth_unwrap_resp - Invoke unwrap and decode function for the cred
814 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
816 if (!cred || !cred->cr_ops->crneed_reencode)
818 return cred->cr_ops->crneed_reencode(task);
824 struct rpc_cred *cred;
827 cred = task->tk_rqstp->rq_cred;
828 if (cred == NULL) {
832 cred = task->tk_rqstp->rq_cred;
835 err = cred->cr_ops->crrefresh(task);
845 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
847 if (cred)
848 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
854 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
856 return cred == NULL ||
857 test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0;