kerberos: use KRB5_KT_KEY macro where appropriate.
authorGünther Deschner <gd@samba.org>
Fri, 22 Aug 2008 12:58:01 +0000 (14:58 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 29 Aug 2008 09:01:34 +0000 (11:01 +0200)
Guenther
(This used to be commit a042dffd7121bda3dbc9509f69fcfae06ed4cc22)

source3/include/includes.h
source3/libads/kerberos_keytab.c
source3/libnet/libnet_keytab.c
source3/libsmb/clikrb5.c

index fa385cba2a57a09148e1fe562742d8cba19f8307..958e7cba1f797c0ccbc2b1846576ad120734ebe5 100644 (file)
@@ -1234,7 +1234,7 @@ krb5_error_code smb_krb5_mk_error(krb5_context context,
                                        krb5_error_code error_code,
                                        const krb5_principal server,
                                        krb5_data *reply);
-krb5_enctype smb_get_enctype_from_kt_entry(const krb5_keytab_entry *kt_entry);
+krb5_enctype smb_get_enctype_from_kt_entry(krb5_keytab_entry *kt_entry);
 krb5_error_code smb_krb5_enctype_to_string(krb5_context context, 
                                            krb5_enctype enctype, 
                                            char **etype_s);
index 77a50e42215906363935d8cbbc6f4a99bf4b33b3..883f5824452cb5fc4045e394110aab8180d9efdc 100644 (file)
@@ -161,15 +161,8 @@ int smb_krb5_kt_add_entry_ext(krb5_context context,
        for (i = 0; enctypes[i]; i++) {
                krb5_keyblock *keyp;
 
-#if !defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) && !defined(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK)
-#error krb5_keytab_entry has no key or keyblock member
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY               /* MIT */
-               keyp = &kt_entry.key;
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK          /* Heimdal */
-               keyp = &kt_entry.keyblock;
-#endif
+               keyp = KRB5_KT_KEY(&kt_entry);
+
                if (create_kerberos_key_from_string(context, princ, &password, keyp, enctypes[i], no_salt)) {
                        continue;
                }
index a4555239da553d09d78135189e147ba3e5d94991..46c17b219c931783e780275d06a4800549ceec41 100644 (file)
@@ -138,15 +138,7 @@ static krb5_error_code libnet_keytab_remove_entries(krb5_context context,
                        goto cont;
                }
 
-#if !defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) && !defined(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK)
-#error krb5_keytab_entry has no key or keyblock member
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY               /* MIT */
-       keyp = &kt_entry.key;
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK          /* Heimdal */
-       keyp = &kt_entry.keyblock;
-#endif
+               keyp = KRB5_KT_KEY(&kt_entry);
 
                if (KRB5_KEY_TYPE(keyp) != enctype) {
                        goto cont;
@@ -240,15 +232,7 @@ static krb5_error_code libnet_keytab_add_entry(krb5_context context,
                return ret;
        }
 
-#if !defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) && !defined(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK)
-#error krb5_keytab_entry has no key or keyblock member
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY               /* MIT */
-       keyp = &kt_entry.key;
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK          /* Heimdal */
-       keyp = &kt_entry.keyblock;
-#endif
+       keyp = KRB5_KT_KEY(&kt_entry);
 
        if (create_kerberos_key_from_string(context, kt_entry.principal,
                                            &password, keyp, enctype, true))
@@ -354,15 +338,7 @@ struct libnet_keytab_entry *libnet_keytab_search(struct libnet_keytab_context *c
                        goto cont;
                }
 
-#if !defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) && !defined(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK)
-#error krb5_keytab_entry has no key or keyblock member
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY               /* MIT */
-       keyp = &kt_entry.key;
-#endif
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK          /* Heimdal */
-       keyp = &kt_entry.keyblock;
-#endif
+               keyp = KRB5_KT_KEY(&kt_entry);
 
                if (KRB5_KEY_TYPE(keyp) != enctype) {
                        goto cont;
index b6fb7cf05025abee3938597d56398827393f1028..bedd7d7aeef4bc1c89e9b4f3437023b24c832917 100644 (file)
@@ -1045,6 +1045,7 @@ get_key_from_keytab(krb5_context context,
        krb5_error_code ret;
        krb5_keytab keytab;
        char *name = NULL;
+       krb5_keyblock *keyp;
 
        /* We have to open a new keytab handle here, as MIT does
           an implicit open/getnext/close on krb5_kt_get_entry. We
@@ -1077,14 +1078,9 @@ get_key_from_keytab(krb5_context context,
                goto out;
        }
 
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK /* Heimdal */
-       ret = krb5_copy_keyblock(context, &entry.keyblock, out_key);
-#elif defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) /* MIT */
-       ret = krb5_copy_keyblock(context, &entry.key, out_key);
-#else
-#error UNKNOWN_KRB5_KEYTAB_ENTRY_FORMAT
-#endif
+       keyp = KRB5_KT_KEY(&entry);
 
+       ret = krb5_copy_keyblock(context, keyp, out_key);
        if (ret) {
                DEBUG(0,("get_key_from_keytab: failed to copy key: %s\n", error_message(ret)));
                goto out;
@@ -1572,15 +1568,9 @@ done:
 #endif /* HAVE_KRB5_GET_INIT_CREDS_OPT_FREE */
 }
 
- krb5_enctype smb_get_enctype_from_kt_entry(const krb5_keytab_entry *kt_entry)
+ krb5_enctype smb_get_enctype_from_kt_entry(krb5_keytab_entry *kt_entry)
 {
-#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY              /* MIT */
-       return kt_entry->key.enctype;
-#elif defined(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK) /* Heimdal */
-       return kt_entry->keyblock.keytype;
-#else
-#error UNKNOWN_KRB5_KEYTAB_ENTRY_KEYBLOCK_FORMAT
-#endif
+       return KRB5_KEY_TYPE(KRB5_KT_KEY(kt_entry));
 }