9991ea
From 03bfce26c944e2bf4d3073d959ed1e26d8f390a1 Mon Sep 17 00:00:00 2001
9991ea
From: Tomas Babej <tbabej@redhat.com>
9991ea
Date: Tue, 26 Nov 2013 12:14:39 +0100
9991ea
Subject: [PATCH 14/14] ipa-cldap: Cut NetBIOS name after 15 characters
9991ea
9991ea
The CLDAP DS plugin uses the uppercased first segment of the fully
9991ea
qualified hostname as the NetBIOS name. We need to limit its size
9991ea
to 15 characters.
9991ea
9991ea
https://fedorahosted.org/freeipa/ticket/4028
9991ea
---
9991ea
 daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h          | 1 +
9991ea
 daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c | 6 +++++-
9991ea
 2 files changed, 6 insertions(+), 1 deletion(-)
9991ea
9991ea
diff --git a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h
9991ea
index 7b0c2aad1991f5f5958db62844f5777f71534794..3f420ff2c5acc7bd75bff7f042f76b9c61144461 100644
9991ea
--- a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h
9991ea
+++ b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h
9991ea
@@ -59,6 +59,7 @@
9991ea
 #define IPA_PLUGIN_NAME IPA_CLDAP_PLUGIN_NAME
9991ea
 #define CLDAP_PORT 389
9991ea
 #define MAX_DG_SIZE 4096
9991ea
+#define NETBIOS_NAME_MAX 15
9991ea
 
9991ea
 #ifndef MAXHOSTNAMELEN
9991ea
 #define MAXHOSTNAMELEN 64
9991ea
diff --git a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
9991ea
index 7d29fe559be55607fcb6b83fa521372e5197b848..9ba05829418a0d1de46f2c7776cc15c54a9eab1c 100644
9991ea
--- a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
9991ea
+++ b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
9991ea
@@ -161,8 +161,12 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
9991ea
     nlr->dns_domain = domain;
9991ea
     nlr->pdc_dns_name = fq_hostname;
9991ea
     nlr->domain_name = name;
9991ea
-    pdc_name = talloc_asprintf(nlr, "\\\\%s", fq_hostname);
9991ea
+
9991ea
+    /* copy the first 15 characters of the fully qualified hostname*/
9991ea
+    pdc_name = talloc_asprintf(nlr, "\\\\%.*s", NETBIOS_NAME_MAX, fq_hostname);
9991ea
+
9991ea
     for (p = pdc_name; *p; p++) {
9991ea
+        /* Create the NetBIOS name from the first segment of the hostname */
9991ea
         if (*p == '.') {
9991ea
             *p = '\0';
9991ea
             break;
9991ea
-- 
9991ea
1.8.4.2
9991ea