From: Günther Deschner Date: Tue, 14 Jan 2025 18:16:31 +0000 (+0100) Subject: s3-libnet: avoid using lp_dns_hostname() in join code X-Git-Tag: samba-4.21.4~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=512514bbae46f668e075b52af4f87bfcc148042b;p=thirdparty%2Fsamba.git s3-libnet: avoid using lp_dns_hostname() in join code BUG: https://bugzilla.samba.org/show_bug.cgi?id=15777 This codepath is also used for provisiong non-local machines into AD during offlinejoin operations. When creating accounts for non-local machines we certainly need to be able to use arbitrary hostname other than lp_netbios_name() (which is used internally by lp_dns_hostname()). This partly reverts 0e96092c1895ecb41d4064111566b4ada71fe457. Guenther Signed-off-by: Guenther Deschner Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Thu Jan 30 07:35:05 UTC 2025 on atb-devel-224 (cherry picked from commit 062dc07e9b9c8e260548d0bca4d02819bdc60326) Autobuild-User(v4-21-test): Jule Anger Autobuild-Date(v4-21-test): Wed Feb 12 10:37:56 UTC 2025 on atb-devel-224 --- diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index d49d54436bb..f98d132d50f 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -552,7 +552,14 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx, * Register dns_hostname if needed, add_uniq_spn() will avoid * duplicates. */ - dns_hostname = lp_dns_hostname(); + if (r->in.dnshostname != NULL) { + dns_hostname = talloc_strdup(frame, r->in.dnshostname); + } else { + dns_hostname = talloc_asprintf(frame, + "%s.%s", + r->in.machine_name, + r->out.dns_domain_name); + } if (dns_hostname == NULL) { status = ADS_ERROR_LDAP(LDAP_NO_MEMORY); goto done;