526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek/*
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek SSSD
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek KCM Server - ccache in-memory storage
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek Copyright (C) Red Hat, 2016
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek This program is free software; you can redistribute it and/or modify
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek it under the terms of the GNU General Public License as published by
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek (at your option) any later version.
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek This program is distributed in the hope that it will be useful,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek GNU General Public License for more details.
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek You should have received a copy of the GNU General Public License
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek*/
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek#include "config.h"
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek#include <talloc.h>
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek#include <stdio.h>
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek#include "util/util.h"
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek#include "responder/kcm/kcmsrv_ccache_pvt.h"
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek#include "responder/kcm/kcmsrv_ccache_be.h"
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstruct ccdb_mem;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek/*
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek * The KCM memory database is just a double-linked list of kcm_ccache structures
50c9d542e8bf641412debaa82a4dcf67ddb72258Lukas Slebodnik */
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstruct ccache_mem_wrap {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccache *cc;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek bool is_default;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *next;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *prev;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem *mem_be;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstruct ccdb_mem {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek /* Both ccaches and the next-id are kept in memory */
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *head;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek unsigned int nextid;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek/* In order to provide a consistent interface, we need to let the caller
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek * of getbyXXX own the ccache, therefore the memory back end returns a shallow
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek * copy of the ccache
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek */
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstatic struct kcm_ccache *kcm_ccache_dup(TALLOC_CTX *mem_ctx,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct kcm_ccache *in)
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek{
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct kcm_ccache *out;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek out = talloc_zero(mem_ctx, struct kcm_ccache);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (out == NULL) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return NULL;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek memcpy(out, in, sizeof(struct kcm_ccache));
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return out;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic struct ccache_mem_wrap *memdb_get_by_uuid(struct ccdb_mem *memdb,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t uuid)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
f1e3364a72eb75673d10cf8c97ba8f1d7a385405Petr ÄŒech uid_t uid;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccache_mem_wrap *out = NULL;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek uid = cli_creds_get_uid(client);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek DLIST_FOR_EACH(ccwrap, memdb->head) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap->cc == NULL) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek /* since KCM stores ccaches, better not crash.. */
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek continue;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap->cc->owner.uid == uid) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (uuid_compare(uuid, ccwrap->cc->uuid) == 0) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek out = ccwrap;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek break;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return out;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstatic struct ccache_mem_wrap *memdb_get_by_name(struct ccdb_mem *memdb,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct cli_creds *client,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek const char *name)
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek{
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek uid_t uid;
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose struct ccache_mem_wrap *ccwrap = NULL;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccache_mem_wrap *out = NULL;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek uid = cli_creds_get_uid(client);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek DLIST_FOR_EACH(ccwrap, memdb->head) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap->cc == NULL) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek /* since KCM stores ccaches, better not crash.. */
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek continue;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose if (ccwrap->cc->owner.uid == uid) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (strcmp(ccwrap->cc->name, name) == 0) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek out = ccwrap;
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek break;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return out;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek/* Since with the in-memory database, the database operations are just
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek * fake-async wrappers around otherwise sync operations, we don't often
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose * need any state, so we use this empty structure instead
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek */
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstruct ccdb_mem_dummy_state {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek};
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bosestatic int ccwrap_destructor(void *ptr)
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek{
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccache_mem_wrap *ccwrap = talloc_get_type(ptr, struct ccache_mem_wrap);
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap == NULL) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return 0;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap->cc != NULL) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap->cc->creds) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek safezero(sss_iobuf_get_data(ccwrap->cc->creds->cred_blob),
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek sss_iobuf_get_size(ccwrap->cc->creds->cred_blob));
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek DLIST_REMOVE(ccwrap->mem_be->head, ccwrap);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek return 0;
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek}
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozekstatic errno_t ccdb_mem_init(struct kcm_ccdb *db)
b5825c74b6bf7a99ae2172392dbecb51179013a6Jakub Hrozek{
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccdb_mem *memdb = NULL;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek memdb = talloc_zero(db, struct ccdb_mem);
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek if (memdb == NULL) {
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek return ENOMEM;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek }
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek db->db_handle = memdb;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek return EOK;
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose}
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozekstruct ccdb_mem_nextid_state {
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek unsigned int nextid;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek};
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozekstatic struct tevent_req *ccdb_mem_nextid_send(TALLOC_CTX *mem_ctx,
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek struct tevent_context *ev,
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek struct kcm_ccdb *db,
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek struct cli_creds *client)
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek{
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek struct tevent_req *req = NULL;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek struct ccdb_mem_nextid_state *state = NULL;
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose struct ccdb_mem *memdb = NULL;
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose errno_t ret;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_nextid_state);
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek if (req == NULL) {
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek return NULL;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek }
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek if (memdb == NULL) {
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek ret = EIO;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek goto immediate;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek state->nextid = memdb->nextid++;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ret = EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekimmediate:
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ret == EOK) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_done(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek } else {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_error(req, ret);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_post(req, ev);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return req;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic errno_t ccdb_mem_nextid_recv(struct tevent_req *req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek unsigned int *_nextid)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_nextid_state *state = tevent_req_data(req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_nextid_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek *_nextid = state->nextid;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstruct ccdb_mem_list_state {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t *uuid_list;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic struct tevent_req *ccdb_mem_list_send(TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_context *ev,
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_list_state *state = NULL;
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek size_t num_ccaches = 0;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek size_t cc_index = 0;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek errno_t ret;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uid_t uid;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_list_state);
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose if (req == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uid = cli_creds_get_uid(client);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DLIST_FOR_EACH(ccwrap, memdb->head) {
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek if (ccwrap->cc->owner.uid == uid) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek num_ccaches++;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik state->uuid_list = talloc_zero_array(state, uuid_t, num_ccaches+1);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (state->uuid_list == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ret = ENOMEM;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek goto immediate;
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek cc_index = 0;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DLIST_FOR_EACH(ccwrap, memdb->head) {
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik if (ccwrap->cc->owner.uid == uid) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_copy(state->uuid_list[cc_index], ccwrap->cc->uuid);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek cc_index++;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_clear(state->uuid_list[num_ccaches]);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ret = EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekimmediate:
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ret == EOK) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_done(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek } else {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_error(req, ret);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_post(req, ev);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return req;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic errno_t ccdb_mem_list_recv(struct tevent_req *req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t **_uuid_list)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_list_state *state = tevent_req_data(req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_list_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek *_uuid_list = talloc_steal(mem_ctx, state->uuid_list);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic struct tevent_req *ccdb_mem_set_default_send(TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_context *ev,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t uuid)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_dummy_state *state = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uid_t uid = cli_creds_get_uid(client);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_dummy_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (req == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return NULL;
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose }
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek /* Reset all ccache defaults first */
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DLIST_FOR_EACH(ccwrap, memdb->head) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap->cc == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek /* since KCM stores ccaches, better not crash.. */
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek continue;
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap->cc->owner.uid == uid) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ccwrap->is_default = false;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose /* Then set the default for the right ccache. This also allows to
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek * pass a null uuid to just reset the old ccache (for example after
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek * deleting the default
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek */
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ccwrap = memdb_get_by_uuid(memdb, client, uuid);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap != NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ccwrap->is_default = true;
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_done(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_post(req, ev);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return req;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic errno_t ccdb_mem_set_default_recv(struct tevent_req *req)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik TEVENT_REQ_RETURN_ON_ERROR(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnikstruct ccdb_mem_get_default_state {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t dfl_uuid;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic struct tevent_req *ccdb_mem_get_default_send(TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_context *ev,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_get_default_state *state = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uid_t uid = cli_creds_get_uid(client);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_get_default_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (req == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek /* Reset all ccache defaults first */
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DLIST_FOR_EACH(ccwrap, memdb->head) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap->cc == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek /* since KCM stores ccaches, better not crash.. */
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek continue;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap->cc->owner.uid == uid && ccwrap->is_default == true) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek break;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek DEBUG(SSSDBG_TRACE_FUNC,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek "No ccache marked as default, returning null ccache\n");
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_clear(state->dfl_uuid);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek } else {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_copy(state->dfl_uuid, ccwrap->cc->uuid);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose tevent_req_done(req);
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose tevent_req_post(req, ev);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return req;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic errno_t ccdb_mem_get_default_recv(struct tevent_req *req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t dfl)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose struct ccdb_mem_get_default_state *state = tevent_req_data(req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_get_default_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_copy(dfl, state->dfl_uuid);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return EOK;
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstruct ccdb_mem_getbyuuid_state {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccache *cc;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židekstatic struct tevent_req *ccdb_mem_getbyuuid_send(TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_context *ev,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t uuid)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek struct ccdb_mem_getbyuuid_state *state = NULL;
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek errno_t ret;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_getbyuuid_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (req == NULL) {
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik return NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ccwrap = memdb_get_by_uuid(memdb, client, uuid);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap != NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek state->cc = kcm_ccache_dup(state, ccwrap->cc);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (state->cc == NULL) {
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik ret = ENOMEM;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek goto immediate;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ret = EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekimmediate:
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ret == EOK) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_done(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek } else {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_error(req, ret);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_post(req, ev);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return req;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic errno_t ccdb_mem_getbyuuid_recv(struct tevent_req *req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccache **_cc)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_getbyuuid_state *state = tevent_req_data(req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_getbyuuid_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek *_cc = talloc_steal(mem_ctx, state->cc);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstruct ccdb_mem_getbyname_state {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccache *cc;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic struct tevent_req *ccdb_mem_getbyname_send(TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_context *ev,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek const char *name)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_getbyname_state *state = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek errno_t ret;
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_getbyname_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (req == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ccwrap = memdb_get_by_name(memdb, client, name);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ccwrap != NULL) {
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose state->cc = kcm_ccache_dup(state, ccwrap->cc);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (state->cc == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ret = ENOMEM;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek goto immediate;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek }
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek ret = EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekimmediate:
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (ret == EOK) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_done(req);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek } else {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek tevent_req_error(req, ret);
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose }
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose tevent_req_post(req, ev);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return req;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstatic errno_t ccdb_mem_getbyname_recv(struct tevent_req *req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TALLOC_CTX *mem_ctx,
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose struct kcm_ccache **_cc)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_getbyname_state *state = tevent_req_data(req,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_getbyname_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
a63d74f65db2db7389cd373cb37adcdaaa2d56eaMichal Židek *_cc = talloc_steal(mem_ctx, state->cc);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return EOK;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek}
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstruct ccdb_mem_name_by_uuid_state {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek const char *name;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek};
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozekstruct tevent_req *ccdb_mem_name_by_uuid_send(TALLOC_CTX *mem_ctx,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_context *ev,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek uuid_t uuid)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_name_by_uuid_state *state = NULL;
06d4c022874d4f12d70e79c3c749d52fe020dad6Lukas Slebodnik struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek errno_t ret;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_name_by_uuid_state);
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina if (req == NULL) {
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina return NULL;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina }
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina ccwrap = memdb_get_by_uuid(memdb, client, uuid);
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina if (ccwrap == NULL) {
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina ret = ERR_KCM_CC_END;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina goto immediate;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina }
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina state->name = talloc_strdup(state, ccwrap->cc->name);
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina if (state->name == NULL) {
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina ret = ENOMEM;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina goto immediate;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina }
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina ret = EOK;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březinaimmediate:
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina if (ret == EOK) {
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina tevent_req_done(req);
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina } else {
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina tevent_req_error(req, ret);
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina }
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina tevent_req_post(req, ev);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return req;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekerrno_t ccdb_mem_name_by_uuid_recv(struct tevent_req *req,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek TALLOC_CTX *mem_ctx,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek const char **_name)
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek{
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccdb_mem_name_by_uuid_state *state = tevent_req_data(req,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccdb_mem_name_by_uuid_state);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek *_name = talloc_steal(mem_ctx, state->name);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return EOK;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstruct ccdb_mem_uuid_by_name_state {
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek uuid_t uuid;
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek};
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekstruct tevent_req *ccdb_mem_uuid_by_name_send(TALLOC_CTX *mem_ctx,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct tevent_context *ev,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct kcm_ccdb *db,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct cli_creds *client,
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek const char *name)
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek{
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct tevent_req *req = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem_uuid_by_name_state *state = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek struct ccache_mem_wrap *ccwrap = NULL;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek errno_t ret;
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_uuid_by_name_state);
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek if (req == NULL) {
b50baee36c9ba9e1dd3f6b9c1356482aecd08128Jakub Hrozek return NULL;
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina }
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina
e16539779668dacff868999bd59dbf33e3eab872Pavel Březina ccwrap = memdb_get_by_name(memdb, client, name);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ccwrap == NULL) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek ret = ERR_KCM_CC_END;
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz goto immediate;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek uuid_copy(state->uuid, ccwrap->cc->uuid);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek ret = EOK;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekimmediate:
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek if (ret == EOK) {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek tevent_req_done(req);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek } else {
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek tevent_req_error(req, ret);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek }
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek tevent_req_post(req, ev);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return req;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozekerrno_t ccdb_mem_uuid_by_name_recv(struct tevent_req *req,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek TALLOC_CTX *mem_ctx,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek uuid_t _uuid)
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek{
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccdb_mem_uuid_by_name_state *state = tevent_req_data(req,
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek struct ccdb_mem_uuid_by_name_state);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek TEVENT_REQ_RETURN_ON_ERROR(req);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek uuid_copy(_uuid, state->uuid);
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek return EOK;
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek}
526a15438525417cd701f837d7085b7f8c8a6325Jakub Hrozek
static struct tevent_req *ccdb_mem_create_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client,
struct kcm_ccache *cc)
{
struct tevent_req *req = NULL;
struct ccdb_mem_dummy_state *state = NULL;
struct ccache_mem_wrap *ccwrap;
struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
errno_t ret;
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_dummy_state);
if (req == NULL) {
return NULL;
}
ccwrap = talloc_zero(memdb, struct ccache_mem_wrap);
if (ccwrap == NULL) {
ret = ENOMEM;
goto immediate;
}
ccwrap->cc = cc;
ccwrap->mem_be = memdb;
talloc_steal(ccwrap, cc);
DLIST_ADD(memdb->head, ccwrap);
talloc_set_destructor((TALLOC_CTX *) ccwrap, ccwrap_destructor);
ret = EOK;
immediate:
if (ret == EOK) {
tevent_req_done(req);
} else {
tevent_req_error(req, ret);
}
tevent_req_post(req, ev);
return req;
}
static errno_t ccdb_mem_create_recv(struct tevent_req *req)
{
TEVENT_REQ_RETURN_ON_ERROR(req);
return EOK;
}
static struct tevent_req *ccdb_mem_mod_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client,
uuid_t uuid,
struct kcm_mod_ctx *mod_cc)
{
errno_t ret;
struct tevent_req *req = NULL;
struct ccdb_mem_dummy_state *state = NULL;
struct ccache_mem_wrap *ccwrap = NULL;
struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_dummy_state);
if (req == NULL) {
return NULL;
}
/* UUID is immutable, so search by that */
ccwrap = memdb_get_by_uuid(memdb, client, uuid);
if (ccwrap == NULL) {
ret = ERR_KCM_CC_END;
goto immediate;
}
kcm_mod_cc(ccwrap->cc, mod_cc);
ret = EOK;
immediate:
if (ret == EOK) {
tevent_req_done(req);
} else {
tevent_req_error(req, ret);
}
tevent_req_post(req, ev);
return req;
}
static errno_t ccdb_mem_mod_recv(struct tevent_req *req)
{
TEVENT_REQ_RETURN_ON_ERROR(req);
return EOK;
}
static struct tevent_req *ccdb_mem_store_cred_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client,
uuid_t uuid,
struct sss_iobuf *cred_blob)
{
struct tevent_req *req = NULL;
struct ccdb_mem_dummy_state *state = NULL;
struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
struct ccache_mem_wrap *ccwrap = NULL;
errno_t ret;
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_dummy_state);
if (req == NULL) {
return NULL;
}
ccwrap = memdb_get_by_uuid(memdb, client, uuid);
if (ccwrap == NULL) {
ret = ERR_KCM_CC_END;
goto immediate;
}
ret = kcm_cc_store_cred_blob(ccwrap->cc, cred_blob);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
"Cannot store credentials to ccache [%d]: %s\n",
ret, sss_strerror(ret));
goto immediate;
}
ret = EOK;
immediate:
if (ret == EOK) {
tevent_req_done(req);
} else {
tevent_req_error(req, ret);
}
tevent_req_post(req, ev);
return req;
}
static errno_t ccdb_mem_store_cred_recv(struct tevent_req *req)
{
TEVENT_REQ_RETURN_ON_ERROR(req);
return EOK;
}
static struct tevent_req *ccdb_mem_delete_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client,
uuid_t uuid)
{
struct tevent_req *req = NULL;
struct ccdb_mem_dummy_state *state = NULL;
struct ccache_mem_wrap *ccwrap;
struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
errno_t ret;
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_dummy_state);
if (req == NULL) {
return NULL;
}
ccwrap = memdb_get_by_uuid(memdb, client, uuid);
if (ccwrap == NULL) {
DEBUG(SSSDBG_MINOR_FAILURE,
"BUG: Attempting to free unknown ccache\n");
ret = ERR_KCM_CC_END;
goto immediate;
}
ret = EOK;
/* Destructor takes care of everything */
talloc_free(ccwrap);
immediate:
if (ret == EOK) {
tevent_req_done(req);
} else {
tevent_req_error(req, ret);
}
tevent_req_post(req, ev);
return req;
}
static errno_t ccdb_mem_delete_recv(struct tevent_req *req)
{
TEVENT_REQ_RETURN_ON_ERROR(req);
return EOK;
}
const struct kcm_ccdb_ops ccdb_mem_ops = {
.init = ccdb_mem_init,
.nextid_send = ccdb_mem_nextid_send,
.nextid_recv = ccdb_mem_nextid_recv,
.set_default_send = ccdb_mem_set_default_send,
.set_default_recv = ccdb_mem_set_default_recv,
.get_default_send = ccdb_mem_get_default_send,
.get_default_recv = ccdb_mem_get_default_recv,
.list_send = ccdb_mem_list_send,
.list_recv = ccdb_mem_list_recv,
.getbyname_send = ccdb_mem_getbyname_send,
.getbyname_recv = ccdb_mem_getbyname_recv,
.getbyuuid_send = ccdb_mem_getbyuuid_send,
.getbyuuid_recv = ccdb_mem_getbyuuid_recv,
.name_by_uuid_send = ccdb_mem_name_by_uuid_send,
.name_by_uuid_recv = ccdb_mem_name_by_uuid_recv,
.uuid_by_name_send = ccdb_mem_uuid_by_name_send,
.uuid_by_name_recv = ccdb_mem_uuid_by_name_recv,
.create_send = ccdb_mem_create_send,
.create_recv = ccdb_mem_create_recv,
.mod_send = ccdb_mem_mod_send,
.mod_recv = ccdb_mem_mod_recv,
.store_cred_send = ccdb_mem_store_cred_send,
.store_cred_recv = ccdb_mem_store_cred_recv,
.delete_send = ccdb_mem_delete_send,
.delete_recv = ccdb_mem_delete_recv,
};