The branch, v3-3-test has been updated
       via  448836d44d0468a74b962ba3c0b7d51de236374f (commit)
       via  2396d5d5d2f453f097f8ce77b640ad7e1d7e7c4c (commit)
       via  55b976ba93462c6885e8d89edd13c32fb5529944 (commit)
       via  80932c0266ef73b8d0462c078a053444fff47f32 (commit)
      from  e98e080bad2c8b9f038a8f2dffcfeba1d5f392ce (commit)

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


- Log -----------------------------------------------------------------
commit 448836d44d0468a74b962ba3c0b7d51de236374f
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Thu Jul 3 21:03:58 2008 +0200

    Slightly increase the default idmap cache time

commit 2396d5d5d2f453f097f8ce77b640ad7e1d7e7c4c
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Thu Jul 3 20:39:22 2008 +0200

    IDMAP_READ_CACHE_DATA_FMT_TEMPLATE is unused, remove it

commit 55b976ba93462c6885e8d89edd13c32fb5529944
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Thu Jul 3 04:59:36 2008 +0200

    Simplify idmap_cache_set() a bit
    
    sid_check_is_in_unix_* will only give true if it is of the corresponding 
type,
    so the check if the struct idmap actually represents a user or group is
    unnecessary.

commit 80932c0266ef73b8d0462c078a053444fff47f32
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Thu Jul 3 04:57:30 2008 +0200

    Simplify idmap_cache_build_[s]idkey a bit

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

Summary of changes:
 docs-xml/smbdotconf/winbind/idmapcachetime.xml |    2 +-
 source/param/loadparm.c                        |    2 +-
 source/winbindd/idmap_cache.c                  |   81 +++++++++++-------------
 3 files changed, 38 insertions(+), 47 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/winbind/idmapcachetime.xml 
b/docs-xml/smbdotconf/winbind/idmapcachetime.xml
index 1636cdf..55ead61 100644
--- a/docs-xml/smbdotconf/winbind/idmapcachetime.xml
+++ b/docs-xml/smbdotconf/winbind/idmapcachetime.xml
@@ -9,5 +9,5 @@
        </para>
 </description>
 
-<value type="default">900</value>
+<value type="default">604800 (i.e. 1 week)</value>
 </samba:parameter>
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index b2cbbf1..c529948 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 = 900; /* 15 minutes by default */
+       Globals.iIdmapCacheTime = 7 * 24 * 3600; /* 1 week by default */
        Globals.iIdmapNegativeCacheTime = 120; /* 2 minutes by default */
 
        Globals.bPassdbExpandExplicit = False;
diff --git a/source/winbindd/idmap_cache.c b/source/winbindd/idmap_cache.c
index b724ba0..8bf797f 100644
--- a/source/winbindd/idmap_cache.c
+++ b/source/winbindd/idmap_cache.c
@@ -25,7 +25,6 @@
 
 #define TIMEOUT_LEN 12
 #define IDMAP_CACHE_DATA_FMT   "%12u/%s"
-#define IDMAP_READ_CACHE_DATA_FMT_TEMPLATE "%%12u/%%%us"
 
 struct idmap_cache_ctx {
        TDB_CONTEXT *tdb;
@@ -70,33 +69,19 @@ struct idmap_cache_ctx *idmap_cache_init(TALLOC_CTX *memctx)
        return cache;
 }
 
-static NTSTATUS idmap_cache_build_sidkey(TALLOC_CTX *ctx, char **sidkey,
-                                        const struct id_map *id)
+static char *idmap_cache_sidkey(TALLOC_CTX *ctx, const DOM_SID *sid)
 {
        fstring sidstr;
 
-       *sidkey = talloc_asprintf(ctx, "IDMAP/SID/%s",
-                                 sid_to_fstring(sidstr, id->sid));
-       if ( ! *sidkey) {
-               DEBUG(1, ("failed to build sidkey, OOM?\n"));
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       return NT_STATUS_OK;
+       return talloc_asprintf(ctx, "IDMAP/SID/%s",
+                              sid_to_fstring(sidstr, sid));
 }
 
-static NTSTATUS idmap_cache_build_idkey(TALLOC_CTX *ctx, char **idkey,
-                                       const struct id_map *id)
+static char *idmap_cache_idkey(TALLOC_CTX *ctx, const struct id_map *id)
 {
-       *idkey = talloc_asprintf(ctx, "IDMAP/%s/%lu",
-                               (id->xid.type==ID_TYPE_UID)?"UID":"GID",
-                               (unsigned long)id->xid.id);
-       if ( ! *idkey) {
-               DEBUG(1, ("failed to build idkey, OOM?\n"));
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       return NT_STATUS_OK;
+       return talloc_asprintf(ctx, "IDMAP/%s/%lu",
+                              (id->xid.type==ID_TYPE_UID)?"UID":"GID",
+                              (unsigned long)id->xid.id);
 }
 
 NTSTATUS idmap_cache_set(struct idmap_cache_ctx *cache, const struct id_map 
*id)
@@ -109,23 +94,21 @@ NTSTATUS idmap_cache_set(struct idmap_cache_ctx *cache, 
const struct id_map *id)
        char *valstr;
 
        /* Don't cache lookups in the S-1-22-{1,2} domain */
-       if ( (id->xid.type == ID_TYPE_UID) && 
-            sid_check_is_in_unix_users(id->sid) )
-       {
-               return NT_STATUS_OK;
-       }
-       if ( (id->xid.type == ID_TYPE_GID) && 
-            sid_check_is_in_unix_groups(id->sid) )
-       {
+
+       if (sid_check_is_in_unix_users(id->sid)
+           || sid_check_is_in_unix_groups(id->sid)) {
                return NT_STATUS_OK;
        }
 
-       ret = idmap_cache_build_sidkey(cache, &sidkey, id);
-       if (!NT_STATUS_IS_OK(ret)) return ret;
+       sidkey = idmap_cache_sidkey(cache, id->sid);
+       if (sidkey == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* use sidkey as the local memory ctx */
-       ret = idmap_cache_build_idkey(sidkey, &idkey, id);
-       if (!NT_STATUS_IS_OK(ret)) {
+       idkey = idmap_cache_idkey(sidkey, id);
+       if (idkey == NULL) {
+               ret = NT_STATUS_NO_MEMORY;
                goto done;
        }
 
@@ -182,14 +165,16 @@ done:
 
 NTSTATUS idmap_cache_set_negative_sid(struct idmap_cache_ctx *cache, const 
struct id_map *id)
 {
-       NTSTATUS ret;
+       NTSTATUS ret = NT_STATUS_OK;
        time_t timeout = time(NULL) + lp_idmap_negative_cache_time();
        TDB_DATA databuf;
        char *sidkey;
        char *valstr;
 
-       ret = idmap_cache_build_sidkey(cache, &sidkey, id);
-       if (!NT_STATUS_IS_OK(ret)) return ret;
+       sidkey = idmap_cache_sidkey(cache, id->sid);
+       if (sidkey == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* use sidkey as the local memory ctx */
        valstr = talloc_asprintf(sidkey, IDMAP_CACHE_DATA_FMT, (int)timeout, 
"IDMAP/NEGATIVE");
@@ -218,14 +203,16 @@ done:
 
 NTSTATUS idmap_cache_set_negative_id(struct idmap_cache_ctx *cache, const 
struct id_map *id)
 {
-       NTSTATUS ret;
+       NTSTATUS ret = NT_STATUS_OK;
        time_t timeout = time(NULL) + lp_idmap_negative_cache_time();
        TDB_DATA databuf;
        char *idkey;
        char *valstr;
 
-       ret = idmap_cache_build_idkey(cache, &idkey, id);
-       if (!NT_STATUS_IS_OK(ret)) return ret;
+       idkey = idmap_cache_idkey(cache, id);
+       if (idkey == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* use idkey as the local memory ctx */
        valstr = talloc_asprintf(idkey, IDMAP_CACHE_DATA_FMT, (int)timeout, 
"IDMAP/NEGATIVE");
@@ -317,7 +304,7 @@ failed:
 
 NTSTATUS idmap_cache_map_sid(struct idmap_cache_ctx *cache, struct id_map *id)
 {
-       NTSTATUS ret;
+       NTSTATUS ret = NT_STATUS_OK;
        TDB_DATA databuf;
        time_t t;
        char *sidkey;
@@ -328,8 +315,10 @@ NTSTATUS idmap_cache_map_sid(struct idmap_cache_ctx 
*cache, struct id_map *id)
        /* make sure it is marked as not mapped by default */
        id->status = ID_UNKNOWN;
 
-       ret = idmap_cache_build_sidkey(cache, &sidkey, id);
-       if (!NT_STATUS_IS_OK(ret)) return ret;
+       sidkey = idmap_cache_sidkey(cache, id->sid);
+       if (sidkey == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        databuf = tdb_fetch_bystring(cache->tdb, sidkey);
 
@@ -438,8 +427,10 @@ NTSTATUS idmap_cache_map_id(struct idmap_cache_ctx *cache, 
struct id_map *id)
        /* make sure it is marked as unknown by default */
        id->status = ID_UNKNOWN;
 
-       ret = idmap_cache_build_idkey(cache, &idkey, id);
-       if (!NT_STATUS_IS_OK(ret)) return ret;
+       idkey = idmap_cache_idkey(cache, id);
+       if (idkey == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
        databuf = tdb_fetch_bystring(cache->tdb, idkey);
 


-- 
Samba Shared Repository

Reply via email to