1 /* $NetBSD: keytab.c,v 1.1.1.2 2014/04/24 12:45:50 pettai Exp $ */
4 * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
5 * (Royal Institute of Technology, Stockholm, Sweden).
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include "krb5_locl.h"
39 * @page krb5_keytab_intro The keytab handing functions
40 * @section section_krb5_keytab Kerberos Keytabs
42 * See the library functions here: @ref krb5_keytab
44 * Keytabs are long term key storage for servers, their equvalment of
47 * Normally the only function that useful for server are to specify
48 * what keytab to use to other core functions like krb5_rd_req()
49 * krb5_kt_resolve(), and krb5_kt_close().
51 * @subsection krb5_keytab_names Keytab names
53 * A keytab name is on the form type:residual. The residual part is
54 * specific to each keytab-type.
56 * When a keytab-name is resolved, the type is matched with an internal
57 * list of keytab types. If there is no matching keytab type,
58 * the default keytab is used. The current default type is FILE.
60 * The default value can be changed in the configuration file
61 * /etc/krb5.conf by setting the variable
62 * [defaults]default_keytab_name.
64 * The keytab types that are implemented in Heimdal are:
66 * store the keytab in a file, the type's name is FILE . The
67 * residual part is a filename. For compatibility with other
68 * Kerberos implemtation WRFILE and JAVA14 is also accepted. WRFILE
69 * has the same format as FILE. JAVA14 have a format that is
70 * compatible with older versions of MIT kerberos and SUN's Java
71 * based installation. They store a truncted kvno, so when the knvo
72 * excess 255, they are truncted in this format.
75 * store the keytab in a AFS keyfile (usually /usr/afs/etc/KeyFile ),
76 * the type's name is AFSKEYFILE. The residual part is a filename.
79 * The keytab is stored in a memory segment. This allows sensitive
80 * and/or temporary data not to be stored on disk. The type's name
81 * is MEMORY. Each MEMORY keytab is referenced counted by and
82 * opened by the residual name, so two handles can point to the
83 * same memory area. When the last user closes using krb5_kt_close()
84 * the keytab, the keys in they keytab is memset() to zero and freed
85 * and can no longer be looked up by name.
88 * @subsection krb5_keytab_example Keytab example
90 * This is a minimalistic version of ktutil.
94 main (int argc, char **argv)
98 krb5_kt_cursor cursor;
99 krb5_keytab_entry entry;
103 if (krb5_init_context (&context) != 0)
104 errx(1, "krb5_context");
106 ret = krb5_kt_default (context, &keytab);
108 krb5_err(context, 1, ret, "krb5_kt_default");
110 ret = krb5_kt_start_seq_get(context, keytab, &cursor);
112 krb5_err(context, 1, ret, "krb5_kt_start_seq_get");
113 while((ret = krb5_kt_next_entry(context, keytab, &entry, &cursor)) == 0){
114 krb5_unparse_name(context, entry.principal, &principal);
115 printf("principal: %s\n", principal);
117 krb5_kt_free_entry(context, &entry);
119 ret = krb5_kt_end_seq_get(context, keytab, &cursor);
121 krb5_err(context, 1, ret, "krb5_kt_end_seq_get");
122 ret = krb5_kt_close(context, keytab);
124 krb5_err(context, 1, ret, "krb5_kt_close");
125 krb5_free_context(context);
134 * Register a new keytab backend.
136 * @param context a Keberos context.
137 * @param ops a backend to register.
139 * @return Return an error code or 0, see krb5_get_error_message().
141 * @ingroup krb5_keytab
144 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
145 krb5_kt_register(krb5_context context
,
146 const krb5_kt_ops
*ops
)
148 struct krb5_keytab_data
*tmp
;
150 if (strlen(ops
->prefix
) > KRB5_KT_PREFIX_MAX_LEN
- 1) {
151 krb5_set_error_message(context
, KRB5_KT_BADNAME
,
152 N_("can't register cache type, prefix too long", ""));
153 return KRB5_KT_BADNAME
;
156 tmp
= realloc(context
->kt_types
,
157 (context
->num_kt_types
+ 1) * sizeof(*context
->kt_types
));
159 krb5_set_error_message(context
, ENOMEM
,
160 N_("malloc: out of memory", ""));
163 memcpy(&tmp
[context
->num_kt_types
], ops
,
164 sizeof(tmp
[context
->num_kt_types
]));
165 context
->kt_types
= tmp
;
166 context
->num_kt_types
++;
171 keytab_name(const char *name
, const char **type
, size_t *type_len
)
173 const char *residual
;
175 residual
= strchr(name
, ':');
177 if (residual
== NULL
||
180 /* Avoid treating <drive>:<path> as a keytab type
182 || name
+ 1 == residual
187 *type_len
= strlen(*type
);
191 *type_len
= residual
- name
;
199 * Resolve the keytab name (of the form `type:residual') in `name'
200 * into a keytab in `id'.
202 * @param context a Keberos context.
203 * @param name name to resolve
204 * @param id resulting keytab, free with krb5_kt_close().
206 * @return Return an error code or 0, see krb5_get_error_message().
208 * @ingroup krb5_keytab
212 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
213 krb5_kt_resolve(krb5_context context
,
219 const char *type
, *residual
;
223 residual
= keytab_name(name
, &type
, &type_len
);
225 for(i
= 0; i
< context
->num_kt_types
; i
++) {
226 if(strncasecmp(type
, context
->kt_types
[i
].prefix
, type_len
) == 0)
229 if(i
== context
->num_kt_types
) {
230 krb5_set_error_message(context
, KRB5_KT_UNKNOWN_TYPE
,
231 N_("unknown keytab type %.*s", "type"),
232 (int)type_len
, type
);
233 return KRB5_KT_UNKNOWN_TYPE
;
236 k
= malloc (sizeof(*k
));
238 krb5_set_error_message(context
, ENOMEM
, N_("malloc: out of memory", ""));
241 memcpy(k
, &context
->kt_types
[i
], sizeof(*k
));
243 ret
= (*k
->resolve
)(context
, residual
, k
);
253 * copy the name of the default keytab into `name'.
255 * @param context a Keberos context.
256 * @param name buffer where the name will be written
257 * @param namesize length of name
259 * @return Return an error code or 0, see krb5_get_error_message().
261 * @ingroup krb5_keytab
264 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
265 krb5_kt_default_name(krb5_context context
, char *name
, size_t namesize
)
267 if (strlcpy (name
, context
->default_keytab
, namesize
) >= namesize
) {
268 krb5_clear_error_message (context
);
269 return KRB5_CONFIG_NOTENUFSPACE
;
275 * Copy the name of the default modify keytab into `name'.
277 * @param context a Keberos context.
278 * @param name buffer where the name will be written
279 * @param namesize length of name
281 * @return Return an error code or 0, see krb5_get_error_message().
283 * @ingroup krb5_keytab
286 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
287 krb5_kt_default_modify_name(krb5_context context
, char *name
, size_t namesize
)
289 const char *kt
= NULL
;
290 if(context
->default_keytab_modify
== NULL
) {
291 if(strncasecmp(context
->default_keytab
, "ANY:", 4) != 0)
292 kt
= context
->default_keytab
;
294 size_t len
= strcspn(context
->default_keytab
+ 4, ",");
295 if(len
>= namesize
) {
296 krb5_clear_error_message(context
);
297 return KRB5_CONFIG_NOTENUFSPACE
;
299 strlcpy(name
, context
->default_keytab
+ 4, namesize
);
304 kt
= context
->default_keytab_modify
;
305 if (strlcpy (name
, kt
, namesize
) >= namesize
) {
306 krb5_clear_error_message (context
);
307 return KRB5_CONFIG_NOTENUFSPACE
;
313 * Set `id' to the default keytab.
315 * @param context a Keberos context.
316 * @param id the new default keytab.
318 * @return Return an error code or 0, see krb5_get_error_message().
320 * @ingroup krb5_keytab
323 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
324 krb5_kt_default(krb5_context context
, krb5_keytab
*id
)
326 return krb5_kt_resolve (context
, context
->default_keytab
, id
);
330 * Read the key identified by `(principal, vno, enctype)' from the
331 * keytab in `keyprocarg' (the default if == NULL) into `*key'.
333 * @param context a Keberos context.
340 * @return Return an error code or 0, see krb5_get_error_message().
342 * @ingroup krb5_keytab
345 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
346 krb5_kt_read_service_key(krb5_context context
,
347 krb5_pointer keyprocarg
,
348 krb5_principal principal
,
350 krb5_enctype enctype
,
354 krb5_keytab_entry entry
;
358 ret
= krb5_kt_resolve (context
, keyprocarg
, &keytab
);
360 ret
= krb5_kt_default (context
, &keytab
);
365 ret
= krb5_kt_get_entry (context
, keytab
, principal
, vno
, enctype
, &entry
);
366 krb5_kt_close (context
, keytab
);
369 ret
= krb5_copy_keyblock (context
, &entry
.keyblock
, key
);
370 krb5_kt_free_entry(context
, &entry
);
375 * Return the type of the `keytab' in the string `prefix of length
378 * @param context a Keberos context.
379 * @param keytab the keytab to get the prefix for
380 * @param prefix prefix buffer
381 * @param prefixsize length of prefix buffer
383 * @return Return an error code or 0, see krb5_get_error_message().
385 * @ingroup krb5_keytab
388 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
389 krb5_kt_get_type(krb5_context context
,
394 strlcpy(prefix
, keytab
->prefix
, prefixsize
);
399 * Retrieve the name of the keytab `keytab' into `name', `namesize'
401 * @param context a Keberos context.
402 * @param keytab the keytab to get the name for.
403 * @param name name buffer.
404 * @param namesize size of name buffer.
406 * @return Return an error code or 0, see krb5_get_error_message().
408 * @ingroup krb5_keytab
411 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
412 krb5_kt_get_name(krb5_context context
,
417 return (*keytab
->get_name
)(context
, keytab
, name
, namesize
);
421 * Retrieve the full name of the keytab `keytab' and store the name in
424 * @param context a Keberos context.
425 * @param keytab keytab to get name for.
426 * @param str the name of the keytab name, usee krb5_xfree() to free
427 * the string. On error, *str is set to NULL.
429 * @return Return an error code or 0, see krb5_get_error_message().
431 * @ingroup krb5_keytab
434 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
435 krb5_kt_get_full_name(krb5_context context
,
439 char type
[KRB5_KT_PREFIX_MAX_LEN
];
440 char name
[MAXPATHLEN
];
445 ret
= krb5_kt_get_type(context
, keytab
, type
, sizeof(type
));
449 ret
= krb5_kt_get_name(context
, keytab
, name
, sizeof(name
));
453 if (asprintf(str
, "%s:%s", type
, name
) == -1) {
454 krb5_set_error_message(context
, ENOMEM
, N_("malloc: out of memory", ""));
463 * Finish using the keytab in `id'. All resources will be released,
466 * @param context a Keberos context.
467 * @param id keytab to close.
469 * @return Return an error code or 0, see krb5_get_error_message().
471 * @ingroup krb5_keytab
474 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
475 krb5_kt_close(krb5_context context
,
480 ret
= (*id
->close
)(context
, id
);
481 memset(id
, 0, sizeof(*id
));
487 * Destroy (remove) the keytab in `id'. All resources will be released,
488 * even on errors, does the equvalment of krb5_kt_close() on the resources.
490 * @param context a Keberos context.
491 * @param id keytab to destroy.
493 * @return Return an error code or 0, see krb5_get_error_message().
495 * @ingroup krb5_keytab
498 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
499 krb5_kt_destroy(krb5_context context
,
504 ret
= (*id
->destroy
)(context
, id
);
505 krb5_kt_close(context
, id
);
510 * Match any aliases in keytab `entry' with `principal'.
514 compare_aliseses(krb5_context context
,
515 krb5_keytab_entry
*entry
,
516 krb5_const_principal principal
)
519 if (entry
->aliases
== NULL
)
521 for (i
= 0; i
< entry
->aliases
->len
; i
++)
522 if (krb5_principal_compare(context
, &entry
->aliases
->val
[i
], principal
))
528 * Compare `entry' against `principal, vno, enctype'.
529 * Any of `principal, vno, enctype' might be 0 which acts as a wildcard.
530 * Return TRUE if they compare the same, FALSE otherwise.
532 * @param context a Keberos context.
533 * @param entry an entry to match with.
534 * @param principal principal to match, NULL matches all principals.
535 * @param vno key version to match, 0 matches all key version numbers.
536 * @param enctype encryption type to match, 0 matches all encryption types.
538 * @return Return TRUE or match, FALSE if not matched.
540 * @ingroup krb5_keytab
543 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
544 krb5_kt_compare(krb5_context context
,
545 krb5_keytab_entry
*entry
,
546 krb5_const_principal principal
,
548 krb5_enctype enctype
)
550 if(principal
!= NULL
&&
551 !(krb5_principal_compare(context
, entry
->principal
, principal
) ||
552 compare_aliseses(context
, entry
, principal
)))
554 if(vno
&& vno
!= entry
->vno
)
556 if(enctype
&& enctype
!= entry
->keyblock
.keytype
)
562 _krb5_kt_principal_not_found(krb5_context context
,
565 krb5_const_principal principal
,
566 krb5_enctype enctype
,
569 char princ
[256], kvno_str
[25], *kt_name
;
570 char *enctype_str
= NULL
;
572 krb5_unparse_name_fixed (context
, principal
, princ
, sizeof(princ
));
573 krb5_kt_get_full_name (context
, id
, &kt_name
);
574 krb5_enctype_to_string(context
, enctype
, &enctype_str
);
577 snprintf(kvno_str
, sizeof(kvno_str
), "(kvno %d)", kvno
);
581 krb5_set_error_message (context
, ret
,
582 N_("Failed to find %s%s in keytab %s (%s)",
583 "principal, kvno, keytab file, enctype"),
586 kt_name
? kt_name
: "unknown keytab",
587 enctype_str
? enctype_str
: "unknown enctype");
595 * Retrieve the keytab entry for `principal, kvno, enctype' into `entry'
596 * from the keytab `id'. Matching is done like krb5_kt_compare().
598 * @param context a Keberos context.
599 * @param id a keytab.
600 * @param principal principal to match, NULL matches all principals.
601 * @param kvno key version to match, 0 matches all key version numbers.
602 * @param enctype encryption type to match, 0 matches all encryption types.
603 * @param entry the returned entry, free with krb5_kt_free_entry().
605 * @return Return an error code or 0, see krb5_get_error_message().
607 * @ingroup krb5_keytab
610 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
611 krb5_kt_get_entry(krb5_context context
,
613 krb5_const_principal principal
,
615 krb5_enctype enctype
,
616 krb5_keytab_entry
*entry
)
618 krb5_keytab_entry tmp
;
620 krb5_kt_cursor cursor
;
623 return (*id
->get
)(context
, id
, principal
, kvno
, enctype
, entry
);
625 ret
= krb5_kt_start_seq_get (context
, id
, &cursor
);
627 /* This is needed for krb5_verify_init_creds, but keep error
628 * string from previous error for the human. */
629 context
->error_code
= KRB5_KT_NOTFOUND
;
630 return KRB5_KT_NOTFOUND
;
634 while (krb5_kt_next_entry(context
, id
, &tmp
, &cursor
) == 0) {
635 if (krb5_kt_compare(context
, &tmp
, principal
, 0, enctype
)) {
636 /* the file keytab might only store the lower 8 bits of
637 the kvno, so only compare those bits */
639 || (tmp
.vno
< 256 && kvno
% 256 == tmp
.vno
)) {
640 krb5_kt_copy_entry_contents (context
, &tmp
, entry
);
641 krb5_kt_free_entry (context
, &tmp
);
642 krb5_kt_end_seq_get(context
, id
, &cursor
);
644 } else if (kvno
== 0 && tmp
.vno
> entry
->vno
) {
646 krb5_kt_free_entry (context
, entry
);
647 krb5_kt_copy_entry_contents (context
, &tmp
, entry
);
650 krb5_kt_free_entry(context
, &tmp
);
652 krb5_kt_end_seq_get (context
, id
, &cursor
);
654 return _krb5_kt_principal_not_found(context
, KRB5_KT_NOTFOUND
,
655 id
, principal
, enctype
, kvno
);
660 * Copy the contents of `in' into `out'.
662 * @param context a Keberos context.
663 * @param in the keytab entry to copy.
664 * @param out the copy of the keytab entry, free with krb5_kt_free_entry().
666 * @return Return an error code or 0, see krb5_get_error_message().
668 * @ingroup krb5_keytab
671 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
672 krb5_kt_copy_entry_contents(krb5_context context
,
673 const krb5_keytab_entry
*in
,
674 krb5_keytab_entry
*out
)
678 memset(out
, 0, sizeof(*out
));
681 ret
= krb5_copy_principal (context
, in
->principal
, &out
->principal
);
684 ret
= krb5_copy_keyblock_contents (context
,
689 out
->timestamp
= in
->timestamp
;
692 krb5_kt_free_entry (context
, out
);
697 * Free the contents of `entry'.
699 * @param context a Keberos context.
700 * @param entry the entry to free
702 * @return Return an error code or 0, see krb5_get_error_message().
704 * @ingroup krb5_keytab
707 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
708 krb5_kt_free_entry(krb5_context context
,
709 krb5_keytab_entry
*entry
)
711 krb5_free_principal (context
, entry
->principal
);
712 krb5_free_keyblock_contents (context
, &entry
->keyblock
);
713 memset(entry
, 0, sizeof(*entry
));
718 * Set `cursor' to point at the beginning of `id'.
720 * @param context a Keberos context.
721 * @param id a keytab.
722 * @param cursor a newly allocated cursor, free with krb5_kt_end_seq_get().
724 * @return Return an error code or 0, see krb5_get_error_message().
726 * @ingroup krb5_keytab
729 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
730 krb5_kt_start_seq_get(krb5_context context
,
732 krb5_kt_cursor
*cursor
)
734 if(id
->start_seq_get
== NULL
) {
735 krb5_set_error_message(context
, HEIM_ERR_OPNOTSUPP
,
736 N_("start_seq_get is not supported "
737 "in the %s keytab type", ""),
739 return HEIM_ERR_OPNOTSUPP
;
741 return (*id
->start_seq_get
)(context
, id
, cursor
);
745 * Get the next entry from keytab, advance the cursor. On last entry
746 * the function will return KRB5_KT_END.
748 * @param context a Keberos context.
749 * @param id a keytab.
750 * @param entry the returned entry, free with krb5_kt_free_entry().
751 * @param cursor the cursor of the iteration.
753 * @return Return an error code or 0, see krb5_get_error_message().
755 * @ingroup krb5_keytab
758 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
759 krb5_kt_next_entry(krb5_context context
,
761 krb5_keytab_entry
*entry
,
762 krb5_kt_cursor
*cursor
)
764 if(id
->next_entry
== NULL
) {
765 krb5_set_error_message(context
, HEIM_ERR_OPNOTSUPP
,
766 N_("next_entry is not supported in the %s "
769 return HEIM_ERR_OPNOTSUPP
;
771 return (*id
->next_entry
)(context
, id
, entry
, cursor
);
775 * Release all resources associated with `cursor'.
777 * @param context a Keberos context.
778 * @param id a keytab.
779 * @param cursor the cursor to free.
781 * @return Return an error code or 0, see krb5_get_error_message().
783 * @ingroup krb5_keytab
786 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
787 krb5_kt_end_seq_get(krb5_context context
,
789 krb5_kt_cursor
*cursor
)
791 if(id
->end_seq_get
== NULL
) {
792 krb5_set_error_message(context
, HEIM_ERR_OPNOTSUPP
,
793 "end_seq_get is not supported in the %s "
794 " keytab", id
->prefix
);
795 return HEIM_ERR_OPNOTSUPP
;
797 return (*id
->end_seq_get
)(context
, id
, cursor
);
801 * Add the entry in `entry' to the keytab `id'.
803 * @param context a Keberos context.
804 * @param id a keytab.
805 * @param entry the entry to add
807 * @return Return an error code or 0, see krb5_get_error_message().
809 * @ingroup krb5_keytab
812 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
813 krb5_kt_add_entry(krb5_context context
,
815 krb5_keytab_entry
*entry
)
817 if(id
->add
== NULL
) {
818 krb5_set_error_message(context
, KRB5_KT_NOWRITE
,
819 N_("Add is not supported in the %s keytab", ""),
821 return KRB5_KT_NOWRITE
;
823 entry
->timestamp
= time(NULL
);
824 return (*id
->add
)(context
, id
,entry
);
828 * Remove an entry from the keytab, matching is done using
831 * @param context a Keberos context.
832 * @param id a keytab.
833 * @param entry the entry to remove
835 * @return Return an error code or 0, see krb5_get_error_message().
837 * @ingroup krb5_keytab
840 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
841 krb5_kt_remove_entry(krb5_context context
,
843 krb5_keytab_entry
*entry
)
845 if(id
->remove
== NULL
) {
846 krb5_set_error_message(context
, KRB5_KT_NOWRITE
,
847 N_("Remove is not supported in the %s keytab", ""),
849 return KRB5_KT_NOWRITE
;
851 return (*id
->remove
)(context
, id
, entry
);
855 * Return true if the keytab exists and have entries
857 * @param context a Keberos context.
858 * @param id a keytab.
860 * @return Return an error code or 0, see krb5_get_error_message().
862 * @ingroup krb5_keytab
865 KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
866 krb5_kt_have_content(krb5_context context
,
869 krb5_keytab_entry entry
;
870 krb5_kt_cursor cursor
;
874 ret
= krb5_kt_start_seq_get(context
, id
, &cursor
);
878 ret
= krb5_kt_next_entry(context
, id
, &entry
, &cursor
);
879 krb5_kt_end_seq_get(context
, id
, &cursor
);
883 krb5_kt_free_entry(context
, &entry
);
888 ret
= krb5_kt_get_full_name(context
, id
, &name
);
890 krb5_set_error_message(context
, KRB5_KT_NOTFOUND
,
891 N_("No entry in keytab: %s", ""), name
);
894 return KRB5_KT_NOTFOUND
;