|
|
9991ea |
From c57ff0a9aae8e51de1de8671dc6c8d91a1f1af66 Mon Sep 17 00:00:00 2001
|
|
|
9991ea |
From: Sumit Bose <sbose@redhat.com>
|
|
|
9991ea |
Date: Thu, 23 Jan 2014 14:39:24 +0100
|
|
|
9991ea |
Subject: [PATCH] CLDAP: generate NetBIOS name like ipa-adtrust-install does
|
|
|
9991ea |
|
|
|
9991ea |
Fixes https://fedorahosted.org/freeipa/ticket/4116
|
|
|
9991ea |
---
|
|
|
9991ea |
daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h | 2 +
|
|
|
9991ea |
.../ipa-cldap/ipa_cldap_netlogon.c | 47 +++++++++++++++-------
|
|
|
9991ea |
2 files changed, 35 insertions(+), 14 deletions(-)
|
|
|
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 3f420ff2c5acc7bd75bff7f042f76b9c61144461..5e963e3f8557d468d646e6343366921d17242e2d 100644
|
|
|
9991ea |
--- a/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h
|
|
|
9991ea |
+++ b/daemons/ipa-slapi-plugins/ipa-cldap/ipa_cldap.h
|
|
|
9991ea |
@@ -51,6 +51,7 @@
|
|
|
9991ea |
#include <stdlib.h>
|
|
|
9991ea |
#include <pthread.h>
|
|
|
9991ea |
#include <dirsrv/slapi-plugin.h>
|
|
|
9991ea |
+#include <talloc.h>
|
|
|
9991ea |
#include "util.h"
|
|
|
9991ea |
|
|
|
9991ea |
#define IPA_CLDAP_PLUGIN_NAME "CLDAP Server"
|
|
|
9991ea |
@@ -106,4 +107,5 @@ int ipa_cldap_netlogon(struct ipa_cldap_ctx *ctx,
|
|
|
9991ea |
struct ipa_cldap_req *req,
|
|
|
9991ea |
struct berval *reply);
|
|
|
9991ea |
|
|
|
9991ea |
+char *make_netbios_name(TALLOC_CTX *mem_ctx, const char *s);
|
|
|
9991ea |
#endif /* _IPA_CLDAP_H_ */
|
|
|
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 c03172d474589ddee84f1cfa5395c23fdba83bcb..1d16de7be09cf9675c2ee1a602ddfb800cd6e7af 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 |
@@ -121,6 +121,38 @@ done:
|
|
|
9991ea |
return ret;
|
|
|
9991ea |
}
|
|
|
9991ea |
|
|
|
9991ea |
+char *make_netbios_name(TALLOC_CTX *mem_ctx, const char *s)
|
|
|
9991ea |
+{
|
|
|
9991ea |
+ char *nb_name;
|
|
|
9991ea |
+ const char *p;
|
|
|
9991ea |
+ size_t c = 0;
|
|
|
9991ea |
+
|
|
|
9991ea |
+ if (s == NULL) {
|
|
|
9991ea |
+ return NULL;
|
|
|
9991ea |
+ }
|
|
|
9991ea |
+
|
|
|
9991ea |
+ nb_name = talloc_zero_size(mem_ctx, NETBIOS_NAME_MAX + 1);
|
|
|
9991ea |
+ if (nb_name == NULL) {
|
|
|
9991ea |
+ return NULL;
|
|
|
9991ea |
+ }
|
|
|
9991ea |
+
|
|
|
9991ea |
+ for (p = s; *p && c < NETBIOS_NAME_MAX; p++) {
|
|
|
9991ea |
+ /* Create the NetBIOS name from the first segment of the hostname */
|
|
|
9991ea |
+ if (*p == '.') {
|
|
|
9991ea |
+ break;
|
|
|
9991ea |
+ } else if (isalnum(*p)) {
|
|
|
9991ea |
+ nb_name[c++] = toupper(*p);
|
|
|
9991ea |
+ }
|
|
|
9991ea |
+ }
|
|
|
9991ea |
+
|
|
|
9991ea |
+ if (*nb_name == '\0') {
|
|
|
9991ea |
+ talloc_free(nb_name);
|
|
|
9991ea |
+ return NULL;
|
|
|
9991ea |
+ }
|
|
|
9991ea |
+
|
|
|
9991ea |
+ return nb_name;
|
|
|
9991ea |
+}
|
|
|
9991ea |
+
|
|
|
9991ea |
#define NETLOGON_SAM_LOGON_RESPONSE_EX_pusher \
|
|
|
9991ea |
(ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX
|
|
|
9991ea |
|
|
|
9991ea |
@@ -131,8 +163,6 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
|
|
|
9991ea |
struct NETLOGON_SAM_LOGON_RESPONSE_EX *nlr;
|
|
|
9991ea |
enum ndr_err_code ndr_err;
|
|
|
9991ea |
DATA_BLOB blob;
|
|
|
9991ea |
- char *pdc_name;
|
|
|
9991ea |
- char *p;
|
|
|
9991ea |
int ret;
|
|
|
9991ea |
|
|
|
9991ea |
nlr = talloc_zero(NULL, struct NETLOGON_SAM_LOGON_RESPONSE_EX);
|
|
|
9991ea |
@@ -162,18 +192,7 @@ static int ipa_cldap_encode_netlogon(char *fq_hostname, char *domain,
|
|
|
9991ea |
nlr->pdc_dns_name = fq_hostname;
|
|
|
9991ea |
nlr->domain_name = name;
|
|
|
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 |
- *p = toupper(*p);
|
|
|
9991ea |
- }
|
|
|
9991ea |
- nlr->pdc_name = pdc_name;
|
|
|
9991ea |
+ nlr->pdc_name = make_netbios_name(nlr, fq_hostname);
|
|
|
9991ea |
nlr->user_name = "";
|
|
|
9991ea |
nlr->server_site = "Default-First-Site-Name";
|
|
|
9991ea |
nlr->client_site = "Default-First-Site-Name";
|
|
|
9991ea |
--
|
|
|
9991ea |
1.8.3.1
|
|
|
9991ea |
|