winbindd: add set_routing_domain()
authorRalph Boehme <slow@samba.org>
Wed, 13 Dec 2017 16:11:25 +0000 (17:11 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 13 Jan 2018 11:55:08 +0000 (12:55 +0100)
source3/winbindd/winbindd.h
source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_util.c

index 682040fd1a7dbd67b154dc3466a481f5289ec7e3..b60094bafcdd92b91ed3c3bd71760ec4383d343d 100644 (file)
@@ -143,6 +143,7 @@ struct winbindd_domain {
        uint32_t domain_flags;                   /* Domain flags from netlogon.h */
        uint32_t domain_type;                    /* Domain type from netlogon.h */
        uint32_t domain_trust_attribs;           /* Trust attribs from netlogon.h */
+       const struct winbindd_domain *routing_domain;
        bool initialized;                      /* Did we already ask for the domain mode? */
        bool native_mode;                      /* is this a win2k domain in native mode ? */
        bool active_directory;                 /* is this a win2k active directory ? */
index 5ab1e8fd590e09a1d9026a50927e8c8c3738671c..4ab52a42ba56b2cbb6c53d55e1c1f77716f809b7 100644 (file)
@@ -438,6 +438,8 @@ NTSTATUS winbind_dual_SamLogon(struct winbindd_domain *domain,
 
 struct winbindd_domain *domain_list(void);
 struct winbindd_domain *wb_next_domain(struct winbindd_domain *domain);
+bool set_routing_domain(struct winbindd_domain *domain,
+                       const struct winbindd_domain *routing_domain);
 bool domain_is_forest_root(const struct winbindd_domain *domain);
 void rescan_trusted_domains(struct tevent_context *ev, struct tevent_timer *te,
                            struct timeval now, void *private_data);
index dd3206c01f48de467af776f9cfb8d7f3197d3a4d..fb1793d250a7e162afd34ae2659cefed0f7bd61c 100644 (file)
@@ -290,6 +290,19 @@ static NTSTATUS add_trusted_domain(const char *domain_name,
        return NT_STATUS_OK;
 }
 
+bool set_routing_domain(struct winbindd_domain *domain,
+                       const struct winbindd_domain *routing_domain)
+{
+       if (domain->routing_domain == NULL) {
+               domain->routing_domain = routing_domain;
+               return true;
+       }
+       if (domain->routing_domain != routing_domain) {
+               return false;
+       }
+       return true;
+}
+
 bool domain_is_forest_root(const struct winbindd_domain *domain)
 {
        const uint32_t fr_flags =
@@ -1105,6 +1118,8 @@ bool init_domain_list(void)
                        struct ForestTrustInfo fti;
                        uint32_t fi;
                        enum ndr_err_code ndr_err;
+                       struct winbindd_domain *routing_domain = NULL;
+                       bool ok;
 
                        if (domains[i]->trust_type != LSA_TRUST_TYPE_UPLEVEL) {
                                continue;
@@ -1118,6 +1133,14 @@ bool init_domain_list(void)
                                continue;
                        }
 
+                       routing_domain = find_domain_from_name_noinit(
+                               domains[i]->netbios_name);
+                       if (routing_domain == NULL) {
+                               DBG_ERR("Can't find winbindd domain [%s]\n",
+                                       domains[i]->netbios_name);
+                               return false;
+                       }
+
                        ndr_err = ndr_pull_struct_blob_all(
                                        &domains[i]->trust_forest_trust_info,
                                        talloc_tos(), &fti,
@@ -1171,6 +1194,17 @@ bool init_domain_list(void)
                                                   nt_errstr(status));
                                        return false;
                                }
+                               if (domain == NULL) {
+                                       continue;
+                               }
+                               ok = set_routing_domain(domain, routing_domain);
+                               if (!ok) {
+                                       DBG_ERR("set_routing_domain on [%s] to "
+                                               "[%s] failed\n",
+                                               domain->name,
+                                               routing_domain->name);
+                                       return false;
+                               }
                        }
                }
        } else if (IS_DC) {