summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-12-28 15:27:42 +0100
committerVolker Lendecke <vl@samba.org>2009-12-28 15:28:43 +0100
commit0aa8946ce08bd50ecf30349894c311efd646492a (patch)
tree5eac5e79e9d74535fababadc125dae2422c5cf94 /source3
parent2c49678ce5d9203a0af2fa82961c0ebc59e1488f (diff)
downloadsamba-0aa8946ce08bd50ecf30349894c311efd646492a.tar.gz
samba-0aa8946ce08bd50ecf30349894c311efd646492a.tar.bz2
samba-0aa8946ce08bd50ecf30349894c311efd646492a.zip
s3: Simplify winbindd_ads.c:trusted_domains()
No real code change, this just removes an indentation by turning if ( NT_STATUS_IS_OK(result) && trusts.count) { into if (!NT_STATUS_IS_OK(result)) { return result; } if (trusts.count == 0) { return NT_STATUS_OK; }
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/winbindd_ads.c233
1 files changed, 123 insertions, 110 deletions
diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c
index 92c0272088..039c59e339 100644
--- a/source3/winbindd/winbindd_ads.c
+++ b/source3/winbindd/winbindd_ads.c
@@ -1305,139 +1305,152 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
flags,
&trusts,
NULL);
- if ( NT_STATUS_IS_OK(result) && trusts.count) {
-
- /* Allocate memory for trusted domain names and sids */
-
- if ( !(*names = TALLOC_ARRAY(mem_ctx, char *, trusts.count)) ) {
- DEBUG(0, ("trusted_domains: out of memory\n"));
- return NT_STATUS_NO_MEMORY;
- }
+ if (!NT_STATUS_IS_OK(result)) {
+ return result;
+ }
+ if (trusts.count == 0) {
+ return NT_STATUS_OK;
+ }
- if ( !(*alt_names = TALLOC_ARRAY(mem_ctx, char *, trusts.count)) ) {
- DEBUG(0, ("trusted_domains: out of memory\n"));
- return NT_STATUS_NO_MEMORY;
- }
+ /* Allocate memory for trusted domain names and sids */
- if ( !(*dom_sids = TALLOC_ARRAY(mem_ctx, DOM_SID, trusts.count)) ) {
- DEBUG(0, ("trusted_domains: out of memory\n"));
- return NT_STATUS_NO_MEMORY;
- }
+ if ( !(*names = TALLOC_ARRAY(mem_ctx, char *, trusts.count)) ) {
+ DEBUG(0, ("trusted_domains: out of memory\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
- /* Copy across names and sids */
+ if ( !(*alt_names = TALLOC_ARRAY(mem_ctx, char *, trusts.count)) ) {
+ DEBUG(0, ("trusted_domains: out of memory\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+ if ( !(*dom_sids = TALLOC_ARRAY(mem_ctx, DOM_SID, trusts.count)) ) {
+ DEBUG(0, ("trusted_domains: out of memory\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
- ret_count = 0;
- for (i = 0; i < trusts.count; i++) {
- struct winbindd_domain d;
+ /* Copy across names and sids */
- ZERO_STRUCT(d);
+ ret_count = 0;
+ for (i = 0; i < trusts.count; i++) {
+ struct winbindd_domain d;
- /* drop external trusts if this is not our primary
- domain. This means that the returned number of
- domains may be less that the ones actually trusted
- by the DC. */
+ ZERO_STRUCT(d);
- if ( (trusts.array[i].trust_attributes == NETR_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN) &&
- !domain->primary )
- {
- DEBUG(10,("trusted_domains: Skipping external trusted domain "
- "%s because it is outside of our primary domain\n",
- trusts.array[i].netbios_name));
- continue;
- }
+ /*
+ * drop external trusts if this is not our primary
+ * domain. This means that the returned number of
+ * domains may be less that the ones actually trusted
+ * by the DC.
+ */
- /* We must check that the SID of each trusted domain
- * was returned to work around a bug in Windows:
- * http://support.microsoft.com/kb/922832 */
+ if ((trusts.array[i].trust_attributes
+ == NETR_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN) &&
+ !domain->primary )
+ {
+ DEBUG(10,("trusted_domains: Skipping external trusted "
+ "domain %s because it is outside of our "
+ "primary domain\n",
+ trusts.array[i].netbios_name));
+ continue;
+ }
- (*names)[ret_count] = CONST_DISCARD(char *, trusts.array[i].netbios_name);
- (*alt_names)[ret_count] = CONST_DISCARD(char *, trusts.array[i].dns_name);
- if (trusts.array[i].sid) {
- sid_copy(&(*dom_sids)[ret_count], trusts.array[i].sid);
- } else {
- sid_copy(&(*dom_sids)[ret_count], &global_sid_NULL);
- }
+ /*
+ * We must check that the SID of each trusted domain
+ * was returned to work around a bug in Windows:
+ * http://support.microsoft.com/kb/922832
+ */
+
+ (*names)[ret_count] = CONST_DISCARD(
+ char *, trusts.array[i].netbios_name);
+ (*alt_names)[ret_count] = CONST_DISCARD(
+ char *, trusts.array[i].dns_name);
+ if (trusts.array[i].sid) {
+ sid_copy(&(*dom_sids)[ret_count], trusts.array[i].sid);
+ } else {
+ sid_copy(&(*dom_sids)[ret_count], &global_sid_NULL);
+ }
- /* add to the trusted domain cache */
+ /* add to the trusted domain cache */
- fstrcpy( d.name, trusts.array[i].netbios_name);
- fstrcpy( d.alt_name, trusts.array[i].dns_name);
- if (trusts.array[i].sid) {
- sid_copy( &d.sid, trusts.array[i].sid);
- } else {
- sid_copy(&d.sid, &global_sid_NULL);
- }
+ fstrcpy( d.name, trusts.array[i].netbios_name);
+ fstrcpy( d.alt_name, trusts.array[i].dns_name);
+ if (trusts.array[i].sid) {
+ sid_copy( &d.sid, trusts.array[i].sid);
+ } else {
+ sid_copy(&d.sid, &global_sid_NULL);
+ }
- if ( domain->primary ) {
+ if ( domain->primary ) {
+ DEBUG(10,("trusted_domains(ads): Searching "
+ "trusted domain list of %s and storing "
+ "trust flags for domain %s\n",
+ domain->name, d.alt_name));
+
+ d.domain_flags = trusts.array[i].trust_flags;
+ d.domain_type = trusts.array[i].trust_type;
+ d.domain_trust_attribs =
+ trusts.array[i].trust_attributes;
+
+ wcache_tdc_add_domain( &d );
+ ret_count++;
+ } else if ( (domain->domain_flags&fr_flags) == fr_flags ) {
+ /* Check if we already have this record. If
+ * we are following our forest root that is not
+ * our primary domain, we want to keep trust
+ * flags from the perspective of our primary
+ * domain not our forest root. */
+ struct winbindd_tdc_domain *exist = NULL;
+
+ exist = wcache_tdc_fetch_domain(
+ NULL, trusts.array[i].netbios_name);
+ if (!exist) {
DEBUG(10,("trusted_domains(ads): Searching "
- "trusted domain list of %s and storing "
- "trust flags for domain %s\n",
- domain->name, d.alt_name));
-
+ "trusted domain list of %s and "
+ "storing trust flags for domain "
+ "%s\n", domain->name, d.alt_name));
d.domain_flags = trusts.array[i].trust_flags;
d.domain_type = trusts.array[i].trust_type;
- d.domain_trust_attribs = trusts.array[i].trust_attributes;
+ d.domain_trust_attribs =
+ trusts.array[i].trust_attributes;
wcache_tdc_add_domain( &d );
ret_count++;
- } else if ( (domain->domain_flags&fr_flags) == fr_flags ) {
- /* Check if we already have this record. If
- * we are following our forest root that is not
- * our primary domain, we want to keep trust
- * flags from the perspective of our primary
- * domain not our forest root. */
- struct winbindd_tdc_domain *exist = NULL;
-
- exist =
- wcache_tdc_fetch_domain(NULL, trusts.array[i].netbios_name);
- if (!exist) {
- DEBUG(10,("trusted_domains(ads): Searching "
- "trusted domain list of %s and storing "
- "trust flags for domain %s\n",
- domain->name, d.alt_name));
- d.domain_flags = trusts.array[i].trust_flags;
- d.domain_type = trusts.array[i].trust_type;
- d.domain_trust_attribs = trusts.array[i].trust_attributes;
-
- wcache_tdc_add_domain( &d );
- ret_count++;
- }
- TALLOC_FREE(exist);
+ }
+ TALLOC_FREE(exist);
+ } else {
+ /* This gets a little tricky. If we are
+ following a transitive forest trust, then
+ innerit the flags, type, and attribs from
+ the domain we queried to make sure we don't
+ record the view of the trust from the wrong
+ side. Always view it from the side of our
+ primary domain. --jerry */
+ struct winbindd_tdc_domain *parent = NULL;
+
+ DEBUG(10,("trusted_domains(ads): Searching "
+ "trusted domain list of %s and inheriting "
+ "trust flags for domain %s\n",
+ domain->name, d.alt_name));
+
+ parent = wcache_tdc_fetch_domain(NULL, domain->name);
+ if (parent) {
+ d.domain_flags = parent->trust_flags;
+ d.domain_type = parent->trust_type;
+ d.domain_trust_attribs = parent->trust_attribs;
} else {
- /* This gets a little tricky. If we are
- following a transitive forest trust, then
- innerit the flags, type, and attribs from
- the domain we queried to make sure we don't
- record the view of the trust from the wrong
- side. Always view it from the side of our
- primary domain. --jerry */
- struct winbindd_tdc_domain *parent = NULL;
-
- DEBUG(10,("trusted_domains(ads): Searching "
- "trusted domain list of %s and inheriting "
- "trust flags for domain %s\n",
- domain->name, d.alt_name));
-
- parent = wcache_tdc_fetch_domain(NULL, domain->name);
- if (parent) {
- d.domain_flags = parent->trust_flags;
- d.domain_type = parent->trust_type;
- d.domain_trust_attribs = parent->trust_attribs;
- } else {
- d.domain_flags = domain->domain_flags;
- d.domain_type = domain->domain_type;
- d.domain_trust_attribs = domain->domain_trust_attribs;
- }
- TALLOC_FREE(parent);
-
- wcache_tdc_add_domain( &d );
- ret_count++;
+ d.domain_flags = domain->domain_flags;
+ d.domain_type = domain->domain_type;
+ d.domain_trust_attribs =
+ domain->domain_trust_attribs;
}
- }
+ TALLOC_FREE(parent);
- *num_domains = ret_count;
+ wcache_tdc_add_domain( &d );
+ ret_count++;
+ }
}
+ *num_domains = ret_count;
return result;
}