]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/rpc_server: return NULL dns_name for NT4 trusts
authorRalph Boehme <slow@samba.org>
Thu, 18 Jan 2024 18:12:34 +0000 (19:12 +0100)
committerStefan Metzmacher <metze@samba.org>
Sat, 20 Jan 2024 13:20:37 +0000 (13:20 +0000)
That's what Windows returns for an NT4 trust:

  array: struct netr_DomainTrust
      netbios_name             : *
          netbios_name             : 'NT4TRUST'
      dns_name                 : NULL
      trust_flags              : 0x00000020 (32)
             0: NETR_TRUST_FLAG_IN_FOREST
             0: NETR_TRUST_FLAG_OUTBOUND
             0: NETR_TRUST_FLAG_TREEROOT
             0: NETR_TRUST_FLAG_PRIMARY
             0: NETR_TRUST_FLAG_NATIVE
             1: NETR_TRUST_FLAG_INBOUND
             0: NETR_TRUST_FLAG_MIT_KRB5
             0: NETR_TRUST_FLAG_AES
      parent_index             : 0x00000000 (0)
      trust_type               : LSA_TRUST_TYPE_DOWNLEVEL (1)
      trust_attributes         : 0x00000000 (0)
             0: LSA_TRUST_ATTRIBUTE_NON_TRANSITIVE
             0: LSA_TRUST_ATTRIBUTE_UPLEVEL_ONLY
             0: LSA_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN
             0: LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE
             0: LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION
             0: LSA_TRUST_ATTRIBUTE_WITHIN_FOREST
             0: LSA_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL
             0: LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION
             0: LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION_NO_TGT_DELEGATION
             0: LSA_TRUST_ATTRIBUTE_PIM_TRUST
             0: LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATION_ENABLE_TGT_DELEGATION
      sid                      : *
          sid                      : S-1-5-21-4267984555-3675415144-1682400025
      guid                     : 00000000-0000-0000-0000-000000000000

Even though when creating the trust the DNS name must not be NULL and the
trustPartner and name attributes are set to the flatName in the trustedDomain
object:

  dn: CN=NT4TRUST,CN=System,DC=wdom2,DC=site
  objectClass: top
  objectClass: leaf
  objectClass: trustedDomain
  cn: NT4TRUST
  distinguishedName: CN=NT4TRUST,CN=System,DC=wdom2,DC=site
  instanceType: 4
  whenCreated: 20240118175040.0Z
  whenChanged: 20240118175040.0Z
  uSNCreated: 4939915
  uSNChanged: 4939916
  showInAdvancedViewOnly: TRUE
  name: NT4TRUST
  objectGUID: c2273b74-19ff-4f5a-b528-9e5ae21960dd
  securityIdentifier: S-1-5-21-4267984555-3675415144-1682400025
  trustDirection: 1
  trustPartner: NT4TRUST
  trustPosixOffset: 0
  trustType: 1
  trustAttributes: 0
  flatName: NT4TRUST
  objectCategory: CN=Trusted-Domain,CN=Schema,CN=Configuration,DC=wdom2,DC=site
  isCriticalSystemObject: TRUE
  dSCorePropagationData: 16010101000000.0Z

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15533

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/rpc_server/netlogon/dcerpc_netlogon.c

index fc32b61d10b5e363e9bcf1d6e67c479bef3c00b5..2c7fecca1a0705133b9166449528e6d2df827c59 100644 (file)
@@ -3991,8 +3991,6 @@ static WERROR fill_trusted_domains_array(TALLOC_CTX *mem_ctx,
                                  ldb_dn_get_linearized(dom_res[i]->dn)));
                }
 
-               trusts->array[n].dns_name = talloc_steal(trusts->array, ldb_msg_find_attr_as_string(dom_res[i], "trustPartner", NULL));
-
                trusts->array[n].trust_flags = flags;
                if ((trust_flags & NETR_TRUST_FLAG_IN_FOREST) &&
                    !(flags & NETR_TRUST_FLAG_TREEROOT)) {
@@ -4007,6 +4005,16 @@ static WERROR fill_trusted_domains_array(TALLOC_CTX *mem_ctx,
                                ldb_msg_find_attr_as_uint(dom_res[i],
                                                  "trustAttributes", 0);
 
+               if (trusts->array[n].trust_type != LSA_TRUST_TYPE_DOWNLEVEL) {
+                       trusts->array[n].dns_name = talloc_steal(
+                               trusts->array,
+                               ldb_msg_find_attr_as_string(dom_res[i],
+                                                           "trustPartner",
+                                                           NULL));
+               } else {
+                       trusts->array[n].dns_name = NULL;
+               }
+
                if ((trusts->array[n].trust_type == LSA_TRUST_TYPE_MIT) ||
                    (trusts->array[n].trust_type == LSA_TRUST_TYPE_DCE)) {
                        struct dom_sid zero_sid;