------------------------------------------------------------
revno: 639
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: Andrew Tridgell <[EMAIL PROTECTED]>
branch nick: s3-ctdb-tridge
timestamp: Sat 2007-10-06 14:15:19 +1000
message:
  added a way to disable idmap_cache.c. It breaks clustering and I need a way 
to test without it
modified:
  source/nsswitch/idmap_cache.c  
idmap_cache.c-20070210173807-1wjifrbwaz6xnmgl-707
=== modified file 'source/nsswitch/idmap_cache.c'
--- a/source/nsswitch/idmap_cache.c     2007-04-18 23:22:20 +0000
+++ b/source/nsswitch/idmap_cache.c     2007-10-06 04:15:19 +0000
@@ -30,6 +30,7 @@
 
 struct idmap_cache_ctx {
        TDB_CONTEXT *tdb;
+       BOOL enabled;
 };
 
 static int idmap_cache_destructor(struct idmap_cache_ctx *cache)
@@ -55,6 +56,11 @@
                return NULL;
        }
 
+       cache->enabled = lp_parm_bool(-1, "idmap", "cache", True);
+       if (!cache->enabled) {
+               return cache;
+       }
+
        cache_fname = lock_path("idmap_cache.tdb");
 
        DEBUG(10, ("Opening cache file at %s\n", cache_fname));
@@ -76,7 +82,7 @@
        talloc_free(cache);
 }
 
-NTSTATUS idmap_cache_build_sidkey(TALLOC_CTX *ctx, char **sidkey, const struct 
id_map *id)
+static NTSTATUS idmap_cache_build_sidkey(TALLOC_CTX *ctx, char **sidkey, const 
struct id_map *id)
 {
        *sidkey = talloc_asprintf(ctx, "IDMAP/SID/%s", 
sid_string_static(id->sid));
        if ( ! *sidkey) {
@@ -87,7 +93,7 @@
        return NT_STATUS_OK;
 }
 
-NTSTATUS idmap_cache_build_idkey(TALLOC_CTX *ctx, char **idkey, const struct 
id_map *id)
+static NTSTATUS idmap_cache_build_idkey(TALLOC_CTX *ctx, char **idkey, const 
struct id_map *id)
 {
        *idkey = talloc_asprintf(ctx, "IDMAP/%s/%lu",
                                (id->xid.type==ID_TYPE_UID)?"UID":"GID",
@@ -109,6 +115,10 @@
        char *idkey;
        char *valstr;
 
+       if (!cache->enabled) {
+               return NT_STATUS_OK;
+       }
+
        /* 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) )
@@ -188,6 +198,10 @@
        char *sidkey = NULL;
        char *idkey = NULL;
 
+       if (!cache->enabled) {
+               return NT_STATUS_OK;
+       }
+
        ret = idmap_cache_build_sidkey(cache, &sidkey, id);
        if (!NT_STATUS_IS_OK(ret)) return ret;
 
@@ -226,6 +240,10 @@
        char *sidkey;
        char *valstr;
 
+       if (!cache->enabled) {
+               return NT_STATUS_OK;
+       }
+
        ret = idmap_cache_build_sidkey(cache, &sidkey, id);
        if (!NT_STATUS_IS_OK(ret)) return ret;
 
@@ -262,6 +280,10 @@
        char *idkey;
        char *valstr;
 
+       if (!cache->enabled) {
+               return NT_STATUS_OK;
+       }
+
        ret = idmap_cache_build_idkey(cache, &idkey, id);
        if (!NT_STATUS_IS_OK(ret)) return ret;
 
@@ -290,7 +312,7 @@
        return ret;
 }
 
-NTSTATUS idmap_cache_fill_map(struct id_map *id, const char *value)
+static NTSTATUS idmap_cache_fill_map(struct id_map *id, const char *value)
 {
        char *rem;
 
@@ -371,6 +393,10 @@
 
        /* make sure it is marked as not mapped by default */
        id->status = ID_UNKNOWN;
+
+       if (!cache->enabled) {
+               return NT_STATUS_NONE_MAPPED;
+       }
        
        ret = idmap_cache_build_sidkey(cache, &sidkey, id);
        if (!NT_STATUS_IS_OK(ret)) return ret;
@@ -466,6 +492,10 @@
        /* make sure it is marked as unknown by default */
        id->status = ID_UNKNOWN;
        
+       if (!cache->enabled) {
+               return NT_STATUS_NONE_MAPPED;
+       }
+
        ret = idmap_cache_build_idkey(cache, &idkey, id);
        if (!NT_STATUS_IS_OK(ret)) return ret;
 

Reply via email to