]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-libnet: avoid using lp_dns_hostname() in join code
authorGünther Deschner <gd@samba.org>
Tue, 14 Jan 2025 18:16:31 +0000 (19:16 +0100)
committerJule Anger <janger@samba.org>
Wed, 12 Feb 2025 10:37:56 +0000 (10:37 +0000)
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 <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
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 <janger@samba.org>
Autobuild-Date(v4-21-test): Wed Feb 12 10:37:56 UTC 2025 on atb-devel-224

source3/libnet/libnet_join.c

index d49d54436bb567948ef7b087dadaf9a720fffc3c..f98d132d50f80b0a925f100225d860587adcfc7d 100644 (file)
@@ -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;