On 11/26/2013 04:56 PM, Alexander Bokovoy wrote:
On Tue, 26 Nov 2013, Tomas Babej wrote:
Hi,

The CLDAP DS plugin uses the uppercased first segment of the fully
qualified hostname as the NetBIOS name. We need to limit its size
to 15 characters.

https://fedorahosted.org/freeipa/ticket/4028

--
Tomas Babej
Associate Software Engeneer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org



From a74aefcd91051e908be0e9bc2b834206024ac043 Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Tue, 26 Nov 2013 12:14:39 +0100
Subject: [PATCH] ipa-cldap: Cut NetBIOS name after 15 characters

The CLDAP DS plugin uses the uppercased first segment of the fully
qualified hostname as the NetBIOS name. We need to limit its size
to 15 characters.

https://fedorahosted.org/freeipa/ticket/4028
---
daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c index 7d29fe559be55607fcb6b83fa521372e5197b848..3799ad4b1e9d456a34cd6967d0770b366590e50c 100644
--- a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
+++ b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
@@ -134,6 +134,8 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
    char *pdc_name;
    char *p;
    int ret;
+    const int netbios_length_limit = 15;
+    int i;

    nlr = talloc_zero(NULL, struct NETLOGON_SAM_LOGON_RESPONSE_EX);
    if (!nlr) {
@@ -162,11 +164,14 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
    nlr->pdc_dns_name = fq_hostname;
    nlr->domain_name = name;
    pdc_name = talloc_asprintf(nlr, "\\\\%s", fq_hostname);
+
+ i = 0; //netbios name length counter, we need to cut it after 15 chrs
Apart from what was said, please do not use C++-like comments.

    for (p = pdc_name; *p; p++) {
-        if (*p == '.') {
+        if ((*p == '.') || (i >= netbios_length_limit)) {
            *p = '\0';
            break;
        }
+        i = i + 1;         *p = toupper(*p);
    }
    nlr->pdc_name = pdc_name;
--
1.8.3.1


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel



Fixed! Thanks for the reviews.



--
Tomas Babej
Associate Software Engeneer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org

From 7bd7268c40328168244340fee1721b3b8dfecc8c Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Tue, 26 Nov 2013 12:14:39 +0100
Subject: [PATCH] ipa-cldap: Cut NetBIOS name after 15 characters

The CLDAP DS plugin uses the uppercased first segment of the fully
qualified hostname as the NetBIOS name. We need to limit its size
to 15 characters.

https://fedorahosted.org/freeipa/ticket/4028
---
 daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
index 7d29fe559be55607fcb6b83fa521372e5197b848..c75b3fc792ef81e4bf7ce69da60675d133d373c5 100644
--- a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
+++ b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap_netlogon.c
@@ -161,9 +161,13 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
     nlr->dns_domain = domain;
     nlr->pdc_dns_name = fq_hostname;
     nlr->domain_name = name;
-    pdc_name = talloc_asprintf(nlr, "\\\\%s", fq_hostname);
+
+    /* copy the first 15 characters of the fully qualified hostname*/
+    pdc_name = talloc_asprintf(nlr, "\\\\%s", 15, fq_hostname);
+
     for (p = pdc_name; *p; p++) {
-        if (*p == '.') {
+        /* Create the NetBIOS name from the first segment of the hostname */
+        if ((*p == '.') || (*p == '\0')) {
             *p = '\0';
             break;
         }
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to