[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4142-g7cdcf4d

Jeremy Allison jra at samba.org
Tue Sep 16 17:42:46 GMT 2008


The branch, v3-3-test has been updated
       via  7cdcf4dff2cb02ec16f4e78b85701cd2043be274 (commit)
       via  081787719590b319633e2bc34f747feabaf3c6fe (commit)
       via  0a2c8ac3f6af38ebeb61a49c515bdc84591130cc (commit)
       via  1ed8c35a730a01a565762485fead8db9cce4c469 (commit)
      from  cc6d1c9a9fb4d97278af4d676f260c479b338638 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 7cdcf4dff2cb02ec16f4e78b85701cd2043be274
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Tue Sep 16 10:41:55 2008 -0700

    * Allow an admin to define the "uid" attribute for a RFC2307
      user object in AD to be the username alias.
    
    For example:
    
      $ net ads search "(uid=coffeedude)"
      distinguishedName: CN=Gerald W. Carter,CN=Users,DC=pink,DC=plainjoe,DC=org
      sAMAccountName: gcarter
      memberOf: CN=UnixUsers,CN=Users,DC=pink,DC=plainjoe,DC=org
      memberOf: CN=Domain Admins,CN=Users,DC=pink,DC=plainjoe,DC=org
      memberOf: CN=Enterprise Admins,CN=Users,DC=pink,DC=plainjoe,DC=org
      memberOf: CN=Schema Admins,CN=Users,DC=pink,DC=plainjoe,DC=org
      uid: coffeedude
      uidNumber: 10000
      gidNumber: 10000
      unixHomeDirectory: /home/gcarter
      loginShell: /bin/bash
    
      $ ssh coffeedude at 192.168.56.91
      Password:
    
      coffeedude at orville:~$ id
      uid=10000(coffeedude) gid=10000(PINK\unixusers) groups=10000(PINK\unixusers)
    
      $ getent passwd PINK\\gcarter
      coffeedude:*:10000:10000::/home/gcarter:/bin/bash
    
      $ getent passwd coffeedude
      coffeedude:*:10000:10000::/home/gcarter:/bin/bash
    
      $ getent group PINK\\Unixusers
      PINK\unixusers:x:10000:coffeedude

commit 081787719590b319633e2bc34f747feabaf3c6fe
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Mon Sep 15 15:51:44 2008 -0500

    idmap_hash: Add the idmap/nss-info provider from Likewise Open.
    
    * Port the Likewise Open idmap/nss_info provider (renamed to
      idmap_hash).
    
    * uids & gids are generated based on a hashing algorithm that collapse
      the Domain SID to a 31 bit number.  The reverse mapping from the
      high order 11 bits to the originat8ing sdomain SID is stored in
      a has table initialized at start up.
    
    * Includes support for "idmap_hash:name_map = <filename>" for the
      name aliasing layer.  The name map file consist of entries in
      the form "alias = DOMAIN\name"

commit 0a2c8ac3f6af38ebeb61a49c515bdc84591130cc
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Mon Sep 15 15:50:15 2008 -0500

    winbindd: Update the calls to ws_name_XX() to reflect API changes.
    
    * Ensures that all points an which a name is received or returned
      to/from a client passes through the name aliases layer (users
      and groups).

commit 1ed8c35a730a01a565762485fead8db9cce4c469
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Mon Sep 15 15:41:37 2008 -0500

    winbindd: Add support for name aliasing.
    
    * Add support user and group name aliasing by expanding
      the ws_name_replace() and ws_name_return() functions.
      The lookup path is
         aliases -> qualified name -> SID
         SID -> fully qualified name -> alias
      In other words, the name aliasing support is a thin layer
      built on top of SID/NAME translation.
    
    * Rename the ws_name_XX() functions to normalize_name_map()
      and normalize_name_unmap().  Chaneg interface to return
      NTSTATUS rather than char *.
    
    * Add associated cache validation functions.

-----------------------------------------------------------------------

Summary of changes:
 source/Makefile.in                      |    8 +
 source/configure.in                     |    1 +
 source/include/ads.h                    |    5 +
 source/include/nss_info.h               |   10 +
 source/libads/ldap_schema.c             |   15 +-
 source/winbindd/idmap_ad.c              |  177 +++++++++++++-
 source/winbindd/idmap_hash/idmap_hash.c |  393 +++++++++++++++++++++++++++++++
 source/winbindd/idmap_hash/idmap_hash.h |   60 +++++
 source/winbindd/idmap_hash/mapfile.c    |  175 ++++++++++++++
 source/winbindd/nss_info.c              |   41 ++++
 source/winbindd/nss_info_template.c     |   32 +++-
 source/winbindd/winbindd_cache.c        |  249 +++++++++++++++++++
 source/winbindd/winbindd_group.c        |  182 ++++++++++++---
 source/winbindd/winbindd_pam.c          |   60 +++++-
 source/winbindd/winbindd_proto.h        |   18 ++-
 source/winbindd/winbindd_rpc.c          |   44 +++-
 source/winbindd/winbindd_user.c         |   74 ++++++-
 source/winbindd/winbindd_util.c         |  107 +++++++--
 18 files changed, 1571 insertions(+), 80 deletions(-)
 create mode 100644 source/winbindd/idmap_hash/idmap_hash.c
 create mode 100644 source/winbindd/idmap_hash/idmap_hash.h
 create mode 100644 source/winbindd/idmap_hash/mapfile.c


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index beb14ee..30ad248 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -985,6 +985,10 @@ IDMAP_OBJ     = winbindd/idmap.o winbindd/idmap_util.o @IDMAP_STATIC@
 
 NSS_INFO_OBJ = winbindd/nss_info.o @NSS_INFO_STATIC@
 
+IDMAP_HASH_OBJ = \
+		winbindd/idmap_hash/idmap_hash.o \
+		winbindd/idmap_hash/mapfile.o
+
 WINBINDD_OBJ1 = \
 		winbindd/winbindd.o       \
 		winbindd/winbindd_user.o  \
@@ -2216,6 +2220,10 @@ bin/ad. at SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_ad.o
 	@echo "Building plugin $@"
 	@$(SHLD_MODULE) winbindd/idmap_ad.o
 
+bin/hash. at SHLIBEXT@: $(BINARY_PREREQS) $(IDMAP_HASH_OBJ)
+	@echo "Building plugin $@"
+	@$(SHLD_MODULE) $(IDMAP_HASH_OBJ)
+
 bin/tdb2. at SHLIBEXT@: $(BINARY_PREREQS) winbindd/idmap_tdb2.o
 	@echo "Building plugin $@"
 	@$(SHLD_MODULE) winbindd/idmap_tdb2.o
diff --git a/source/configure.in b/source/configure.in
index e7b2aff..7211b0f 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -6059,6 +6059,7 @@ SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_hash, \$(IDMAP_HASH_OBJ), "bin/hash.$SHLIBEXT", IDMAP)
 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
 
 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
diff --git a/source/include/ads.h b/source/include/ads.h
index 97faf0b..b72d250 100644
--- a/source/include/ads.h
+++ b/source/include/ads.h
@@ -133,6 +133,7 @@ struct posix_schema {
 	char *posix_uidnumber_attr;
 	char *posix_gidnumber_attr;
 	char *posix_gecos_attr;
+	char *posix_uid_attr;
 };
 
 
@@ -179,6 +180,7 @@ typedef void **ADS_MODLIST;
 #define ADS_ATTR_SFU_HOMEDIR_OID 	"1.2.840.113556.1.6.18.1.344"
 #define ADS_ATTR_SFU_SHELL_OID 		"1.2.840.113556.1.6.18.1.312"
 #define ADS_ATTR_SFU_GECOS_OID 		"1.2.840.113556.1.6.18.1.337"
+#define ADS_ATTR_SFU_UID_OID            "1.2.840.113556.1.6.18.1.309"
 
 /* ldap attribute oids (Services for Unix 2.0) */
 #define ADS_ATTR_SFU20_UIDNUMBER_OID	"1.2.840.113556.1.4.7000.187.70"
@@ -186,6 +188,8 @@ typedef void **ADS_MODLIST;
 #define ADS_ATTR_SFU20_HOMEDIR_OID	"1.2.840.113556.1.4.7000.187.106"
 #define ADS_ATTR_SFU20_SHELL_OID	"1.2.840.113556.1.4.7000.187.72"
 #define ADS_ATTR_SFU20_GECOS_OID 	"1.2.840.113556.1.4.7000.187.97"
+#define ADS_ATTR_SFU20_UID_OID          "1.2.840.113556.1.4.7000.187.102"
+
 
 /* ldap attribute oids (RFC2307) */
 #define ADS_ATTR_RFC2307_UIDNUMBER_OID	"1.3.6.1.1.1.1.0"
@@ -193,6 +197,7 @@ typedef void **ADS_MODLIST;
 #define ADS_ATTR_RFC2307_HOMEDIR_OID	"1.3.6.1.1.1.1.3"
 #define ADS_ATTR_RFC2307_SHELL_OID	"1.3.6.1.1.1.1.4"
 #define ADS_ATTR_RFC2307_GECOS_OID	"1.3.6.1.1.1.1.2"
+#define ADS_ATTR_RFC2307_UID_OID        "0.9.2342.19200300.100.1.1"
 
 /* ldap bitwise searches */
 #define ADS_LDAP_MATCHING_RULE_BIT_AND	"1.2.840.113556.1.4.803"
diff --git a/source/include/nss_info.h b/source/include/nss_info.h
index 1ff9ebc..e756136 100644
--- a/source/include/nss_info.h
+++ b/source/include/nss_info.h
@@ -66,6 +66,10 @@ struct nss_info_methods {
 				  TALLOC_CTX *ctx, 
 				  ADS_STRUCT *ads, LDAPMessage *msg,
 				  char **homedir, char **shell, char **gecos, gid_t *p_gid);
+	NTSTATUS (*map_to_alias)( TALLOC_CTX *mem_ctx, const char *domain,
+				  const char *name, char **alias );
+	NTSTATUS (*map_from_alias)( TALLOC_CTX *mem_ctx, const char *domain,
+				    const char *alias, char **name );
 	NTSTATUS (*close_fn)( void );
 };
 
@@ -84,6 +88,12 @@ NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid,
                        char **homedir, char **shell, char **gecos,
                        gid_t *p_gid);
 
+NTSTATUS nss_map_to_alias( TALLOC_CTX *mem_ctx, const char *domain,
+			   const char *name, char **alias );
+
+NTSTATUS nss_map_from_alias( TALLOC_CTX *mem_ctx, const char *domain,
+			     const char *alias, char **name );
+
 NTSTATUS nss_close( const char *parameters );
 
 #endif /* _IDMAP_NSS_H_ */
diff --git a/source/libads/ldap_schema.c b/source/libads/ldap_schema.c
index ff41ccc..b5d2d35 100644
--- a/source/libads/ldap_schema.c
+++ b/source/libads/ldap_schema.c
@@ -246,19 +246,22 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
 					ADS_ATTR_SFU_GIDNUMBER_OID,
 					ADS_ATTR_SFU_HOMEDIR_OID,
 					ADS_ATTR_SFU_SHELL_OID,
-					ADS_ATTR_SFU_GECOS_OID};
+					ADS_ATTR_SFU_GECOS_OID,
+					ADS_ATTR_SFU_UID_OID };
 
 	const char *oids_sfu20[] = { 	ADS_ATTR_SFU20_UIDNUMBER_OID,
 					ADS_ATTR_SFU20_GIDNUMBER_OID,
 					ADS_ATTR_SFU20_HOMEDIR_OID,
 					ADS_ATTR_SFU20_SHELL_OID,
-					ADS_ATTR_SFU20_GECOS_OID};
+					ADS_ATTR_SFU20_GECOS_OID,
+					ADS_ATTR_SFU20_UID_OID };
 
 	const char *oids_rfc2307[] = {	ADS_ATTR_RFC2307_UIDNUMBER_OID,
 					ADS_ATTR_RFC2307_GIDNUMBER_OID,
 					ADS_ATTR_RFC2307_HOMEDIR_OID,
 					ADS_ATTR_RFC2307_SHELL_OID,
-					ADS_ATTR_RFC2307_GECOS_OID };
+					ADS_ATTR_RFC2307_GECOS_OID,
+					ADS_ATTR_RFC2307_UID_OID };
 
 	DEBUG(10,("ads_check_posix_schema_mapping for schema mode: %d\n", map_type));
 
@@ -359,6 +362,12 @@ ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
 		    strequal(ADS_ATTR_SFU20_GECOS_OID, oids_out[i])) {
 			schema->posix_gecos_attr = talloc_strdup(schema, names_out[i]);
 		}
+
+		if (strequal(ADS_ATTR_RFC2307_UID_OID, oids_out[i]) ||
+		    strequal(ADS_ATTR_SFU_UID_OID, oids_out[i]) ||
+		    strequal(ADS_ATTR_SFU20_UID_OID, oids_out[i])) {
+			schema->posix_uid_attr = talloc_strdup(schema, names_out[i]);
+		}
 	}
 
 	if (!schema->posix_uidnumber_attr ||
diff --git a/source/winbindd/idmap_ad.c b/source/winbindd/idmap_ad.c
index d7c8749..8144d87 100644
--- a/source/winbindd/idmap_ad.c
+++ b/source/winbindd/idmap_ad.c
@@ -818,6 +818,159 @@ done:
 	return nt_status;
 }
 
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS nss_ad_map_to_alias(TALLOC_CTX *mem_ctx,
+				    const char *domain,
+				    const char *name,
+				    char **alias)
+{
+	ADS_STRUCT *ads_internal = NULL;
+	const char *attrs[] = {NULL, /* attr_uid */
+			       NULL };
+	char *filter = NULL;
+	LDAPMessage *msg = NULL;
+	ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
+	NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+
+	/* Check incoming parameters */
+
+	if ( !domain || !name || !*alias) {
+		nt_status = NT_STATUS_INVALID_PARAMETER;
+		goto done;
+	}
+
+	/* Only do query if we are online */
+
+	if (idmap_is_offline())	{
+		nt_status = NT_STATUS_FILE_IS_OFFLINE;
+		goto done;
+	}
+
+	ads_internal = ad_idmap_cached_connection();
+
+	if (!ads_internal || !ad_schema) {
+		nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+		goto done;
+	}
+
+	attrs[0] = ad_schema->posix_uid_attr;
+
+	filter = talloc_asprintf(mem_ctx,
+				 "(sAMAccountName=%s)",
+				 name);
+	if (!filter) {
+		nt_status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	ads_status = ads_search_retry(ads_internal, &msg, filter, attrs);
+	if (!ADS_ERR_OK(ads_status)) {
+		nt_status = ads_ntstatus(ads_status);
+		goto done;
+	}
+
+	*alias = ads_pull_string(ads_internal, mem_ctx, msg, ad_schema->posix_uid_attr );
+
+	if (!*alias) {
+		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+	}
+
+	nt_status = NT_STATUS_OK;
+
+done:
+	if (filter) {
+		talloc_destroy(filter);
+	}
+	if (msg) {
+		ads_msgfree(ads_internal, msg);
+	}
+
+	return nt_status;
+}
+
+/**********************************************************************
+ *********************************************************************/
+
+static NTSTATUS nss_ad_map_from_alias( TALLOC_CTX *mem_ctx,
+					     const char *domain,
+					     const char *alias,
+					     char **name )
+{
+	ADS_STRUCT *ads_internal = NULL;
+	const char *attrs[] = {"sAMAccountName",
+			       NULL };
+	char *filter = NULL;
+	LDAPMessage *msg = NULL;
+	ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
+	NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+	char *username;
+
+	/* Check incoming parameters */
+
+	if ( !alias || !name) {
+		nt_status = NT_STATUS_INVALID_PARAMETER;
+		goto done;
+	}
+
+	/* Only do query if we are online */
+
+	if (idmap_is_offline())	{
+		nt_status = NT_STATUS_FILE_IS_OFFLINE;
+		goto done;
+	}
+
+	ads_internal = ad_idmap_cached_connection();
+
+	if (!ads_internal || !ad_schema) {
+		nt_status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+		goto done;
+	}
+
+	filter = talloc_asprintf(mem_ctx,
+				 "(%s=%s)",
+				 ad_schema->posix_uid_attr,
+				 alias);
+	if (!filter) {
+		nt_status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	ads_status = ads_search_retry(ads_internal, &msg, filter, attrs);
+	if (!ADS_ERR_OK(ads_status)) {
+		nt_status = ads_ntstatus(ads_status);
+		goto done;
+	}
+
+      	username = ads_pull_string(ads_internal, mem_ctx, msg,
+				   "sAMAccountName");
+	if (!username) {
+		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+	}
+
+	*name = talloc_asprintf(mem_ctx, "%s\\%s",
+				lp_workgroup(),
+				username);
+	if (!*name) {
+		nt_status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	nt_status = NT_STATUS_OK;
+
+done:
+	if (filter) {
+		talloc_destroy(filter);
+	}
+	if (msg) {
+		ads_msgfree(ads_internal, msg);
+	}
+
+	return nt_status;
+}
+
+
 /************************************************************************
  ***********************************************************************/
 
@@ -843,21 +996,27 @@ static struct idmap_methods ad_methods = {
    function which sets the intended schema model to use */
   
 static struct nss_info_methods nss_rfc2307_methods = {
-	.init         = nss_rfc2307_init,
-	.get_nss_info =	nss_ad_get_info,
-	.close_fn     = nss_ad_close
+	.init           = nss_rfc2307_init,
+	.get_nss_info   = nss_ad_get_info,
+	.map_to_alias   = nss_ad_map_to_alias,
+	.map_from_alias = nss_ad_map_from_alias,
+	.close_fn       = nss_ad_close
 };
 
 static struct nss_info_methods nss_sfu_methods = {
-	.init         = nss_sfu_init,
-	.get_nss_info =	nss_ad_get_info,
-	.close_fn     = nss_ad_close
+	.init           = nss_sfu_init,
+	.get_nss_info   = nss_ad_get_info,
+	.map_to_alias   = nss_ad_map_to_alias,
+	.map_from_alias = nss_ad_map_from_alias,
+	.close_fn       = nss_ad_close
 };
 
 static struct nss_info_methods nss_sfu20_methods = {
-	.init         = nss_sfu20_init,
-	.get_nss_info =	nss_ad_get_info,
-	.close_fn     = nss_ad_close
+	.init           = nss_sfu20_init,
+	.get_nss_info   = nss_ad_get_info,
+	.map_to_alias   = nss_ad_map_to_alias,
+	.map_from_alias = nss_ad_map_from_alias,
+	.close_fn       = nss_ad_close
 };
 
 
diff --git a/source/winbindd/idmap_hash/idmap_hash.c b/source/winbindd/idmap_hash/idmap_hash.c
new file mode 100644
index 0000000..a050f99
--- /dev/null
+++ b/source/winbindd/idmap_hash/idmap_hash.c
@@ -0,0 +1,393 @@
+/*
+ *  idmap_hash.c
+ *
+ * Copyright (C) Gerald Carter  <jerry at samba.org>      2007 - 2008
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "includes.h"
+#include "winbindd/winbindd.h"
+#include "idmap_hash.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_IDMAP
+
+struct sid_hash_table {
+	DOM_SID *sid;
+};
+
+struct sid_hash_table *hashed_domains = NULL;
+
+/*********************************************************************
+ Hash a domain SID (S-1-5-12-aaa-bbb-ccc) to a 12bit number
+ ********************************************************************/
+
+static uint32_t hash_domain_sid(const DOM_SID *sid)
+{
+	uint32_t hash;
+
+	if (sid->num_auths != 4)
+		return 0;
+
+	/* XOR the last three subauths */
+
+	hash = ((sid->sub_auths[1] ^ sid->sub_auths[2]) ^ sid->sub_auths[3]);
+
+	/* Take all 32-bits into account when generating the 12-bit
+	   hash value */
+	hash = (((hash & 0xFFF00000) >> 20)
+		+ ((hash & 0x000FFF00) >> 8)
+		+ (hash & 0x000000FF)) & 0x0000FFF;
+
+	/* return a 12-bit hash value */
+
+	return hash;
+}
+
+/*********************************************************************
+ Hash a Relative ID to a 20 bit number
+ ********************************************************************/
+
+static uint32_t hash_rid(uint32_t rid)
+{
+	/* 20 bits for the rid which allows us to support
+	   the first 100K users/groups in a domain */
+
+	return (rid & 0x0007FFFF);
+}
+
+/*********************************************************************
+ ********************************************************************/
+
+static uint32_t combine_hashes(uint32_t h_domain,
+			       uint32_t h_rid)
+{
+	uint32_t return_id = 0;
+
+	/* shift the hash_domain 19 bits to the left and OR with the
+	   hash_rid */
+
+	return_id = ((h_domain<<19) | h_rid);
+
+	return return_id;
+}
+
+/*********************************************************************
+ ********************************************************************/
+
+static void separate_hashes(uint32_t id,
+			    uint32_t *h_domain,
+			    uint32_t *h_rid)
+{
+	*h_rid = id & 0x0007FFFF;
+	*h_domain = (id & 0x7FF80000) >> 19;
+
+	return;
+}
+
+
+/*********************************************************************
+ ********************************************************************/
+
+static NTSTATUS be_init(struct idmap_domain *dom,
+			const char *params)
+{
+	NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+	struct winbindd_tdc_domain *dom_list = NULL;
+	size_t num_domains = 0;
+	int i;
+
+	/* If the domain SID hash talbe has been initialized, assume
+	   that we completed this function previously */
+
+	if ( hashed_domains ) {
+		nt_status = NT_STATUS_OK;
+		goto done;
+	}
+
+	if (!wcache_tdc_fetch_list(&dom_list, &num_domains)) {
+		nt_status = NT_STATUS_TRUSTED_DOMAIN_FAILURE;
+		BAIL_ON_NTSTATUS_ERROR(nt_status);
+	}
+
+	/* Create the hash table of domain SIDs */
+
+	hashed_domains = TALLOC_ZERO_ARRAY(NULL, struct sid_hash_table, 4096);
+	BAIL_ON_PTR_NT_ERROR(hashed_domains, nt_status);
+
+	/* create the hash table of domain SIDs */
+
+	for (i=0; i<num_domains; i++) {
+		uint32_t hash;
+
+		if (is_null_sid(&dom_list[i].sid))
+			continue;
+		if ((hash = hash_domain_sid(&dom_list[i].sid)) == 0)
+			continue;
+
+		DEBUG(5,("hash:be_init() Adding %s (%s) -> %d\n",
+			 dom_list[i].domain_name,
+			 sid_string_dbg(&dom_list[i].sid),
+			 hash));
+
+		hashed_domains[hash].sid = talloc(hashed_domains, DOM_SID);
+		sid_copy(hashed_domains[hash].sid, &dom_list[i].sid);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list