6729ff
From d161c173088ce82ea11a914ce62c5b77af9f4f9f Mon Sep 17 00:00:00 2001
6729ff
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd@samba.org>
6729ff
Date: Wed, 6 Nov 2013 18:21:32 +0100
6729ff
Subject: [PATCH] s3-libnetjoin: use upper-case realm when composing default
6729ff
 upn.
6729ff
MIME-Version: 1.0
6729ff
Content-Type: text/plain; charset=UTF-8
6729ff
Content-Transfer-Encoding: 8bit
6729ff
6729ff
In case we are about to generate a keytab during the join make sure the default
6729ff
upn we create is usable with kinit -k.
6729ff
6729ff
Guenther
6729ff
6729ff
Signed-off-by: Günther Deschner <gd@samba.org>
6729ff
---
6729ff
 source3/libnet/libnet_join.c | 17 ++++++++++++++++-
6729ff
 1 file changed, 16 insertions(+), 1 deletion(-)
6729ff
6729ff
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
6729ff
index 2dcb920..b84fcd6 100644
6729ff
--- a/source3/libnet/libnet_join.c
6729ff
+++ b/source3/libnet/libnet_join.c
6729ff
@@ -449,10 +449,25 @@ static ADS_STATUS libnet_join_set_machine_upn(TALLOC_CTX *mem_ctx,
6729ff
 	}
6729ff
 
6729ff
 	if (!r->in.upn) {
6729ff
+		char *realm = r->out.dns_domain_name;
6729ff
+
6729ff
+		/* in case we are about to generate a keytab during the join
6729ff
+		 * make sure the default upn we create is usable with kinit -k.
6729ff
+		 * gd */
6729ff
+
6729ff
+		if (USE_KERBEROS_KEYTAB) {
6729ff
+			realm = talloc_strdup_upper(mem_ctx,
6729ff
+						    r->out.dns_domain_name);
6729ff
+		}
6729ff
+
6729ff
+		if (!realm) {
6729ff
+			return ADS_ERROR(LDAP_NO_MEMORY);
6729ff
+		}
6729ff
+
6729ff
 		r->in.upn = talloc_asprintf(mem_ctx,
6729ff
 					    "host/%s@%s",
6729ff
 					    r->in.machine_name,
6729ff
-					    r->out.dns_domain_name);
6729ff
+					    realm);
6729ff
 		if (!r->in.upn) {
6729ff
 			return ADS_ERROR(LDAP_NO_MEMORY);
6729ff
 		}
6729ff
-- 
6729ff
1.8.3.1
6729ff