Blame SOURCES/0102-UTIL-Use-max-15-characters-for-AD-host-UPN.patch

ecf709
From b2dcfa00dcb7b315a739d35ff6722a25b0ab5556 Mon Sep 17 00:00:00 2001
ecf709
From: Lukas Slebodnik <lslebodn@redhat.com>
ecf709
Date: Tue, 14 Mar 2017 10:34:00 +0100
ecf709
Subject: [PATCH 102/102] UTIL: Use max 15 characters for AD host UPN
ecf709
MIME-Version: 1.0
ecf709
Content-Type: text/plain; charset=UTF-8
ecf709
Content-Transfer-Encoding: 8bit
ecf709
ecf709
We do not want to use host principal with AD
ecf709
"host/name.domain.tld@DOMAIN.TLD" because it does not work.
ecf709
We need to use correct user principal for AD hosts. And we cannot
ecf709
rely all fallback "*$" because of other principals in keytab.
ecf709
ecf709
The NetBIOS naming convention allows for 16 characters in a NetBIOS
ecf709
name. Microsoft, however, limits NetBIOS names to 15 characters and
ecf709
uses the 16th character as a NetBIOS suffix.
ecf709
https://support.microsoft.com/en-us/help/163409/netbios-suffixes-16th-character-of-the-netbios-name
ecf709
ecf709
Resolves:
ecf709
https://pagure.io/SSSD/sssd/issue/3329
ecf709
ecf709
Reviewed-by: Michal Židek <mzidek@redhat.com>
ecf709
(cherry picked from commit c6f1bc32774a7cf2f8678499dfbced420be3a3a1)
ecf709
---
ecf709
 src/util/sss_krb5.c | 8 +++++++-
ecf709
 1 file changed, 7 insertions(+), 1 deletion(-)
ecf709
ecf709
diff --git a/src/util/sss_krb5.c b/src/util/sss_krb5.c
ecf709
index d461cf881566af37f31524c16f6a5f1511a5dc89..a3f066e8add5b7d7575c1e0f537c5729e4a0dad0 100644
ecf709
--- a/src/util/sss_krb5.c
ecf709
+++ b/src/util/sss_krb5.c
ecf709
@@ -51,7 +51,13 @@ sss_krb5_get_primary(TALLOC_CTX *mem_ctx,
ecf709
             *c = toupper(*c);
ecf709
         }
ecf709
 
ecf709
-        primary = talloc_asprintf(mem_ctx, "%s$", shortname);
ecf709
+        /* The samAccountName is recommended to be less than 20 characters.
ecf709
+         * This is only for users and groups. For machine accounts,
ecf709
+         * the real limit is caused by NetBIOS protocol.
ecf709
+         * NetBIOS names are limited to 16 (15 + $)
ecf709
+         * https://support.microsoft.com/en-us/help/163409/netbios-suffixes-16th-character-of-the-netbios-name
ecf709
+         */
ecf709
+        primary = talloc_asprintf(mem_ctx, "%.15s$", shortname);
ecf709
         talloc_free(shortname);
ecf709
         return primary;
ecf709
     }
ecf709
-- 
ecf709
2.9.3
ecf709