1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
|
/*
SSSD
KCM Server - ccache in-memory storage
Copyright (C) Red Hat, 2016
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <talloc.h>
#include <stdio.h>
#include "util/util.h"
#include "responder/kcm/kcmsrv_ccache_pvt.h"
#include "responder/kcm/kcmsrv_ccache_be.h"
struct ccdb_mem;
/*
* The KCM memory database is just a double-linked list of kcm_ccache structures
*/
struct ccache_mem_wrap {
struct kcm_ccache *cc;
bool is_default;
struct ccache_mem_wrap *next;
struct ccache_mem_wrap *prev;
struct ccdb_mem *mem_be;
};
struct ccdb_mem {
/* Both ccaches and the next-id are kept in memory */
struct ccache_mem_wrap *head;
unsigned int nextid;
};
static struct ccache_mem_wrap *memdb_get_by_uuid(struct ccdb_mem *memdb,
struct cli_creds *client,
uuid_t uuid)
{
uid_t uid;
struct ccache_mem_wrap *ccwrap = NULL;
struct ccache_mem_wrap *out = NULL;
uid = cli_creds_get_uid(client);
DLIST_FOR_EACH(ccwrap, memdb->head) {
if (ccwrap->cc == NULL) {
/* since KCM stores ccaches, better not crash.. */
DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
continue;
}
if (ccwrap->cc->owner.uid == uid) {
if (uuid_compare(uuid, ccwrap->cc->uuid) == 0) {
out = ccwrap;
break;
}
}
}
return out;
}
static struct ccache_mem_wrap *memdb_get_by_name(struct ccdb_mem *memdb,
struct cli_creds *client,
const char *name)
{
uid_t uid;
struct ccache_mem_wrap *ccwrap = NULL;
struct ccache_mem_wrap *out = NULL;
uid = cli_creds_get_uid(client);
DLIST_FOR_EACH(ccwrap, memdb->head) {
if (ccwrap->cc == NULL) {
/* since KCM stores ccaches, better not crash.. */
DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
continue;
}
if (ccwrap->cc->owner.uid == uid) {
if (strcmp(ccwrap->cc->name, name) == 0) {
out = ccwrap;
break;
}
}
}
return out;
}
/* Since with the in-memory database, the database operations are just
* fake-async wrappers around otherwise sync operations, we don't often
* need any state, so we use this empty structure instead
*/
struct ccdb_mem_dummy_state {
};
static int ccwrap_destructor(void *ptr)
{
struct ccache_mem_wrap *ccwrap = talloc_get_type(ptr, struct ccache_mem_wrap);
if (ccwrap == NULL) {
return 0;
}
if (ccwrap->cc != NULL) {
if (ccwrap->cc->creds) {
sss_erase_mem_securely(
sss_iobuf_get_data(ccwrap->cc->creds->cred_blob),
sss_iobuf_get_size(ccwrap->cc->creds->cred_blob));
}
}
DLIST_REMOVE(ccwrap->mem_be->head, ccwrap);
return 0;
}
static errno_t ccdb_mem_init(struct kcm_ccdb *db,
struct confdb_ctx *cdb,
const char *confdb_service_path)
{
struct ccdb_mem *memdb = NULL;
memdb = talloc_zero(db, struct ccdb_mem);
if (memdb == NULL) {
return ENOMEM;
}
db->db_handle = memdb;
return EOK;
}
struct ccdb_mem_nextid_state {
unsigned int nextid;
};
static struct tevent_req *ccdb_mem_nextid_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client)
{
struct tevent_req *req = NULL;
struct ccdb_mem_nextid_state *state = NULL;
struct ccdb_mem *memdb = NULL;
errno_t ret;
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_nextid_state);
if (req == NULL) {
return NULL;
}
memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
if (memdb == NULL) {
ret = EIO;
goto immediate;
}
state->nextid = memdb->nextid++;
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_nextid_recv(struct tevent_req *req,
unsigned int *_nextid)
{
struct ccdb_mem_nextid_state *state = tevent_req_data(req,
struct ccdb_mem_nextid_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
*_nextid = state->nextid;
return EOK;
}
struct ccdb_mem_list_state {
uuid_t *uuid_list;
};
static struct tevent_req *ccdb_mem_list_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client)
{
struct tevent_req *req = NULL;
struct ccache_mem_wrap *ccwrap = NULL;
struct ccdb_mem_list_state *state = NULL;
struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
size_t num_ccaches = 0;
size_t cc_index = 0;
errno_t ret;
uid_t uid;
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_list_state);
if (req == NULL) {
return NULL;
}
uid = cli_creds_get_uid(client);
DLIST_FOR_EACH(ccwrap, memdb->head) {
if (ccwrap->cc->owner.uid == uid) {
num_ccaches++;
}
}
state->uuid_list = talloc_zero_array(state, uuid_t, num_ccaches+1);
if (state->uuid_list == NULL) {
ret = ENOMEM;
goto immediate;
}
cc_index = 0;
DLIST_FOR_EACH(ccwrap, memdb->head) {
if (ccwrap->cc->owner.uid == uid) {
uuid_copy(state->uuid_list[cc_index], ccwrap->cc->uuid);
cc_index++;
}
}
uuid_clear(state->uuid_list[num_ccaches]);
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_list_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
uuid_t **_uuid_list)
{
struct ccdb_mem_list_state *state = tevent_req_data(req,
struct ccdb_mem_list_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
*_uuid_list = talloc_steal(mem_ctx, state->uuid_list);
return EOK;
}
static struct tevent_req *ccdb_mem_set_default_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 ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
struct ccache_mem_wrap *ccwrap = NULL;
uid_t uid = cli_creds_get_uid(client);
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_dummy_state);
if (req == NULL) {
return NULL;
}
/* Reset all ccache defaults first */
DLIST_FOR_EACH(ccwrap, memdb->head) {
if (ccwrap->cc == NULL) {
/* since KCM stores ccaches, better not crash.. */
DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
continue;
}
if (ccwrap->cc->owner.uid == uid) {
ccwrap->is_default = false;
}
}
/* Then set the default for the right ccache. This also allows to
* pass a null uuid to just reset the old ccache (for example after
* deleting the default
*/
ccwrap = memdb_get_by_uuid(memdb, client, uuid);
if (ccwrap != NULL) {
ccwrap->is_default = true;
}
tevent_req_done(req);
tevent_req_post(req, ev);
return req;
}
static errno_t ccdb_mem_set_default_recv(struct tevent_req *req)
{
TEVENT_REQ_RETURN_ON_ERROR(req);
return EOK;
}
struct ccdb_mem_get_default_state {
uuid_t dfl_uuid;
};
static struct tevent_req *ccdb_mem_get_default_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client)
{
struct tevent_req *req = NULL;
struct ccdb_mem_get_default_state *state = NULL;
struct ccache_mem_wrap *ccwrap = NULL;
struct ccdb_mem *memdb = talloc_get_type(db->db_handle, struct ccdb_mem);
uid_t uid = cli_creds_get_uid(client);
req = tevent_req_create(mem_ctx, &state, struct ccdb_mem_get_default_state);
if (req == NULL) {
return NULL;
}
/* Reset all ccache defaults first */
DLIST_FOR_EACH(ccwrap, memdb->head) {
if (ccwrap->cc == NULL) {
/* since KCM stores ccaches, better not crash.. */
DEBUG(SSSDBG_CRIT_FAILURE, "BUG: ccwrap contains NULL cc\n");
continue;
}
if (ccwrap->cc->owner.uid == uid && ccwrap->is_default == true) {
break;
}
}
if (ccwrap == NULL) {
DEBUG(SSSDBG_TRACE_FUNC,
"No ccache marked as default, returning null ccache\n");
uuid_clear(state->dfl_uuid);
} else {
uuid_copy(state->dfl_uuid, ccwrap->cc->uuid);
}
tevent_req_done(req);
tevent_req_post(req, ev);
return req;
}
static errno_t ccdb_mem_get_default_recv(struct tevent_req *req,
uuid_t dfl)
{
struct ccdb_mem_get_default_state *state = tevent_req_data(req,
struct ccdb_mem_get_default_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
uuid_copy(dfl, state->dfl_uuid);
return EOK;
}
struct ccdb_mem_getbyuuid_state {
struct kcm_ccache *cc;
};
static struct tevent_req *ccdb_mem_getbyuuid_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_getbyuuid_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_getbyuuid_state);
if (req == NULL) {
return NULL;
}
ccwrap = memdb_get_by_uuid(memdb, client, uuid);
if (ccwrap != NULL) {
/* In order to provide a consistent interface, we need to let the caller
* of getbyXXX own the ccache, therefore the memory back end returns a shallow
* copy of the ccache
*/
state->cc = kcm_cc_dup(state, ccwrap->cc);
if (state->cc == NULL) {
ret = ENOMEM;
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_getbyuuid_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct kcm_ccache **_cc)
{
struct ccdb_mem_getbyuuid_state *state = tevent_req_data(req,
struct ccdb_mem_getbyuuid_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
*_cc = talloc_steal(mem_ctx, state->cc);
return EOK;
}
struct ccdb_mem_getbyname_state {
struct kcm_ccache *cc;
};
static struct tevent_req *ccdb_mem_getbyname_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client,
const char *name)
{
struct tevent_req *req = NULL;
struct ccdb_mem_getbyname_state *state = NULL;
struct ccache_mem_wrap *ccwrap = NULL;
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_getbyname_state);
if (req == NULL) {
return NULL;
}
ccwrap = memdb_get_by_name(memdb, client, name);
if (ccwrap != NULL) {
/* In order to provide a consistent interface, we need to let the caller
* of getbyXXX own the ccache, therefore the memory back end returns a shallow
* copy of the ccache
*/
state->cc = kcm_cc_dup(state, ccwrap->cc);
if (state->cc == NULL) {
ret = ENOMEM;
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_getbyname_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
struct kcm_ccache **_cc)
{
struct ccdb_mem_getbyname_state *state = tevent_req_data(req,
struct ccdb_mem_getbyname_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
*_cc = talloc_steal(mem_ctx, state->cc);
return EOK;
}
struct ccdb_mem_name_by_uuid_state {
const char *name;
};
struct tevent_req *ccdb_mem_name_by_uuid_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_name_by_uuid_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_name_by_uuid_state);
if (req == NULL) {
return NULL;
}
ccwrap = memdb_get_by_uuid(memdb, client, uuid);
if (ccwrap == NULL) {
ret = ERR_KCM_CC_END;
goto immediate;
}
state->name = talloc_strdup(state, ccwrap->cc->name);
if (state->name == NULL) {
ret = ENOMEM;
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;
}
errno_t ccdb_mem_name_by_uuid_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
const char **_name)
{
struct ccdb_mem_name_by_uuid_state *state = tevent_req_data(req,
struct ccdb_mem_name_by_uuid_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
*_name = talloc_steal(mem_ctx, state->name);
return EOK;
}
struct ccdb_mem_uuid_by_name_state {
uuid_t uuid;
};
struct tevent_req *ccdb_mem_uuid_by_name_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct kcm_ccdb *db,
struct cli_creds *client,
const char *name)
{
struct tevent_req *req = NULL;
struct ccdb_mem_uuid_by_name_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_uuid_by_name_state);
if (req == NULL) {
return NULL;
}
ccwrap = memdb_get_by_name(memdb, client, name);
if (ccwrap == NULL) {
ret = ERR_NO_CREDS;
goto immediate;
}
uuid_copy(state->uuid, ccwrap->cc->uuid);
ret = EOK;
immediate:
if (ret == EOK) {
tevent_req_done(req);
} else {
tevent_req_error(req, ret);
}
tevent_req_post(req, ev);
return req;
}
errno_t ccdb_mem_uuid_by_name_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
uuid_t _uuid)
{
struct ccdb_mem_uuid_by_name_state *state = tevent_req_data(req,
struct ccdb_mem_uuid_by_name_state);
TEVENT_REQ_RETURN_ON_ERROR(req);
uuid_copy(_uuid, state->uuid);
return EOK;
}
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;
}
ret = kcm_mod_cc(ccwrap->cc, mod_cc);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
"Cannot modify 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_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,
};
|