static krb5_error_code flush_keytab(krb5_context krbctx, krb5_keytab keytab)
{
krb5_error_code ret;
- krb5_kt_cursor kt_cursor = NULL;
+ krb5_kt_cursor kt_cursor;
krb5_keytab_entry kt_entry;
ZERO_STRUCT(kt_entry);
krb5_keytab_entry kt_entry;
unsigned int i;
- ret = krb5_get_permitted_enctypes(krbctx, &enctypes);
+ ret = get_kerberos_allowed_etypes(krbctx, &enctypes);
if (ret) {
DEBUG(1, (__location__
": Can't determine permitted enctypes!\n"));
kt_entry.principal = princ;
kt_entry.vno = vno;
- kt_entry.key = *key;
+ *(KRB5_KT_KEY(&kt_entry)) = *key;
ret = krb5_kt_add_entry(krbctx, keytab, &kt_entry);
if (ret) {
krb5_error_code ret;
char *pwd = NULL;
size_t pwd_len;
- krb5_kt_cursor kt_cursor = NULL;
+ krb5_kt_cursor kt_cursor;
krb5_keytab_entry kt_entry;
krb5_data password;
krb5_principal princ = NULL;
}
ZERO_STRUCT(kt_entry);
+ ZERO_STRUCT(kt_cursor);
/* check if the keytab already has any entry */
ret = krb5_kt_start_seq_get(krbctx, *keytab, &kt_cursor);
* we can verify if the keytab needs to be upgraded */
while ((ret = krb5_kt_next_entry(krbctx, *keytab,
&kt_entry, &kt_cursor)) == 0) {
- if (kt_entry.key.enctype == CLEARTEXT_PRIV_ENCTYPE) {
+ if (smb_get_enctype_from_kt_entry(&kt_entry) == CLEARTEXT_PRIV_ENCTYPE) {
break;
}
smb_krb5_kt_free_entry(krbctx, &kt_entry);
/* found private entry,
* check if keytab is up to date */
- if ((pwd_len == kt_entry.key.length) &&
- (memcmp(kt_entry.key.contents,
+ if ((pwd_len == KRB5_KEY_LENGTH(KRB5_KT_KEY(&kt_entry))) &&
+ (memcmp(KRB5_KEY_DATA(KRB5_KT_KEY(&kt_entry)),
pwd, pwd_len) == 0)) {
/* keytab is already up to date, return */
smb_krb5_kt_free_entry(krbctx, &kt_entry);
}
}
- if (kt_cursor) {
- /* stop enumeration and free cursor */
- krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
- kt_cursor = NULL;
- }
+ {
+ krb5_kt_cursor zero_csr;
+ ZERO_STRUCT(zero_csr);
+ if ((memcmp(&kt_cursor, &zero_csr, sizeof(krb5_kt_cursor)) != 0) && *keytab) {
+ krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
+ }
+ }
/* keytab is not up to date, fill it up */
ZERO_STRUCT(kt_entry);
kt_entry.principal = princ;
kt_entry.vno = 0;
- kt_entry.key.enctype = CLEARTEXT_PRIV_ENCTYPE;
- kt_entry.key.length = pwd_len;
- kt_entry.key.contents = (uint8_t *)pwd;
+
+ KRB5_KEY_TYPE(KRB5_KT_KEY(&kt_entry)) = CLEARTEXT_PRIV_ENCTYPE;
+ KRB5_KEY_LENGTH(KRB5_KT_KEY(&kt_entry)) = pwd_len;
+ KRB5_KEY_DATA(KRB5_KT_KEY(&kt_entry)) = (uint8_t *)pwd;
ret = krb5_kt_add_entry(krbctx, *keytab, &kt_entry);
if (ret) {
SAFE_FREE(pwd);
SAFE_FREE(pwd_old);
- if (kt_cursor) {
- /* stop enumeration and free cursor */
- krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
- kt_cursor = NULL;
- }
+ {
+ krb5_kt_cursor zero_csr;
+ ZERO_STRUCT(zero_csr);
+ if ((memcmp(&kt_cursor, &zero_csr, sizeof(krb5_kt_cursor)) != 0) && *keytab) {
+ krb5_kt_end_seq_get(krbctx, *keytab, &kt_cursor);
+ }
+ }
if (princ) {
krb5_free_principal(krbctx, princ);