]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:mit-kdb: Force canonicalization for looking up principals
authorIsaac Boukris <iboukris@gmail.com>
Sat, 19 Sep 2020 12:16:20 +0000 (14:16 +0200)
committerJule Anger <janger@samba.org>
Sun, 24 Jul 2022 09:42:01 +0000 (11:42 +0200)
See also
https://github.com/krb5/krb5/commit/ac8865a22138ab0c657208c41be8fd6bc7968148

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Nov 29 09:32:26 UTC 2021 on sn-devel-184

(cherry picked from commit 90febd2a33b88af49af595fe0e995d6ba0f33a1b)

[jsutton@samba.org Removed MIT knownfail changes]

source4/heimdal/lib/hdb/hdb.h
source4/kdc/db-glue.c
source4/kdc/mit_samba.c
source4/kdc/sdb.h

index 5ef9d9565f3fe8fe33c9c4c3b0c38b209db23608..dafaffc6c2dc30def2d09a5cdcc99242af2574a3 100644 (file)
@@ -63,6 +63,7 @@ enum hdb_lockop{ HDB_RLOCK, HDB_WLOCK };
 #define HDB_F_ALL_KVNOS                2048    /* we want all the keys, live or not */
 #define HDB_F_FOR_AS_REQ       4096    /* fetch is for a AS REQ */
 #define HDB_F_FOR_TGS_REQ      8192    /* fetch is for a TGS REQ */
+#define HDB_F_FORCE_CANON      16384   /* force canonicalition */
 
 /* hdb_capability_flags */
 #define HDB_CAP_F_HANDLE_ENTERPRISE_PRINCIPAL 1
index 3a7e2176653082f0057237f2eed9edad8983b0ba..ac47fe783739def2ea5a51e3d1660b4b01c19589 100644 (file)
@@ -957,11 +957,16 @@ static krb5_error_code samba_kdc_message2entry(krb5_context context,
                        krb5_clear_error_message(context);
                        goto out;
                }
-       } else if ((flags & SDB_F_CANON) && (flags & SDB_F_FOR_AS_REQ)) {
+       } else if ((flags & SDB_F_FORCE_CANON) ||
+                  ((flags & SDB_F_CANON) && (flags & SDB_F_FOR_AS_REQ))) {
                /*
                 * SDB_F_CANON maps from the canonicalize flag in the
                 * packet, and has a different meaning between AS-REQ
                 * and TGS-REQ.  We only change the principal in the AS-REQ case
+                *
+                * The SDB_F_FORCE_CANON if for new MIT KDC code that wants
+                * the canonical name in all lookups, and takes care to
+                * canonicalize only when appropriate.
                 */
                ret = smb_krb5_make_principal(context, &entry_ex->entry.principal, lpcfg_realm(lp_ctx), samAccountName, NULL);
                if (ret) {
index e015c5a52dbe97efc7593ac5b941ea93bfa0e1be..c2a604045d99124ea11d7e691935540f11dd46b3 100644 (file)
@@ -195,6 +195,14 @@ int mit_samba_get_principal(struct mit_samba_context *ctx,
                return ENOMEM;
        }
 
+#if KRB5_KDB_API_VERSION >= 10
+       /*
+        * The MIT KDC code that wants the canonical name in all lookups, and
+        * takes care to canonicalize only when appropriate.
+        */
+       sflags |= SDB_F_FORCE_CANON;
+#endif
+
        if (kflags & KRB5_KDB_FLAG_CANONICALIZE) {
                sflags |= SDB_F_CANON;
        }
index c929acccce6a25a92283e310a42a248c04262d01..a9115ec23d74456faa139555937627f9f6eef0ef 100644 (file)
@@ -116,6 +116,7 @@ struct sdb_entry_ex {
 #define SDB_F_KVNO_SPECIFIED   128     /* we want a particular KVNO */
 #define SDB_F_FOR_AS_REQ       4096    /* fetch is for a AS REQ */
 #define SDB_F_FOR_TGS_REQ      8192    /* fetch is for a TGS REQ */
+#define SDB_F_FORCE_CANON      16384   /* force canonicalition */
 
 void sdb_free_entry(struct sdb_entry_ex *e);
 void free_sdb_entry(struct sdb_entry *s);