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

Volker Lendecke vlendec at samba.org
Fri Jul 11 15:53:59 GMT 2008


The branch, v3-3-test has been updated
       via  d0b34cbb4eba2b6543402af2c9f95407546cefad (commit)
       via  5cded3da00c0af40a98d86011507553f97fe6a22 (commit)
       via  fe216bff1d7d805403cbfb3eaf381c2a57a254d7 (commit)
       via  b826420c3adfd24a01080d25f8a61d33d05722c8 (commit)
       via  1b1124bcb9043deb495897467e4cd3ae8a07784b (commit)
       via  b2f7bd6a05afcbba076f78d0caeaf154854db7de (commit)
       via  0d2fc3c394d300d906cdcd14f1abf8e6f84beff7 (commit)
       via  ed5b516c2027d78011cdaa7cbbc01bb01e766381 (commit)
       via  b71ce00796efdd27b593bbbc36f5cbba23fe9240 (commit)
       via  62835f8d7e824a5d469ec5f79e4db739e6602f4f (commit)
       via  061e55d4f48d269dc45fad6739e0872501b9433d (commit)
       via  26ca09a3570a0df051d042bef586ea57ad9f198c (commit)
       via  fa9b128e93cca45b9516917f73f586197e7637f3 (commit)
       via  114ca8577568cdb5a81d8734f1d1d096f1b36c36 (commit)
       via  77ab2fb306a7ad59447a3e1591c2af03447e09c5 (commit)
       via  62e444dd50ae974c2ab9a553cdf7f188a8f2c538 (commit)
       via  cae8ec3199d5b0ffe0bfb6f15adaa5a12343c763 (commit)
       via  847609a148b653b9e3a24b2bc9e1636c6ef0db84 (commit)
       via  23edc4ec0ab1de60a864de01c0ff90ea1378231d (commit)
       via  447d77949f99fdc5fc2bea6ddc27176d3a0871a9 (commit)
       via  a9b29ab6b7503d6d30553a17219603a4f4cd3df9 (commit)
       via  cc536677735ecc318cbd2176ce53b124f44d85a0 (commit)
       via  d4d106776af3f475d46a4dd78794b7b48a3572af (commit)
       via  b0fe0c7ac18d4f47ad4a218114de7bab7a3f19de (commit)
      from  58bc04b31b15c36505c5ecb2d8373e9033972390 (commit)

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


- Log -----------------------------------------------------------------
commit d0b34cbb4eba2b6543402af2c9f95407546cefad
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:46:09 2008 +0200

    Revert "Fix two memory leaks in an error path in idmap.c"
    
    This reverts commit 7cec389e19323e99b6b6258e539be9d1fd65810f.

commit 5cded3da00c0af40a98d86011507553f97fe6a22
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:46:00 2008 +0200

    Revert "Make idmap_init() static"
    
    This reverts commit c8d1bbfddce41cd6bf37dd0a622ef3437a24b492.

commit fe216bff1d7d805403cbfb3eaf381c2a57a254d7
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:54 2008 +0200

    Revert "Fix typo"
    
    This reverts commit fe58926283b51910d8587e32bb11aa681b9a27d3.

commit b826420c3adfd24a01080d25f8a61d33d05722c8
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:46 2008 +0200

    Revert "Fix a debug msg, this was probably a leftover from gencache"
    
    This reverts commit daa171552dc00d9602a05ba199c9a3ff24c802f5.

commit 1b1124bcb9043deb495897467e4cd3ae8a07784b
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:40 2008 +0200

    Revert "Fix indentation"
    
    This reverts commit 954556b527aa652f9a46f0d48834e92befb3c5f9.

commit b2f7bd6a05afcbba076f78d0caeaf154854db7de
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:31 2008 +0200

    Revert "Fix nonempty whitespace only lines"
    
    This reverts commit 0da9d0d0f9662d8bd2f370f764d5a875e11b3068.

commit 0d2fc3c394d300d906cdcd14f1abf8e6f84beff7
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:23 2008 +0200

    Revert "fix typos"
    
    This reverts commit e0957c6f4b1e81c27fda1de7fb7cbc9c585f5ac9.

commit ed5b516c2027d78011cdaa7cbbc01bb01e766381
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:16 2008 +0200

    Revert "Fix nonempty whitespace only lines"
    
    This reverts commit cc77db2acbc35cea58576f1e28c7a760a5e31609.

commit b71ce00796efdd27b593bbbc36f5cbba23fe9240
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:09 2008 +0200

    Revert "Tiny logic simplification: Remove an unnecessary else branch"
    
    This reverts commit 6009ae329375b1c40e3d00df977ddccc8b5cc176.

commit 62835f8d7e824a5d469ec5f79e4db739e6602f4f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:45:03 2008 +0200

    Revert "Fix typo"
    
    This reverts commit fe79c8a5b726754703626ca0bff57074274c98c7.

commit 061e55d4f48d269dc45fad6739e0872501b9433d
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:44:52 2008 +0200

    Revert "Make use of sid_check_is_in_unix_users/groups"
    
    This reverts commit cd8e63b2b45402091d6d328b3c6ca593fc19ac92.

commit 26ca09a3570a0df051d042bef586ea57ad9f198c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:44:44 2008 +0200

    Revert "Don't scream, better explain a bit in comments"
    
    This reverts commit dcc39ed00453a075b23daece2844ca4817bfbfaf.

commit fa9b128e93cca45b9516917f73f586197e7637f3
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:44:35 2008 +0200

    Revert "Fix indentation"
    
    This reverts commit c4e6de9e34e1ff76552ce6d4e72b343fb5f33306.

commit 114ca8577568cdb5a81d8734f1d1d096f1b36c36
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:44:25 2008 +0200

    Revert "Pass NULL to gencache_get when we are not interested in the timeout value"
    
    This reverts commit 16062dfc3dcc8f1ca0024a3ae21effb889c7ffc0.

commit 77ab2fb306a7ad59447a3e1591c2af03447e09c5
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:44:15 2008 +0200

    Revert "Return timed out entries from gencache_get if timeout param != NULL"
    
    This reverts commit 2954b2be563149380e1fae7fe088b98d6cbd42e7.

commit 62e444dd50ae974c2ab9a553cdf7f188a8f2c538
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:44:09 2008 +0200

    Revert "Remove gencache_[un]lock_entry"
    
    This reverts commit 7a5a575ffe5196caecedc93970a25abfbe6f8059.

commit cae8ec3199d5b0ffe0bfb6f15adaa5a12343c763
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:43:54 2008 +0200

    Revert "Remove an unused variable"
    
    This reverts commit 454cb852e06fa3d8bdd0eebb3ebdb24b3d74ecd0.

commit 847609a148b653b9e3a24b2bc9e1636c6ef0db84
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:43:42 2008 +0200

    Revert "Simplify idmap_cache_build_[s]idkey a bit"
    
    This reverts commit 80932c0266ef73b8d0462c078a053444fff47f32.

commit 23edc4ec0ab1de60a864de01c0ff90ea1378231d
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:43:25 2008 +0200

    Revert "Simplify idmap_cache_set() a bit"
    
    This reverts commit 55b976ba93462c6885e8d89edd13c32fb5529944.

commit 447d77949f99fdc5fc2bea6ddc27176d3a0871a9
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:43:17 2008 +0200

    Revert "IDMAP_READ_CACHE_DATA_FMT_TEMPLATE is unused, remove it"
    
    This reverts commit 2396d5d5d2f453f097f8ce77b640ad7e1d7e7c4c.

commit a9b29ab6b7503d6d30553a17219603a4f4cd3df9
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:43:07 2008 +0200

    Revert "Slightly increase the default idmap cache time"
    
    This reverts commit 448836d44d0468a74b962ba3c0b7d51de236374f.

commit cc536677735ecc318cbd2176ce53b124f44d85a0
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:42:58 2008 +0200

    Revert "Convert idmap_cache to gencache"
    
    This reverts commit 0bf0434f22b0ea46fda3ccc4dd612adbc88dd4f2.

commit d4d106776af3f475d46a4dd78794b7b48a3572af
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:42:48 2008 +0200

    Revert "Make use of ADD_TO_ARRAY"
    
    This reverts commit 81f334bd6da601a040f754c46705cfa2fd4f8c45.

commit b0fe0c7ac18d4f47ad4a218114de7bab7a3f19de
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 11 17:42:40 2008 +0200

    Revert "Tiny logic simplification -- remove an else branch"
    
    This reverts commit 01c8c7bbf6163d5c7733db0d8ecbccfe7e4fec7d.

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

Summary of changes:
 docs-xml/smbdotconf/winbind/idmapcachetime.xml |    2 +-
 source/include/proto.h                         |   20 +-
 source/lib/gencache.c                          |   50 ++-
 source/libads/dns.c                            |    3 +-
 source/libsmb/dsgetdcname.c                    |   12 +-
 source/libsmb/namecache.c                      |    6 +-
 source/libsmb/namequery.c                      |    3 +-
 source/libsmb/trustdom_cache.c                 |    6 +-
 source/param/loadparm.c                        |    2 +-
 source/passdb/lookup_sid.c                     |   46 +--
 source/torture/torture.c                       |    4 +-
 source/utils/net_cache.c                       |    3 +-
 source/winbindd/idmap.c                        |  148 +++++---
 source/winbindd/idmap_ad.c                     |   55 ++--
 source/winbindd/idmap_cache.c                  |  514 +++++++++++++++++++-----
 source/winbindd/idmap_nss.c                    |    8 +-
 source/winbindd/idmap_passdb.c                 |    8 +-
 source/winbindd/idmap_rid.c                    |    6 +-
 source/winbindd/idmap_tdb.c                    |    6 +-
 source/winbindd/idmap_tdb2.c                   |   28 +-
 source/winbindd/idmap_util.c                   |   38 +-
 source/winbindd/nss_info.c                     |   33 +-
 source/winbindd/nss_info_template.c            |   10 +-
 source/winbindd/winbindd.h                     |    1 -
 source/winbindd/winbindd_idmap.c               |   46 ++-
 25 files changed, 713 insertions(+), 345 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/winbind/idmapcachetime.xml b/docs-xml/smbdotconf/winbind/idmapcachetime.xml
index 55ead61..1636cdf 100644
--- a/docs-xml/smbdotconf/winbind/idmapcachetime.xml
+++ b/docs-xml/smbdotconf/winbind/idmapcachetime.xml
@@ -9,5 +9,5 @@
 	</para>
 </description>
 
-<value type="default">604800 (i.e. 1 week)</value>
+<value type="default">900</value>
 </samba:parameter>
diff --git a/source/include/proto.h b/source/include/proto.h
index 665a86d..2a5d21d 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -606,6 +606,8 @@ bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob, bool *expired);
 bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
 void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
                       void* data, const char* keystr_pattern);
+int gencache_lock_entry( const char *key );
+void gencache_unlock_entry( const char *key );
 
 /* The following definitions come from lib/genrand.c  */
 
@@ -10482,25 +10484,25 @@ NTSTATUS smb_register_idmap_alloc(int version, const char *name,
 				  struct idmap_alloc_methods *methods);
 NTSTATUS idmap_close(void);
 NTSTATUS idmap_init_cache(void);
+NTSTATUS idmap_init(void);
 NTSTATUS idmap_allocate_uid(struct unixid *id);
 NTSTATUS idmap_allocate_gid(struct unixid *id);
 NTSTATUS idmap_set_uid_hwm(struct unixid *id);
 NTSTATUS idmap_set_gid_hwm(struct unixid *id);
-NTSTATUS idmap_unixids_to_sids(struct id_map **ids, int n_ids);
-NTSTATUS idmap_sids_to_unixids(struct id_map **ids, int n_ids);
+NTSTATUS idmap_unixids_to_sids(struct id_map **ids);
+NTSTATUS idmap_sids_to_unixids(struct id_map **ids);
 NTSTATUS idmap_set_mapping(const struct id_map *id);
 char *idmap_fetch_secret(const char *backend, bool alloc,
 			       const char *domain, const char *identity);
 
 /* The following definitions come from winbindd/idmap_cache.c  */
 
-NTSTATUS idmap_cache_set(const struct id_map *id);
-NTSTATUS idmap_cache_set_negative_sid(const struct id_map *id);
-NTSTATUS idmap_cache_set_negative_id(const struct id_map *id);
-bool idmap_cache_map_sid(const struct dom_sid *sid, struct unixid *xid,
-			 bool *mapped, bool *expired);
-bool idmap_cache_map_id(const struct unixid *xid, struct dom_sid *psid,
-			bool *mapped, bool *expired);
+struct idmap_cache_ctx *idmap_cache_init(TALLOC_CTX *memctx);
+NTSTATUS idmap_cache_set(struct idmap_cache_ctx *cache, const struct id_map *id);
+NTSTATUS idmap_cache_set_negative_sid(struct idmap_cache_ctx *cache, const struct id_map *id);
+NTSTATUS idmap_cache_set_negative_id(struct idmap_cache_ctx *cache, const struct id_map *id);
+NTSTATUS idmap_cache_map_sid(struct idmap_cache_ctx *cache, struct id_map *id);
+NTSTATUS idmap_cache_map_id(struct idmap_cache_ctx *cache, struct id_map *id);
 
 /* The following definitions come from winbindd/idmap_nss.c  */
 
diff --git a/source/lib/gencache.c b/source/lib/gencache.c
index a55b2ab..b773f83 100644
--- a/source/lib/gencache.c
+++ b/source/lib/gencache.c
@@ -166,16 +166,15 @@ bool gencache_del(const char *keystr)
  *
  * @param keystr string that represents a key of this entry
  * @param valstr buffer that is allocated and filled with the entry value
- *               buffer's disposing must be done outside
- * @param timeout If == NULL, the caller is not interested in timed out
- *                entries. If != NULL, return the timeout timestamp, the
- *                caller must figure out itself if this entry is timed out.
+ *        buffer's disposing must be done outside
+ * @param timeout pointer to a time_t that is filled with entry's
+ *        timeout
  *
  * @retval true when entry is successfuly fetched
  * @retval False for failure
  **/
 
-bool gencache_get(const char *keystr, char **valstr, time_t *ptimeout)
+bool gencache_get(const char *keystr, char **valstr, time_t *timeout)
 {
 	TDB_DATA databuf;
 	time_t t;
@@ -208,13 +207,9 @@ bool gencache_get(const char *keystr, char **valstr, time_t *ptimeout)
 		   "timeout = %s", t > time(NULL) ? "valid" :
 		   "expired", keystr, endptr+1, ctime(&t)));
 
-	if ((t <= time(NULL)) && (ptimeout == NULL)) {
-
-		/*
-		 * The entry is expired, and the caller isn't interested in
-		 * timed out ones. Delete it.
-		 */
+	if (t <= time(NULL)) {
 
+		/* We're expired, delete the entry */
 		tdb_delete_bystring(cache, keystr);
 
 		SAFE_FREE(databuf.dptr);
@@ -229,15 +224,15 @@ bool gencache_get(const char *keystr, char **valstr, time_t *ptimeout)
 			return False;
 		}
 	}
-
+	
 	SAFE_FREE(databuf.dptr);
 
-	if (ptimeout) {
-		*ptimeout = t;
+	if (timeout) {
+		*timeout = t;
 	}
 
 	return True;
-}
+} 
 
 /**
  * Get existing entry from the cache file.
@@ -484,3 +479,28 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
 	
 	tdb_search_list_free(first_node);
 }
+
+/********************************************************************
+ lock a key
+********************************************************************/
+
+int gencache_lock_entry( const char *key )
+{
+	if (!gencache_init())
+		return -1;
+	
+	return tdb_lock_bystring(cache, key);
+}
+
+/********************************************************************
+ unlock a key
+********************************************************************/
+
+void gencache_unlock_entry( const char *key )
+{
+	if (!gencache_init())
+		return;
+	
+	tdb_unlock_bystring(cache, key);
+	return;
+}
diff --git a/source/libads/dns.c b/source/libads/dns.c
index a8825d3..3a9e849 100644
--- a/source/libads/dns.c
+++ b/source/libads/dns.c
@@ -790,6 +790,7 @@ bool sitename_store(const char *realm, const char *sitename)
 char *sitename_fetch(const char *realm)
 {
 	char *sitename = NULL;
+	time_t timeout;
 	bool ret = False;
 	const char *query_realm;
 	char *key;
@@ -806,7 +807,7 @@ char *sitename_fetch(const char *realm)
 
 	key = sitename_key(query_realm);
 
-	ret = gencache_get( key, &sitename, NULL );
+	ret = gencache_get( key, &sitename, &timeout );
 	SAFE_FREE(key);
 	if ( !ret ) {
 		DEBUG(5,("sitename_fetch: No stored sitename for %s\n",
diff --git a/source/libsmb/dsgetdcname.c b/source/libsmb/dsgetdcname.c
index afc8703..2a445cb 100644
--- a/source/libsmb/dsgetdcname.c
+++ b/source/libsmb/dsgetdcname.c
@@ -159,6 +159,7 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx,
 {
 	time_t expire_time;
 	char *key;
+	bool ret = false;
 
 	if (!gencache_init()) {
 		return NT_STATUS_INTERNAL_DB_ERROR;
@@ -171,8 +172,15 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx,
 
 	expire_time = time(NULL) + DSGETDCNAME_CACHE_TTL;
 
-	return gencache_set_data_blob(key, blob, expire_time)
-		? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+	if (gencache_lock_entry(key) != 0) {
+		return NT_STATUS_LOCK_NOT_GRANTED;
+	}
+
+	ret = gencache_set_data_blob(key, blob, expire_time);
+
+	gencache_unlock_entry(key);
+
+	return ret ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
 }
 
 /****************************************************************
diff --git a/source/libsmb/namecache.c b/source/libsmb/namecache.c
index 1f462ba..ba706e5 100644
--- a/source/libsmb/namecache.c
+++ b/source/libsmb/namecache.c
@@ -200,6 +200,7 @@ bool namecache_fetch(const char *name,
 			int *num_names)
 {
 	char *key, *value;
+	time_t timeout;
 
 	/* exit now if null pointers were passed as they're required further */
 	if (!ip_list || !num_names) {
@@ -224,7 +225,7 @@ bool namecache_fetch(const char *name,
 		return False;
 	}
 
-	if (!gencache_get(key, &value, NULL)) {
+	if (!gencache_get(key, &value, &timeout)) {
 		DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
 		SAFE_FREE(key);
 		return False;
@@ -366,6 +367,7 @@ bool namecache_status_fetch(const char *keyname,
 {
 	char *key = NULL;
 	char *value = NULL;
+	time_t timeout;
 
 	if (!gencache_init())
 		return False;
@@ -375,7 +377,7 @@ bool namecache_status_fetch(const char *keyname,
 	if (!key)
 		return False;
 
-	if (!gencache_get(key, &value, NULL)) {
+	if (!gencache_get(key, &value, &timeout)) {
 		DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n",
 					key));
 		SAFE_FREE(key);
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index 9b50d20..24d7ee1 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -112,6 +112,7 @@ bool saf_delete( const char *domain )
 char *saf_fetch( const char *domain )
 {
 	char *server = NULL;
+	time_t timeout;
 	bool ret = False;
 	char *key = NULL;
 
@@ -125,7 +126,7 @@ char *saf_fetch( const char *domain )
 
 	key = saf_key( domain );
 
-	ret = gencache_get( key, &server, NULL );
+	ret = gencache_get( key, &server, &timeout );
 
 	SAFE_FREE( key );
 
diff --git a/source/libsmb/trustdom_cache.c b/source/libsmb/trustdom_cache.c
index 92dde0c..6755de3 100644
--- a/source/libsmb/trustdom_cache.c
+++ b/source/libsmb/trustdom_cache.c
@@ -164,6 +164,7 @@ bool trustdom_cache_store(char* name, char* alt_name, const DOM_SID *sid,
 bool trustdom_cache_fetch(const char* name, DOM_SID* sid)
 {
 	char *key = NULL, *value = NULL;
+	time_t timeout;
 
 	/* init the cache */
 	if (!gencache_init())
@@ -178,7 +179,7 @@ bool trustdom_cache_fetch(const char* name, DOM_SID* sid)
 	if (!key)
 		return False;
 	
-	if (!gencache_get(key, &value, NULL)) {
+	if (!gencache_get(key, &value, &timeout)) {
 		DEBUG(5, ("no entry for trusted domain %s found.\n", name));
 		SAFE_FREE(key);
 		return False;
@@ -206,13 +207,14 @@ bool trustdom_cache_fetch(const char* name, DOM_SID* sid)
 uint32 trustdom_cache_fetch_timestamp( void )
 {
 	char *value = NULL;
+	time_t timeout;
 	uint32 timestamp;
 
 	/* init the cache */
 	if (!gencache_init()) 
 		return False;
 		
-	if (!gencache_get(TDOMTSKEY, &value, NULL)) {
+	if (!gencache_get(TDOMTSKEY, &value, &timeout)) {
 		DEBUG(5, ("no timestamp for trusted domain cache located.\n"));
 		SAFE_FREE(value);
 		return 0;
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index c529948..b2cbbf1 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -4827,7 +4827,7 @@ static void init_globals(bool first_time_only)
 	Globals.bWinbindRefreshTickets = False;
 	Globals.bWinbindOfflineLogon = False;
 
-	Globals.iIdmapCacheTime = 7 * 24 * 3600; /* 1 week by default */
+	Globals.iIdmapCacheTime = 900; /* 15 minutes by default */
 	Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
 
 	Globals.bPassdbExpandExplicit = False;
diff --git a/source/passdb/lookup_sid.c b/source/passdb/lookup_sid.c
index 777793c..a7175b9 100644
--- a/source/passdb/lookup_sid.c
+++ b/source/passdb/lookup_sid.c
@@ -1109,7 +1109,7 @@ void store_gid_sid_cache(const DOM_SID *psid, gid_t gid)
 }
 
 /*****************************************************************
- uid_t->SID conversion used if winbind is not around
+ *THE LEGACY* convert uid_t to SID function.
 *****************************************************************/  
 
 static void legacy_uid_to_sid(DOM_SID *psid, uid_t uid)
@@ -1143,7 +1143,7 @@ static void legacy_uid_to_sid(DOM_SID *psid, uid_t uid)
 }
 
 /*****************************************************************
- gid_t->SID conversion used if winbind is not around
+ *THE LEGACY* convert gid_t to SID function.
 *****************************************************************/  
 
 static void legacy_gid_to_sid(DOM_SID *psid, gid_t gid)
@@ -1174,7 +1174,7 @@ static void legacy_gid_to_sid(DOM_SID *psid, gid_t gid)
 }
 
 /*****************************************************************
- SID->uid_t conversion used if winbind is not around
+ *THE LEGACY* convert SID to uid function.
 *****************************************************************/  
 
 static bool legacy_sid_to_uid(const DOM_SID *psid, uid_t *puid)
@@ -1217,7 +1217,8 @@ done:
 }
 
 /*****************************************************************
- SID->gid_t conversion used if winbind is not around
+ *THE LEGACY* convert SID to gid function.
+ Group mapping is used for gids that maps to Wellknown SIDs
 *****************************************************************/  
 
 static bool legacy_sid_to_gid(const DOM_SID *psid, gid_t *pgid)
@@ -1280,7 +1281,7 @@ static bool legacy_sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 }
 
 /*****************************************************************
- uid_t->SID conversion
+ *THE CANONICAL* convert uid_t to SID function.
 *****************************************************************/  
 
 void uid_to_sid(DOM_SID *psid, uid_t uid)
@@ -1309,7 +1310,7 @@ void uid_to_sid(DOM_SID *psid, uid_t uid)
 }
 
 /*****************************************************************
- gid_t->SID conversion
+ *THE CANONICAL* convert gid_t to SID function.
 *****************************************************************/  
 
 void gid_to_sid(DOM_SID *psid, gid_t gid)
@@ -1338,11 +1339,12 @@ void gid_to_sid(DOM_SID *psid, gid_t gid)
 }
 
 /*****************************************************************
- SID->uid_t conversion
+ *THE CANONICAL* convert SID to uid function.
 *****************************************************************/  
 
 bool sid_to_uid(const DOM_SID *psid, uid_t *puid)
 {
+	uint32 rid;
 	gid_t gid;
 
 	if (fetch_uid_from_cache(puid, psid))
@@ -1354,16 +1356,13 @@ bool sid_to_uid(const DOM_SID *psid, uid_t *puid)
 
 	/* Optimize for the Unix Users Domain
 	 * as the conversion is straightforward */
-
-	if (sid_check_is_in_unix_users(psid)) {
-		uint32_t rid;
-
-		sid_peek_rid(psid, &rid);
-		*puid = (uid_t)rid;
+	if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
+		uid_t uid = rid;
+		*puid = uid;
 
 		/* return here, don't cache */
-		DEBUG(10, ("sid %s -> uid %u\n", sid_string_dbg(psid),
-			   (unsigned int)rid));
+		DEBUG(10,("sid %s -> uid %u\n", sid_string_dbg(psid),
+			(unsigned int)*puid ));
 		return true;
 	}
 
@@ -1388,11 +1387,13 @@ bool sid_to_uid(const DOM_SID *psid, uid_t *puid)
 }
 
 /*****************************************************************
- SID->gid_t conversion
+ *THE CANONICAL* convert SID to gid function.
+ Group mapping is used for gids that maps to Wellknown SIDs
 *****************************************************************/  
 
 bool sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 {
+	uint32 rid;
 	uid_t uid;
 
 	if (fetch_gid_from_cache(pgid, psid))
@@ -1403,16 +1404,13 @@ bool sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 
 	/* Optimize for the Unix Groups Domain
 	 * as the conversion is straightforward */
-
-	if (sid_check_is_in_unix_groups(psid)) {
-		uint32_t rid;
-
-		sid_peek_rid(psid, &rid);
-		*pgid = (gid_t)rid;
+	if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
+		gid_t gid = rid;
+		*pgid = gid;
 
 		/* return here, don't cache */
-		DEBUG(10, ("sid %s -> gid %u\n", sid_string_dbg(psid),
-			   (unsigned int)rid));
+		DEBUG(10,("sid %s -> gid %u\n", sid_string_dbg(psid),
+			(unsigned int)*pgid ));
 		return true;
 	}
 
diff --git a/source/torture/torture.c b/source/torture/torture.c
index 98dd900..d8add20 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -4933,7 +4933,7 @@ static bool run_local_gencache(int dummy)
 		return False;
 	}
 
-	if (!gencache_get("foo", &val, NULL)) {
+	if (!gencache_get("foo", &val, &tm)) {
 		d_printf("%s: gencache_get() failed\n", __location__);
 		return False;
 	}
@@ -4957,7 +4957,7 @@ static bool run_local_gencache(int dummy)
 		return False;
 	}
 			
-	if (gencache_get("foo", &val, NULL)) {
+	if (gencache_get("foo", &val, &tm)) {
 		d_printf("%s: gencache_get() on deleted entry "
 			 "succeeded\n", __location__);
 		return False;
diff --git a/source/utils/net_cache.c b/source/utils/net_cache.c
index 21fcc91..4e9ae18 100644
--- a/source/utils/net_cache.c
+++ b/source/utils/net_cache.c
@@ -225,8 +225,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv)
 		return -1;
 	}
 
-	if (gencache_get(keystr, &valuestr, &timeout)
-	    && (timeout > time(NULL))) {
+	if (gencache_get(keystr, &valuestr, &timeout)) {
 		print_cache_entry(keystr, valuestr, timeout, NULL);
 		return 0;
 	}
diff --git a/source/winbindd/idmap.c b/source/winbindd/idmap.c
index 504be22..8b16f27 100644
--- a/source/winbindd/idmap.c
+++ b/source/winbindd/idmap.c
@@ -40,6 +40,8 @@ struct idmap_alloc_backend {
 	struct idmap_alloc_backend *prev, *next;
 };
 
+struct idmap_cache_ctx;
+
 struct idmap_alloc_context {
 	const char *params;
 	struct idmap_alloc_methods *methods;
@@ -47,6 +49,7 @@ struct idmap_alloc_context {
 };
 
 static TALLOC_CTX *idmap_ctx = NULL;
+static struct idmap_cache_ctx *idmap_cache;
 
 static struct idmap_backend *backends = NULL;
 static struct idmap_domain **idmap_domains = NULL;
@@ -151,7 +154,6 @@ NTSTATUS smb_register_idmap(int version, const char *name,
 	entry->name = talloc_strdup(idmap_ctx, name);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list