2 * Copyright (c) 2005, PADL Software Pty Ltd.
5 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of PADL Software nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include "krb5_locl.h"
39 * Client library for Kerberos Credentials Manager (KCM) daemon
45 static krb5_error_code
46 kcm_set_kdc_offset(krb5_context
, krb5_ccache
, krb5_deltat
);
48 static const char *kcm_ipc_name
= "ANY:org.h5l.kcm";
50 typedef struct krb5_kcmcache
{
54 typedef struct krb5_kcm_cursor
{
61 #define KCMCACHE(X) ((krb5_kcmcache *)(X)->data.data)
62 #define CACHENAME(X) (KCMCACHE(X)->name)
63 #define KCMCURSOR(C) ((krb5_kcm_cursor)(C))
65 static HEIMDAL_MUTEX kcm_mutex
= HEIMDAL_MUTEX_INITIALIZER
;
66 static heim_ipc kcm_ipc
= NULL
;
68 static krb5_error_code
69 kcm_send_request(krb5_context context
,
70 krb5_storage
*request
,
71 krb5_data
*response_data
)
73 krb5_error_code ret
= 0;
74 krb5_data request_data
;
76 HEIMDAL_MUTEX_lock(&kcm_mutex
);
78 ret
= heim_ipc_init_context(kcm_ipc_name
, &kcm_ipc
);
79 HEIMDAL_MUTEX_unlock(&kcm_mutex
);
81 return KRB5_CC_NOSUPP
;
83 ret
= krb5_storage_to_data(request
, &request_data
);
85 krb5_clear_error_message(context
);
89 ret
= heim_ipc_call(kcm_ipc
, &request_data
, response_data
, NULL
);
90 krb5_data_free(&request_data
);
93 krb5_clear_error_message(context
);
100 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
101 krb5_kcm_storage_request(krb5_context context
,
103 krb5_storage
**storage_p
)
110 sp
= krb5_storage_emem();
112 krb5_set_error_message(context
, KRB5_CC_NOMEM
, N_("malloc: out of memory", ""));
113 return KRB5_CC_NOMEM
;
116 /* Send MAJOR | VERSION | OPCODE */
117 ret
= krb5_store_int8(sp
, KCM_PROTOCOL_VERSION_MAJOR
);
120 ret
= krb5_store_int8(sp
, KCM_PROTOCOL_VERSION_MINOR
);
123 ret
= krb5_store_int16(sp
, opcode
);
130 krb5_set_error_message(context
, ret
,
131 N_("Failed to encode KCM request", ""));
132 krb5_storage_free(sp
);
138 static krb5_error_code
139 kcm_alloc(krb5_context context
,
145 k
= malloc(sizeof(*k
));
147 krb5_set_error_message(context
, KRB5_CC_NOMEM
,
148 N_("malloc: out of memory", ""));
149 return KRB5_CC_NOMEM
;
153 k
->name
= strdup(name
);
154 if (k
->name
== NULL
) {
156 krb5_set_error_message(context
, KRB5_CC_NOMEM
,
157 N_("malloc: out of memory", ""));
158 return KRB5_CC_NOMEM
;
163 (*id
)->data
.data
= k
;
164 (*id
)->data
.length
= sizeof(*k
);
169 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
170 krb5_kcm_call(krb5_context context
,
171 krb5_storage
*request
,
172 krb5_storage
**response_p
,
173 krb5_data
*response_data_p
)
175 krb5_data response_data
;
178 krb5_storage
*response
;
180 if (response_p
!= NULL
)
183 krb5_data_zero(&response_data
);
185 ret
= kcm_send_request(context
, request
, &response_data
);
189 response
= krb5_storage_from_data(&response_data
);
190 if (response
== NULL
) {
191 krb5_data_free(&response_data
);
195 ret
= krb5_ret_int32(response
, &status
);
197 krb5_storage_free(response
);
198 krb5_data_free(&response_data
);
199 return KRB5_CC_FORMAT
;
203 krb5_storage_free(response
);
204 krb5_data_free(&response_data
);
208 if (response_p
!= NULL
) {
209 *response_data_p
= response_data
;
210 *response_p
= response
;
215 krb5_storage_free(response
);
216 krb5_data_free(&response_data
);
222 kcm_free(krb5_context context
, krb5_ccache
*id
)
224 krb5_kcmcache
*k
= KCMCACHE(*id
);
229 memset_s(k
, sizeof(*k
), 0, sizeof(*k
));
230 krb5_data_free(&(*id
)->data
);
234 static krb5_error_code KRB5_CALLCONV
235 kcm_get_name_2(krb5_context context
,
244 * - name should be <IPC-name>:<cache-name>
245 * - col should be <IPC-name>
246 * - sub should be <cache-name>
249 *name
= CACHENAME(id
);
253 *sub
= CACHENAME(id
);
257 static krb5_error_code
258 kcm_resolve_2(krb5_context context
,
264 * For now, for KCM the `res' is the `sub'.
266 * TODO: We should use `res' as the IPC name instead of the one currently
267 * hard-coded in `kcm_ipc_name'.
269 return kcm_alloc(context
, sub
&& *sub
? sub
: res
, id
);
278 static krb5_error_code
279 kcm_gen_new(krb5_context context
, krb5_ccache
*id
)
283 krb5_storage
*request
, *response
;
284 krb5_data response_data
;
286 ret
= kcm_alloc(context
, NULL
, id
);
292 ret
= krb5_kcm_storage_request(context
, KCM_OP_GEN_NEW
, &request
);
294 kcm_free(context
, id
);
298 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
300 krb5_storage_free(request
);
301 kcm_free(context
, id
);
305 ret
= krb5_ret_stringz(response
, &k
->name
);
309 krb5_storage_free(request
);
310 krb5_storage_free(response
);
311 krb5_data_free(&response_data
);
314 kcm_free(context
, id
);
327 static krb5_error_code
328 kcm_initialize(krb5_context context
,
330 krb5_principal primary_principal
)
333 krb5_kcmcache
*k
= KCMCACHE(id
);
334 krb5_storage
*request
;
336 ret
= krb5_kcm_storage_request(context
, KCM_OP_INITIALIZE
, &request
);
340 ret
= krb5_store_stringz(request
, k
->name
);
342 krb5_storage_free(request
);
346 ret
= krb5_store_principal(request
, primary_principal
);
348 krb5_storage_free(request
);
352 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
354 krb5_storage_free(request
);
356 if (context
->kdc_sec_offset
)
357 kcm_set_kdc_offset(context
, id
, context
->kdc_sec_offset
);
362 static krb5_error_code
363 kcm_close(krb5_context context
,
366 kcm_free(context
, &id
);
377 static krb5_error_code
378 kcm_destroy(krb5_context context
,
382 krb5_kcmcache
*k
= KCMCACHE(id
);
383 krb5_storage
*request
;
385 ret
= krb5_kcm_storage_request(context
, KCM_OP_DESTROY
, &request
);
389 ret
= krb5_store_stringz(request
, k
->name
);
391 krb5_storage_free(request
);
395 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
397 krb5_storage_free(request
);
409 static krb5_error_code
410 kcm_store_cred(krb5_context context
,
415 krb5_kcmcache
*k
= KCMCACHE(id
);
416 krb5_storage
*request
;
418 ret
= krb5_kcm_storage_request(context
, KCM_OP_STORE
, &request
);
422 ret
= krb5_store_stringz(request
, k
->name
);
424 krb5_storage_free(request
);
428 ret
= krb5_store_creds(request
, creds
);
430 krb5_storage_free(request
);
434 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
436 krb5_storage_free(request
);
451 static krb5_error_code
452 kcm_retrieve(krb5_context context
,
455 const krb5_creds
*mcred
,
459 krb5_kcmcache
*k
= KCMCACHE(id
);
460 krb5_storage
*request
, *response
;
461 krb5_data response_data
;
463 ret
= krb5_kcm_storage_request(context
, KCM_OP_RETRIEVE
, &request
);
467 ret
= krb5_store_stringz(request
, k
->name
);
469 krb5_storage_free(request
);
473 ret
= krb5_store_int32(request
, which
);
475 krb5_storage_free(request
);
479 ret
= krb5_store_creds_tag(request
, rk_UNCONST(mcred
));
481 krb5_storage_free(request
);
485 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
487 krb5_storage_free(request
);
491 ret
= krb5_ret_creds(response
, creds
);
495 krb5_storage_free(request
);
496 krb5_storage_free(response
);
497 krb5_data_free(&response_data
);
510 static krb5_error_code
511 kcm_get_principal(krb5_context context
,
513 krb5_principal
*principal
)
516 krb5_kcmcache
*k
= KCMCACHE(id
);
517 krb5_storage
*request
, *response
;
518 krb5_data response_data
;
520 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_PRINCIPAL
, &request
);
524 ret
= krb5_store_stringz(request
, k
->name
);
526 krb5_storage_free(request
);
530 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
532 krb5_storage_free(request
);
536 ret
= krb5_ret_principal(response
, principal
);
540 krb5_storage_free(request
);
541 krb5_storage_free(response
);
542 krb5_data_free(&response_data
);
555 static krb5_error_code
556 kcm_get_first (krb5_context context
,
558 krb5_cc_cursor
*cursor
)
562 krb5_kcmcache
*k
= KCMCACHE(id
);
563 krb5_storage
*request
, *response
;
564 krb5_data response_data
;
566 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_CRED_UUID_LIST
, &request
);
570 ret
= krb5_store_stringz(request
, k
->name
);
572 krb5_storage_free(request
);
576 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
577 krb5_storage_free(request
);
581 c
= calloc(1, sizeof(*c
));
583 ret
= krb5_enomem(context
);
592 sret
= krb5_storage_read(response
, &uuid
, sizeof(uuid
));
596 } else if (sret
!= sizeof(uuid
)) {
601 ptr
= realloc(c
->uuids
, sizeof(c
->uuids
[0]) * (c
->length
+ 1));
605 return krb5_enomem(context
);
609 memcpy(&c
->uuids
[c
->length
], &uuid
, sizeof(uuid
));
613 krb5_storage_free(response
);
614 krb5_data_free(&response_data
);
635 static krb5_error_code
636 kcm_get_next (krb5_context context
,
638 krb5_cc_cursor
*cursor
,
642 krb5_kcmcache
*k
= KCMCACHE(id
);
643 krb5_kcm_cursor c
= KCMCURSOR(*cursor
);
644 krb5_storage
*request
, *response
;
645 krb5_data response_data
;
650 if (c
->offset
>= c
->length
)
653 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_CRED_BY_UUID
, &request
);
657 ret
= krb5_store_stringz(request
, k
->name
);
659 krb5_storage_free(request
);
663 sret
= krb5_storage_write(request
,
664 &c
->uuids
[c
->offset
],
665 sizeof(c
->uuids
[c
->offset
]));
667 if (sret
!= sizeof(c
->uuids
[c
->offset
])) {
668 krb5_storage_free(request
);
669 krb5_clear_error_message(context
);
673 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
674 krb5_storage_free(request
);
675 if (ret
== KRB5_CC_END
) {
680 ret
= krb5_ret_creds(response
, creds
);
684 krb5_storage_free(response
);
685 krb5_data_free(&response_data
);
698 static krb5_error_code
699 kcm_end_get (krb5_context context
,
701 krb5_cc_cursor
*cursor
)
703 krb5_kcm_cursor c
= KCMCURSOR(*cursor
);
722 static krb5_error_code
723 kcm_remove_cred(krb5_context context
,
729 krb5_kcmcache
*k
= KCMCACHE(id
);
730 krb5_storage
*request
;
732 ret
= krb5_kcm_storage_request(context
, KCM_OP_REMOVE_CRED
, &request
);
736 ret
= krb5_store_stringz(request
, k
->name
);
738 krb5_storage_free(request
);
742 ret
= krb5_store_int32(request
, which
);
744 krb5_storage_free(request
);
748 ret
= krb5_store_creds_tag(request
, cred
);
750 krb5_storage_free(request
);
754 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
756 krb5_storage_free(request
);
760 static krb5_error_code
761 kcm_set_flags(krb5_context context
,
766 krb5_kcmcache
*k
= KCMCACHE(id
);
767 krb5_storage
*request
;
769 ret
= krb5_kcm_storage_request(context
, KCM_OP_SET_FLAGS
, &request
);
773 ret
= krb5_store_stringz(request
, k
->name
);
775 krb5_storage_free(request
);
779 ret
= krb5_store_int32(request
, flags
);
781 krb5_storage_free(request
);
785 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
787 krb5_storage_free(request
);
792 kcm_get_version(krb5_context context
,
800 * get back list of uuids
803 static krb5_error_code
804 kcm_get_cache_first(krb5_context context
, krb5_cc_cursor
*cursor
)
808 krb5_storage
*request
, *response
;
809 krb5_data response_data
;
813 c
= calloc(1, sizeof(*c
));
815 ret
= krb5_enomem(context
);
819 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_CACHE_UUID_LIST
, &request
);
823 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
824 krb5_storage_free(request
);
833 sret
= krb5_storage_read(response
, &uuid
, sizeof(uuid
));
837 } else if (sret
!= sizeof(uuid
)) {
842 ptr
= realloc(c
->uuids
, sizeof(c
->uuids
[0]) * (c
->length
+ 1));
844 ret
= krb5_enomem(context
);
849 memcpy(&c
->uuids
[c
->length
], &uuid
, sizeof(uuid
));
853 krb5_storage_free(response
);
854 krb5_data_free(&response_data
);
871 static krb5_error_code
872 kcm_get_cache_next(krb5_context context
, krb5_cc_cursor cursor
, const krb5_cc_ops
*ops
, krb5_ccache
*id
)
875 krb5_kcm_cursor c
= KCMCURSOR(cursor
);
876 krb5_storage
*request
, *response
;
877 krb5_data response_data
;
885 if (c
->offset
>= c
->length
)
888 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_CACHE_BY_UUID
, &request
);
892 sret
= krb5_storage_write(request
,
893 &c
->uuids
[c
->offset
],
894 sizeof(c
->uuids
[c
->offset
]));
896 if (sret
!= sizeof(c
->uuids
[c
->offset
])) {
897 krb5_storage_free(request
);
898 krb5_clear_error_message(context
);
902 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
903 krb5_storage_free(request
);
904 if (ret
== KRB5_CC_END
)
909 ret
= krb5_ret_stringz(response
, &name
);
910 krb5_storage_free(response
);
911 krb5_data_free(&response_data
);
914 ret
= _krb5_cc_allocate(context
, ops
, id
);
916 ret
= kcm_alloc(context
, name
, id
);
923 static krb5_error_code
924 kcm_get_cache_next_kcm(krb5_context context
, krb5_cc_cursor cursor
, krb5_ccache
*id
)
926 #ifndef KCM_IS_API_CACHE
927 return kcm_get_cache_next(context
, cursor
, &krb5_kcm_ops
, id
);
933 static krb5_error_code
934 kcm_get_cache_next_api(krb5_context context
, krb5_cc_cursor cursor
, krb5_ccache
*id
)
936 return kcm_get_cache_next(context
, cursor
, &krb5_akcm_ops
, id
);
940 static krb5_error_code
941 kcm_end_cache_get(krb5_context context
, krb5_cc_cursor cursor
)
943 krb5_kcm_cursor c
= KCMCURSOR(cursor
);
951 static krb5_error_code
952 kcm_move(krb5_context context
, krb5_ccache from
, krb5_ccache to
)
955 krb5_kcmcache
*oldk
= KCMCACHE(from
);
956 krb5_kcmcache
*newk
= KCMCACHE(to
);
957 krb5_storage
*request
;
959 ret
= krb5_kcm_storage_request(context
, KCM_OP_MOVE_CACHE
, &request
);
963 ret
= krb5_store_stringz(request
, oldk
->name
);
965 krb5_storage_free(request
);
969 ret
= krb5_store_stringz(request
, newk
->name
);
971 krb5_storage_free(request
);
974 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
976 krb5_storage_free(request
);
979 krb5_cc_destroy(context
, from
);
983 static krb5_error_code
984 kcm_get_default_name(krb5_context context
, const krb5_cc_ops
*ops
,
985 const char *defstr
, char **str
)
988 krb5_storage
*request
, *response
;
989 krb5_data response_data
;
995 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_DEFAULT_CACHE
, &request
);
999 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
1000 krb5_storage_free(request
);
1002 return _krb5_expand_default_cc_name(context
, defstr
, str
);
1004 ret
= krb5_ret_stringz(response
, &name
);
1005 krb5_storage_free(response
);
1006 krb5_data_free(&response_data
);
1010 aret
= asprintf(str
, "%s:%s", ops
->prefix
, name
);
1012 if (aret
== -1 || str
== NULL
)
1018 static krb5_error_code
1019 kcm_get_default_name_api(krb5_context context
, char **str
)
1021 return kcm_get_default_name(context
, &krb5_akcm_ops
,
1022 KRB5_DEFAULT_CCNAME_KCM_API
, str
);
1025 static krb5_error_code
1026 kcm_get_default_name_kcm(krb5_context context
, char **str
)
1028 return kcm_get_default_name(context
, &krb5_kcm_ops
,
1029 KRB5_DEFAULT_CCNAME_KCM_KCM
, str
);
1032 static krb5_error_code
1033 kcm_set_default(krb5_context context
, krb5_ccache id
)
1035 krb5_error_code ret
;
1036 krb5_storage
*request
;
1037 krb5_kcmcache
*k
= KCMCACHE(id
);
1039 ret
= krb5_kcm_storage_request(context
, KCM_OP_SET_DEFAULT_CACHE
, &request
);
1043 ret
= krb5_store_stringz(request
, k
->name
);
1045 krb5_storage_free(request
);
1049 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
1050 krb5_storage_free(request
);
1055 static krb5_error_code
1056 kcm_lastchange(krb5_context context
, krb5_ccache id
, krb5_timestamp
*mtime
)
1058 *mtime
= time(NULL
);
1062 static krb5_error_code
1063 kcm_set_kdc_offset(krb5_context context
, krb5_ccache id
, krb5_deltat kdc_offset
)
1065 krb5_kcmcache
*k
= KCMCACHE(id
);
1066 krb5_error_code ret
;
1067 krb5_storage
*request
;
1069 ret
= krb5_kcm_storage_request(context
, KCM_OP_SET_KDC_OFFSET
, &request
);
1073 ret
= krb5_store_stringz(request
, k
->name
);
1075 krb5_storage_free(request
);
1078 ret
= krb5_store_int32(request
, kdc_offset
);
1080 krb5_storage_free(request
);
1084 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
1085 krb5_storage_free(request
);
1090 static krb5_error_code
1091 kcm_get_kdc_offset(krb5_context context
, krb5_ccache id
, krb5_deltat
*kdc_offset
)
1093 krb5_kcmcache
*k
= KCMCACHE(id
);
1094 krb5_error_code ret
;
1095 krb5_storage
*request
, *response
;
1096 krb5_data response_data
;
1099 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_KDC_OFFSET
, &request
);
1103 ret
= krb5_store_stringz(request
, k
->name
);
1105 krb5_storage_free(request
);
1109 ret
= krb5_kcm_call(context
, request
, &response
, &response_data
);
1110 krb5_storage_free(request
);
1114 ret
= krb5_ret_int32(response
, &offset
);
1115 krb5_storage_free(response
);
1116 krb5_data_free(&response_data
);
1120 *kdc_offset
= offset
;
1126 * Variable containing the KCM based credential cache implemention.
1128 * @ingroup krb5_ccache
1131 KRB5_LIB_VARIABLE
const krb5_cc_ops krb5_kcm_ops
= {
1132 KRB5_CC_OPS_VERSION_5
,
1141 NULL
/* kcm_retrieve */,
1149 kcm_get_cache_first
,
1150 kcm_get_cache_next_kcm
,
1153 kcm_get_default_name_kcm
,
1162 KRB5_LIB_VARIABLE
const krb5_cc_ops krb5_akcm_ops
= {
1163 KRB5_CC_OPS_VERSION_5
,
1172 NULL
/* kcm_retrieve */,
1180 kcm_get_cache_first
,
1181 kcm_get_cache_next_api
,
1184 kcm_get_default_name_api
,
1194 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
1195 _krb5_kcm_is_running(krb5_context context
)
1197 krb5_error_code ret
;
1198 krb5_ccache_data ccdata
;
1199 krb5_ccache id
= &ccdata
;
1200 krb5_boolean running
;
1202 ret
= kcm_alloc(context
, NULL
, &id
);
1206 running
= (_krb5_kcm_noop(context
, id
) == 0);
1208 kcm_free(context
, &id
);
1219 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
1220 _krb5_kcm_noop(krb5_context context
,
1223 krb5_error_code ret
;
1224 krb5_storage
*request
;
1226 ret
= krb5_kcm_storage_request(context
, KCM_OP_NOOP
, &request
);
1230 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
1232 krb5_storage_free(request
);
1240 * ServerPrincipalPresent
1241 * ServerPrincipal OPTIONAL
1247 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
1248 _krb5_kcm_get_initial_ticket(krb5_context context
,
1250 krb5_principal server
,
1253 krb5_kcmcache
*k
= KCMCACHE(id
);
1254 krb5_error_code ret
;
1255 krb5_storage
*request
;
1257 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_INITIAL_TICKET
, &request
);
1261 ret
= krb5_store_stringz(request
, k
->name
);
1263 krb5_storage_free(request
);
1267 ret
= krb5_store_int8(request
, (server
== NULL
) ? 0 : 1);
1269 krb5_storage_free(request
);
1273 if (server
!= NULL
) {
1274 ret
= krb5_store_principal(request
, server
);
1276 krb5_storage_free(request
);
1281 ret
= krb5_store_keyblock(request
, *key
);
1283 krb5_storage_free(request
);
1287 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
1289 krb5_storage_free(request
);
1304 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
1305 _krb5_kcm_get_ticket(krb5_context context
,
1307 krb5_kdc_flags flags
,
1308 krb5_enctype enctype
,
1309 krb5_principal server
)
1311 krb5_error_code ret
;
1312 krb5_kcmcache
*k
= KCMCACHE(id
);
1313 krb5_storage
*request
;
1315 ret
= krb5_kcm_storage_request(context
, KCM_OP_GET_TICKET
, &request
);
1319 ret
= krb5_store_stringz(request
, k
->name
);
1321 krb5_storage_free(request
);
1325 ret
= krb5_store_int32(request
, flags
.i
);
1327 krb5_storage_free(request
);
1331 ret
= krb5_store_int32(request
, enctype
);
1333 krb5_storage_free(request
);
1337 ret
= krb5_store_principal(request
, server
);
1339 krb5_storage_free(request
);
1343 ret
= krb5_kcm_call(context
, request
, NULL
, NULL
);
1345 krb5_storage_free(request
);
1349 #endif /* HAVE_KCM */