2 Unix SMB/CIFS implementation.
3 kerberos keytab utility library
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Remus Koos 2001
6 Copyright (C) Luke Howard 2003
7 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003
8 Copyright (C) Guenther Deschner 2003
9 Copyright (C) Rakesh Patel 2004
10 Copyright (C) Dan Perry 2004
11 Copyright (C) Jeremy Allison 2004
12 Copyright (C) Gerald Carter 2006
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
32 /**********************************************************************
33 **********************************************************************/
35 int smb_krb5_kt_add_entry_ext(krb5_context context
,
39 krb5_enctype
*enctypes
,
42 bool keep_old_entries
)
44 krb5_error_code ret
= 0;
45 krb5_kt_cursor cursor
;
46 krb5_keytab_entry kt_entry
;
47 krb5_principal princ
= NULL
;
51 ZERO_STRUCT(kt_entry
);
54 ret
= smb_krb5_parse_name(context
, princ_s
, &princ
);
56 DEBUG(1,("smb_krb5_kt_add_entry_ext: smb_krb5_parse_name(%s) failed (%s)\n", princ_s
, error_message(ret
)));
60 /* Seek and delete old keytab entries */
61 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
62 if (ret
!= KRB5_KT_END
&& ret
!= ENOENT
) {
63 DEBUG(3,("smb_krb5_kt_add_entry_ext: Will try to delete old keytab entries\n"));
64 while(!krb5_kt_next_entry(context
, keytab
, &kt_entry
, &cursor
)) {
65 bool compare_name_ok
= False
;
67 ret
= smb_krb5_unparse_name(talloc_tos(), context
, kt_entry
.principal
, &ktprinc
);
69 DEBUG(1,("smb_krb5_kt_add_entry_ext: smb_krb5_unparse_name failed (%s)\n",
74 /*---------------------------------------------------------------------------
75 * Save the entries with kvno - 1. This is what microsoft does
76 * to allow people with existing sessions that have kvno - 1 to still
77 * work. Otherwise, when the password for the machine changes, all
78 * kerberizied sessions will 'break' until either the client reboots or
79 * the client's session key expires and they get a new session ticket
83 #ifdef HAVE_KRB5_KT_COMPARE
84 compare_name_ok
= (krb5_kt_compare(context
, &kt_entry
, princ
, 0, 0) == True
);
86 compare_name_ok
= (strcmp(ktprinc
, princ_s
) == 0);
89 if (!compare_name_ok
) {
90 DEBUG(10,("smb_krb5_kt_add_entry_ext: ignoring keytab entry principal %s, kvno = %d\n",
91 ktprinc
, kt_entry
.vno
));
96 if (compare_name_ok
) {
97 if (kt_entry
.vno
== kvno
- 1) {
98 DEBUG(5,("smb_krb5_kt_add_entry_ext: Saving previous (kvno %d) entry for principal: %s.\n",
100 } else if (!keep_old_entries
) {
101 DEBUG(5,("smb_krb5_kt_add_entry_ext: Found old entry for principal: %s (kvno %d) - trying to remove it.\n",
102 princ_s
, kt_entry
.vno
));
103 ret
= krb5_kt_end_seq_get(context
, keytab
, &cursor
);
106 DEBUG(1,("smb_krb5_kt_add_entry_ext: krb5_kt_end_seq_get() failed (%s)\n",
107 error_message(ret
)));
110 ret
= krb5_kt_remove_entry(context
, keytab
, &kt_entry
);
112 DEBUG(1,("smb_krb5_kt_add_entry_ext: krb5_kt_remove_entry failed (%s)\n",
113 error_message(ret
)));
117 DEBUG(5,("smb_krb5_kt_add_entry_ext: removed old entry for principal: %s (kvno %d).\n",
118 princ_s
, kt_entry
.vno
));
120 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
122 DEBUG(1,("smb_krb5_kt_add_entry_ext: krb5_kt_start_seq failed (%s)\n",
123 error_message(ret
)));
126 ret
= smb_krb5_kt_free_entry(context
, &kt_entry
);
127 ZERO_STRUCT(kt_entry
);
129 DEBUG(1,("smb_krb5_kt_add_entry_ext: krb5_kt_remove_entry failed (%s)\n",
130 error_message(ret
)));
137 /* Not a match, just free this entry and continue. */
138 ret
= smb_krb5_kt_free_entry(context
, &kt_entry
);
139 ZERO_STRUCT(kt_entry
);
141 DEBUG(1,("smb_krb5_kt_add_entry_ext: smb_krb5_kt_free_entry failed (%s)\n", error_message(ret
)));
146 ret
= krb5_kt_end_seq_get(context
, keytab
, &cursor
);
149 DEBUG(1,("smb_krb5_kt_add_entry_ext: krb5_kt_end_seq_get failed (%s)\n",error_message(ret
)));
154 /* Ensure we don't double free. */
155 ZERO_STRUCT(kt_entry
);
158 /* If we get here, we have deleted all the old entries with kvno's not equal to the current kvno-1. */
160 /* Now add keytab entries for all encryption types */
161 for (i
= 0; enctypes
[i
]; i
++) {
164 keyp
= KRB5_KT_KEY(&kt_entry
);
166 if (create_kerberos_key_from_string(context
, princ
, &password
, keyp
, enctypes
[i
], no_salt
)) {
170 kt_entry
.principal
= princ
;
173 DEBUG(3,("smb_krb5_kt_add_entry_ext: adding keytab entry for (%s) with encryption type (%d) and version (%d)\n",
174 princ_s
, enctypes
[i
], kt_entry
.vno
));
175 ret
= krb5_kt_add_entry(context
, keytab
, &kt_entry
);
176 krb5_free_keyblock_contents(context
, keyp
);
177 ZERO_STRUCT(kt_entry
);
179 DEBUG(1,("smb_krb5_kt_add_entry_ext: adding entry to keytab failed (%s)\n", error_message(ret
)));
187 krb5_keytab_entry zero_kt_entry
;
188 ZERO_STRUCT(zero_kt_entry
);
189 if (memcmp(&zero_kt_entry
, &kt_entry
, sizeof(krb5_keytab_entry
))) {
190 smb_krb5_kt_free_entry(context
, &kt_entry
);
194 krb5_free_principal(context
, princ
);
198 krb5_kt_cursor zero_csr
;
199 ZERO_STRUCT(zero_csr
);
200 if ((memcmp(&cursor
, &zero_csr
, sizeof(krb5_kt_cursor
)) != 0) && keytab
) {
201 krb5_kt_end_seq_get(context
, keytab
, &cursor
);
208 static int smb_krb5_kt_add_entry(krb5_context context
,
212 krb5_enctype
*enctypes
,
215 return smb_krb5_kt_add_entry_ext(context
,
225 /**********************************************************************
226 Adds a single service principal, i.e. 'host' to the system keytab
227 ***********************************************************************/
229 int ads_keytab_add_entry(ADS_STRUCT
*ads
, const char *srvPrinc
)
231 krb5_error_code ret
= 0;
232 krb5_context context
= NULL
;
233 krb5_keytab keytab
= NULL
;
236 krb5_enctype enctypes
[4] = { ENCTYPE_DES_CBC_CRC
, ENCTYPE_DES_CBC_MD5
, 0, 0 };
237 char *princ_s
= NULL
, *short_princ_s
= NULL
;
238 char *password_s
= NULL
;
240 TALLOC_CTX
*ctx
= NULL
;
243 #if defined(ENCTYPE_ARCFOUR_HMAC)
244 enctypes
[2] = ENCTYPE_ARCFOUR_HMAC
;
247 initialize_krb5_error_table();
248 ret
= krb5_init_context(&context
);
250 DEBUG(1,("ads_keytab_add_entry: could not krb5_init_context: %s\n",error_message(ret
)));
254 ret
= smb_krb5_open_keytab(context
, NULL
, True
, &keytab
);
256 DEBUG(1,("ads_keytab_add_entry: smb_krb5_open_keytab failed (%s)\n", error_message(ret
)));
260 /* retrieve the password */
261 if (!secrets_init()) {
262 DEBUG(1,("ads_keytab_add_entry: secrets_init failed\n"));
266 password_s
= secrets_fetch_machine_password(lp_workgroup(), NULL
, NULL
);
268 DEBUG(1,("ads_keytab_add_entry: failed to fetch machine password\n"));
272 ZERO_STRUCT(password
);
273 password
.data
= password_s
;
274 password
.length
= strlen(password_s
);
276 /* we need the dNSHostName value here */
278 if ( (ctx
= talloc_init("ads_keytab_add_entry")) == NULL
) {
279 DEBUG(0,("ads_keytab_add_entry: talloc() failed!\n"));
284 if ( (my_fqdn
= ads_get_dnshostname( ads
, ctx
, global_myname())) == NULL
) {
285 DEBUG(0,("ads_keytab_add_entry: unable to determine machine account's dns name in AD!\n"));
290 if ( (machine_name
= ads_get_samaccountname( ads
, ctx
, global_myname())) == NULL
) {
291 DEBUG(0,("ads_keytab_add_entry: unable to determine machine account's short name in AD!\n"));
295 /*strip the trailing '$' */
296 machine_name
[strlen(machine_name
)-1] = '\0';
298 /* Construct our principal */
300 if (strchr_m(srvPrinc
, '@')) {
301 /* It's a fully-named principal. */
302 if (asprintf(&princ_s
, "%s", srvPrinc
) == -1) {
306 } else if (srvPrinc
[strlen(srvPrinc
)-1] == '$') {
307 /* It's the machine account, as used by smbclient clients. */
308 if (asprintf(&princ_s
, "%s@%s", srvPrinc
, lp_realm()) == -1) {
313 /* It's a normal service principal. Add the SPN now so that we
314 * can obtain credentials for it and double-check the salt value
315 * used to generate the service's keys. */
317 if (asprintf(&princ_s
, "%s/%s@%s", srvPrinc
, my_fqdn
, lp_realm()) == -1) {
321 if (asprintf(&short_princ_s
, "%s/%s@%s", srvPrinc
, machine_name
, lp_realm()) == -1) {
326 /* According to http://support.microsoft.com/kb/326985/en-us,
327 certain principal names are automatically mapped to the host/...
328 principal in the AD account. So only create these in the
329 keytab, not in AD. --jerry */
331 if ( !strequal( srvPrinc
, "cifs" ) && !strequal(srvPrinc
, "host" ) ) {
332 DEBUG(3,("ads_keytab_add_entry: Attempting to add/update '%s'\n", princ_s
));
334 if (!ADS_ERR_OK(ads_add_service_principal_name(ads
, global_myname(), my_fqdn
, srvPrinc
))) {
335 DEBUG(1,("ads_keytab_add_entry: ads_add_service_principal_name failed.\n"));
341 kvno
= (krb5_kvno
) ads_get_machine_kvno(ads
, global_myname());
342 if (kvno
== -1) { /* -1 indicates failure, everything else is OK */
343 DEBUG(1,("ads_keytab_add_entry: ads_get_machine_kvno failed to determine the system's kvno.\n"));
348 /* add the fqdn principal to the keytab */
350 ret
= smb_krb5_kt_add_entry( context
, keytab
, kvno
, princ_s
, enctypes
, password
);
352 DEBUG(1,("ads_keytab_add_entry: Failed to add entry to keytab file\n"));
356 /* add the short principal name if we have one */
358 if ( short_princ_s
) {
359 ret
= smb_krb5_kt_add_entry( context
, keytab
, kvno
, short_princ_s
, enctypes
, password
);
361 DEBUG(1,("ads_keytab_add_entry: Failed to add short entry to keytab file\n"));
367 SAFE_FREE( princ_s
);
368 SAFE_FREE( short_princ_s
);
372 krb5_kt_close(context
, keytab
);
375 krb5_free_context(context
);
380 /**********************************************************************
381 Flushes all entries from the system keytab.
382 ***********************************************************************/
384 int ads_keytab_flush(ADS_STRUCT
*ads
)
386 krb5_error_code ret
= 0;
387 krb5_context context
= NULL
;
388 krb5_keytab keytab
= NULL
;
389 krb5_kt_cursor cursor
;
390 krb5_keytab_entry kt_entry
;
393 ZERO_STRUCT(kt_entry
);
396 initialize_krb5_error_table();
397 ret
= krb5_init_context(&context
);
399 DEBUG(1,("ads_keytab_flush: could not krb5_init_context: %s\n",error_message(ret
)));
403 ret
= smb_krb5_open_keytab(context
, NULL
, True
, &keytab
);
405 DEBUG(1,("ads_keytab_flush: smb_krb5_open_keytab failed (%s)\n", error_message(ret
)));
409 kvno
= (krb5_kvno
) ads_get_machine_kvno(ads
, global_myname());
410 if (kvno
== -1) { /* -1 indicates a failure */
411 DEBUG(1,("ads_keytab_flush: Error determining the system's kvno.\n"));
415 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
416 if (ret
!= KRB5_KT_END
&& ret
!= ENOENT
) {
417 while (!krb5_kt_next_entry(context
, keytab
, &kt_entry
, &cursor
)) {
418 ret
= krb5_kt_end_seq_get(context
, keytab
, &cursor
);
421 DEBUG(1,("ads_keytab_flush: krb5_kt_end_seq_get() failed (%s)\n",error_message(ret
)));
424 ret
= krb5_kt_remove_entry(context
, keytab
, &kt_entry
);
426 DEBUG(1,("ads_keytab_flush: krb5_kt_remove_entry failed (%s)\n",error_message(ret
)));
429 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
431 DEBUG(1,("ads_keytab_flush: krb5_kt_start_seq failed (%s)\n",error_message(ret
)));
434 ret
= smb_krb5_kt_free_entry(context
, &kt_entry
);
435 ZERO_STRUCT(kt_entry
);
437 DEBUG(1,("ads_keytab_flush: krb5_kt_remove_entry failed (%s)\n",error_message(ret
)));
443 /* Ensure we don't double free. */
444 ZERO_STRUCT(kt_entry
);
447 if (!ADS_ERR_OK(ads_clear_service_principal_names(ads
, global_myname()))) {
448 DEBUG(1,("ads_keytab_flush: Error while clearing service principal listings in LDAP.\n"));
455 krb5_keytab_entry zero_kt_entry
;
456 ZERO_STRUCT(zero_kt_entry
);
457 if (memcmp(&zero_kt_entry
, &kt_entry
, sizeof(krb5_keytab_entry
))) {
458 smb_krb5_kt_free_entry(context
, &kt_entry
);
462 krb5_kt_cursor zero_csr
;
463 ZERO_STRUCT(zero_csr
);
464 if ((memcmp(&cursor
, &zero_csr
, sizeof(krb5_kt_cursor
)) != 0) && keytab
) {
465 krb5_kt_end_seq_get(context
, keytab
, &cursor
);
469 krb5_kt_close(context
, keytab
);
472 krb5_free_context(context
);
477 /**********************************************************************
478 Adds all the required service principals to the system keytab.
479 ***********************************************************************/
481 int ads_keytab_create_default(ADS_STRUCT
*ads
)
483 krb5_error_code ret
= 0;
484 krb5_context context
= NULL
;
485 krb5_keytab keytab
= NULL
;
486 krb5_kt_cursor cursor
;
487 krb5_keytab_entry kt_entry
;
490 char *sam_account_name
, *upn
;
491 char **oldEntries
= NULL
, *princ_s
[26];
492 TALLOC_CTX
*ctx
= NULL
;
493 fstring machine_name
;
495 memset(princ_s
, '\0', sizeof(princ_s
));
497 fstrcpy( machine_name
, global_myname() );
499 /* these are the main ones we need */
501 if ( (ret
= ads_keytab_add_entry(ads
, "host") ) != 0 ) {
502 DEBUG(1,("ads_keytab_create_default: ads_keytab_add_entry failed while adding 'host'.\n"));
507 #if 0 /* don't create the CIFS/... keytab entries since no one except smbd
508 really needs them and we will fall back to verifying against secrets.tdb */
510 if ( (ret
= ads_keytab_add_entry(ads
, "cifs")) != 0 ) {
511 DEBUG(1,("ads_keytab_create_default: ads_keytab_add_entry failed while adding 'cifs'.\n"));
516 if ( (ctx
= talloc_init("ads_keytab_create_default")) == NULL
) {
517 DEBUG(0,("ads_keytab_create_default: talloc() failed!\n"));
521 /* now add the userPrincipalName and sAMAccountName entries */
523 if ( (sam_account_name
= ads_get_samaccountname( ads
, ctx
, machine_name
)) == NULL
) {
524 DEBUG(0,("ads_keytab_add_entry: unable to determine machine account's name in AD!\n"));
529 /* upper case the sAMAccountName to make it easier for apps to
530 know what case to use in the keytab file */
532 strupper_m( sam_account_name
);
534 if ( (ret
= ads_keytab_add_entry(ads
, sam_account_name
)) != 0 ) {
535 DEBUG(1,("ads_keytab_create_default: ads_keytab_add_entry failed while adding sAMAccountName (%s)\n",
540 /* remember that not every machine account will have a upn */
542 upn
= ads_get_upn( ads
, ctx
, machine_name
);
544 if ( (ret
= ads_keytab_add_entry(ads
, upn
)) != 0 ) {
545 DEBUG(1,("ads_keytab_create_default: ads_keytab_add_entry failed while adding UPN (%s)\n",
552 /* Now loop through the keytab and update any other existing entries... */
554 kvno
= (krb5_kvno
) ads_get_machine_kvno(ads
, machine_name
);
556 DEBUG(1,("ads_keytab_create_default: ads_get_machine_kvno failed to determine the system's kvno.\n"));
561 DEBUG(3,("ads_keytab_create_default: Searching for keytab entries to "
562 "preserve and update.\n"));
564 ZERO_STRUCT(kt_entry
);
567 initialize_krb5_error_table();
568 ret
= krb5_init_context(&context
);
570 DEBUG(1,("ads_keytab_create_default: could not krb5_init_context: %s\n",error_message(ret
)));
575 ret
= smb_krb5_open_keytab(context
, NULL
, True
, &keytab
);
577 DEBUG(1,("ads_keytab_create_default: smb_krb5_open_keytab failed (%s)\n", error_message(ret
)));
581 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
582 if (ret
!= KRB5_KT_END
&& ret
!= ENOENT
) {
583 while ((ret
= krb5_kt_next_entry(context
, keytab
, &kt_entry
, &cursor
)) == 0) {
584 smb_krb5_kt_free_entry(context
, &kt_entry
);
585 ZERO_STRUCT(kt_entry
);
589 krb5_kt_end_seq_get(context
, keytab
, &cursor
);
593 * Hmmm. There is no "rewind" function for the keytab. This means we have a race condition
594 * where someone else could add entries after we've counted them. Re-open asap to minimise
598 DEBUG(3, ("ads_keytab_create_default: Found %d entries in the keytab.\n", found
));
602 oldEntries
= talloc_array(ctx
, char *, found
);
604 DEBUG(1,("ads_keytab_create_default: Failed to allocate space to store the old keytab entries (malloc failed?).\n"));
608 memset(oldEntries
, '\0', found
* sizeof(char *));
610 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
611 if (ret
!= KRB5_KT_END
&& ret
!= ENOENT
) {
612 while (krb5_kt_next_entry(context
, keytab
, &kt_entry
, &cursor
) == 0) {
613 if (kt_entry
.vno
!= kvno
) {
614 char *ktprinc
= NULL
;
617 /* This returns a malloc'ed string in ktprinc. */
618 ret
= smb_krb5_unparse_name(oldEntries
, context
, kt_entry
.principal
, &ktprinc
);
620 DEBUG(1,("smb_krb5_unparse_name failed (%s)\n", error_message(ret
)));
624 * From looking at the krb5 source they don't seem to take locale
625 * or mb strings into account. Maybe this is because they assume utf8 ?
626 * In this case we may need to convert from utf8 to mb charset here ? JRA.
628 p
= strchr_m(ktprinc
, '@');
633 p
= strchr_m(ktprinc
, '/');
637 for (i
= 0; i
< found
; i
++) {
638 if (!oldEntries
[i
]) {
639 oldEntries
[i
] = ktprinc
;
642 if (!strcmp(oldEntries
[i
], ktprinc
)) {
643 TALLOC_FREE(ktprinc
);
648 TALLOC_FREE(ktprinc
);
651 smb_krb5_kt_free_entry(context
, &kt_entry
);
652 ZERO_STRUCT(kt_entry
);
655 for (i
= 0; oldEntries
[i
]; i
++) {
656 ret
|= ads_keytab_add_entry(ads
, oldEntries
[i
]);
657 TALLOC_FREE(oldEntries
[i
]);
659 krb5_kt_end_seq_get(context
, keytab
, &cursor
);
665 TALLOC_FREE(oldEntries
);
669 krb5_keytab_entry zero_kt_entry
;
670 ZERO_STRUCT(zero_kt_entry
);
671 if (memcmp(&zero_kt_entry
, &kt_entry
, sizeof(krb5_keytab_entry
))) {
672 smb_krb5_kt_free_entry(context
, &kt_entry
);
676 krb5_kt_cursor zero_csr
;
677 ZERO_STRUCT(zero_csr
);
678 if ((memcmp(&cursor
, &zero_csr
, sizeof(krb5_kt_cursor
)) != 0) && keytab
) {
679 krb5_kt_end_seq_get(context
, keytab
, &cursor
);
683 krb5_kt_close(context
, keytab
);
686 krb5_free_context(context
);
691 /**********************************************************************
693 ***********************************************************************/
695 int ads_keytab_list(const char *keytab_name
)
697 krb5_error_code ret
= 0;
698 krb5_context context
= NULL
;
699 krb5_keytab keytab
= NULL
;
700 krb5_kt_cursor cursor
;
701 krb5_keytab_entry kt_entry
;
703 ZERO_STRUCT(kt_entry
);
706 initialize_krb5_error_table();
707 ret
= krb5_init_context(&context
);
709 DEBUG(1,("ads_keytab_list: could not krb5_init_context: %s\n",error_message(ret
)));
713 ret
= smb_krb5_open_keytab(context
, keytab_name
, False
, &keytab
);
715 DEBUG(1,("ads_keytab_list: smb_krb5_open_keytab failed (%s)\n", error_message(ret
)));
719 ret
= krb5_kt_start_seq_get(context
, keytab
, &cursor
);
724 printf("Vno Type Principal\n");
726 while (krb5_kt_next_entry(context
, keytab
, &kt_entry
, &cursor
) == 0) {
728 char *princ_s
= NULL
;
729 char *etype_s
= NULL
;
730 krb5_enctype enctype
= 0;
732 ret
= smb_krb5_unparse_name(talloc_tos(), context
, kt_entry
.principal
, &princ_s
);
737 enctype
= smb_get_enctype_from_kt_entry(&kt_entry
);
739 ret
= smb_krb5_enctype_to_string(context
, enctype
, &etype_s
);
741 if (asprintf(&etype_s
, "UNKNOWN: %d\n", enctype
) == -1)
743 TALLOC_FREE(princ_s
);
748 printf("%3d %s\t\t %s\n", kt_entry
.vno
, etype_s
, princ_s
);
750 TALLOC_FREE(princ_s
);
753 ret
= smb_krb5_kt_free_entry(context
, &kt_entry
);
759 ret
= krb5_kt_end_seq_get(context
, keytab
, &cursor
);
764 /* Ensure we don't double free. */
765 ZERO_STRUCT(kt_entry
);
770 krb5_keytab_entry zero_kt_entry
;
771 ZERO_STRUCT(zero_kt_entry
);
772 if (memcmp(&zero_kt_entry
, &kt_entry
, sizeof(krb5_keytab_entry
))) {
773 smb_krb5_kt_free_entry(context
, &kt_entry
);
777 krb5_kt_cursor zero_csr
;
778 ZERO_STRUCT(zero_csr
);
779 if ((memcmp(&cursor
, &zero_csr
, sizeof(krb5_kt_cursor
)) != 0) && keytab
) {
780 krb5_kt_end_seq_get(context
, keytab
, &cursor
);
785 krb5_kt_close(context
, keytab
);
788 krb5_free_context(context
);
793 #endif /* HAVE_KRB5 */