Lines Matching refs:cred
12 #include <linux/cred.h>
41 static struct cred machine_cred = {
49 const struct cred *rpc_machine_cred(void)
261 rpcauth_unhash_cred_locked(struct rpc_cred *cred)
263 if (!test_and_clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
265 hlist_del_rcu(&cred->cr_hash);
270 rpcauth_unhash_cred(struct rpc_cred *cred)
275 if (!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
277 cache_lock = &cred->cr_auth->au_credcache->lock;
279 ret = rpcauth_unhash_cred_locked(cred);
312 rpcauth_stringify_acceptor(struct rpc_cred *cred)
314 if (!cred->cr_ops->crstringify_acceptor)
316 return cred->cr_ops->crstringify_acceptor(cred);
326 struct rpc_cred *cred;
329 cred = list_entry(head->next, struct rpc_cred, cr_lru);
330 list_del_init(&cred->cr_lru);
331 put_rpccred(cred);
336 rpcauth_lru_add_locked(struct rpc_cred *cred)
338 if (!list_empty(&cred->cr_lru))
341 list_add_tail(&cred->cr_lru, &cred_unused);
345 rpcauth_lru_add(struct rpc_cred *cred)
347 if (!list_empty(&cred->cr_lru))
350 rpcauth_lru_add_locked(cred);
355 rpcauth_lru_remove_locked(struct rpc_cred *cred)
357 if (list_empty(&cred->cr_lru))
360 list_del_init(&cred->cr_lru);
364 rpcauth_lru_remove(struct rpc_cred *cred)
366 if (list_empty(&cred->cr_lru))
369 rpcauth_lru_remove_locked(cred);
382 struct rpc_cred *cred;
391 cred = hlist_entry(head->first, struct rpc_cred, cr_hash);
392 rpcauth_unhash_cred_locked(cred);
393 /* Note: We now hold a reference to cred */
394 rpcauth_lru_remove_locked(cred);
395 list_add_tail(&cred->cr_lru, &free);
429 struct rpc_cred *cred, *next;
433 list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) {
437 if (refcount_read(&cred->cr_count) > 1) {
438 rpcauth_lru_remove_locked(cred);
445 if (time_in_range(cred->cr_expire, expired, jiffies))
447 if (!rpcauth_unhash_cred(cred))
450 rpcauth_lru_remove_locked(cred);
452 list_add_tail(&cred->cr_lru, free);
519 struct rpc_cred *cred = NULL,
529 cred = get_rpccred(entry);
530 if (cred)
535 if (cred != NULL)
540 cred = new;
548 cred = get_rpccred(entry);
549 if (cred)
552 if (cred == NULL) {
553 cred = new;
554 set_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags);
555 refcount_inc(&cred->cr_count);
556 hlist_add_head_rcu(&cred->cr_hash, &cache->hashtable[nr]);
562 if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags) &&
563 cred->cr_ops->cr_init != NULL &&
565 int res = cred->cr_ops->cr_init(auth, cred);
567 put_rpccred(cred);
568 cred = ERR_PTR(res);
573 return cred;
582 const struct cred *cred = current_cred();
585 acred.cred = cred;
592 rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
595 INIT_HLIST_NODE(&cred->cr_hash);
596 INIT_LIST_HEAD(&cred->cr_lru);
597 refcount_set(&cred->cr_count, 1);
598 cred->cr_auth = auth;
599 cred->cr_flags = 0;
600 cred->cr_ops = ops;
601 cred->cr_expire = jiffies;
602 cred->cr_cred = get_cred(acred->cred);
611 .cred = get_task_cred(&init_task),
618 put_cred(acred.cred);
628 .cred = init_task.cred,
647 rpcauth_bindcred(struct rpc_task *task, const struct cred *cred, int flags)
654 .cred = cred,
662 else if (cred != NULL && cred != &machine_cred)
664 else if (cred == &machine_cred)
667 /* If machine cred couldn't be bound, try a root cred */
670 else if (cred == &machine_cred)
684 put_rpccred(struct rpc_cred *cred)
686 if (cred == NULL)
689 if (refcount_dec_and_test(&cred->cr_count))
691 if (refcount_read(&cred->cr_count) != 1 ||
692 !test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
694 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) {
695 cred->cr_expire = jiffies;
696 rpcauth_lru_add(cred);
698 if (unlikely(!test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)))
699 rpcauth_lru_remove(cred);
700 } else if (rpcauth_unhash_cred(cred)) {
701 rpcauth_lru_remove(cred);
702 if (refcount_dec_and_test(&cred->cr_count))
710 cred->cr_ops->crdestroy(cred);
803 * rpcauth_unwrap_resp - Invoke unwrap and decode function for the cred
820 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
822 if (!cred || !cred->cr_ops->crneed_reencode)
824 return cred->cr_ops->crneed_reencode(task);
830 struct rpc_cred *cred;
833 cred = task->tk_rqstp->rq_cred;
834 if (cred == NULL) {
838 cred = task->tk_rqstp->rq_cred;
841 err = cred->cr_ops->crrefresh(task);
851 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
853 if (cred)
854 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
860 struct rpc_cred *cred = task->tk_rqstp->rq_cred;
862 return cred == NULL ||
863 test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0;