s3:idmap_tdb2: move the idmap script from idmap_tdb2_state to idmap_tdb2_context
authorMichael Adam <obnox@samba.org>
Wed, 16 Jun 2010 13:47:23 +0000 (15:47 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 23 Jun 2010 09:23:54 +0000 (11:23 +0200)
The state (aka idmap_tdb2_alloc_context) is being removed.
The (global) idmap script was wrong there anyways.
It belongs to the per-domain context.

source3/winbindd/idmap_tdb2.c

index 0421d9fcc2620bfe302b267ca60723bd9d740f34..ae7b3403e919bb5b892df11a35de77a6ed7ad5d1 100644 (file)
@@ -40,6 +40,7 @@ struct idmap_tdb2_context {
        uint32_t filter_low_id;
        uint32_t filter_high_id;
        bool read_only;
+       const char *script; /* script to provide idmaps */
 };
 
 /* High water mark keys */
@@ -50,7 +51,6 @@ static struct idmap_tdb2_state {
        /* User and group id pool */
        uid_t low_uid, high_uid;               /* Range of uids to allocate */
        gid_t low_gid, high_gid;               /* Range of gids to allocate */
-       const char *idmap_script;
 } idmap_tdb2_state;
 
 
@@ -142,15 +142,6 @@ static NTSTATUS idmap_tdb2_alloc_load(void)
        NTSTATUS status;
        uint32 low_id;
 
-       /* see if a idmap script is configured */
-       idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap",
-                                                            "script", NULL);
-
-       if (idmap_tdb2_state.idmap_script) {
-               DEBUG(1, ("using idmap script '%s'\n",
-                         idmap_tdb2_state.idmap_script));
-       }
-
        /* load ranges */
 
        status = idmap_tdb2_load_ranges();
@@ -372,6 +363,11 @@ static NTSTATUS idmap_tdb2_db_init(struct idmap_domain *dom,
                }
 
                ctx->read_only = lp_idmap_read_only();
+
+               ctx->script = lp_parm_const_string(-1, "idmap", "script", NULL);
+               if (ctx->script) {
+                       DEBUG(1, ("using idmap script '%s'\n", ctx->script));
+               }
        } else {
                char *config_option = NULL;
                const char *range;
@@ -489,7 +485,7 @@ static NTSTATUS idmap_tdb2_script(struct idmap_tdb2_context *ctx, struct id_map
        char line[64];
        unsigned long v;
 
-       cmd = talloc_asprintf(ctx, "%s ", idmap_tdb2_state.idmap_script);
+       cmd = talloc_asprintf(ctx, "%s ", ctx->script);
        NT_STATUS_HAVE_NO_MEMORY(cmd);  
 
        va_start(ap, fmt);
@@ -520,12 +516,12 @@ static NTSTATUS idmap_tdb2_script(struct idmap_tdb2_context *ctx, struct id_map
        } else if (strncmp(line, "SID:S-", 6) == 0) {
                if (!string_to_sid(map->sid, &line[4])) {
                        DEBUG(0,("Bad SID in '%s' from idmap script %s\n",
-                                line, idmap_tdb2_state.idmap_script));
+                                line, ctx->script));
                        return NT_STATUS_NONE_MAPPED;                   
                }
        } else {
                DEBUG(0,("Bad reply '%s' from idmap script %s\n",
-                        line, idmap_tdb2_state.idmap_script));
+                        line, ctx->script));
                return NT_STATUS_NONE_MAPPED;
        }
 
@@ -593,7 +589,7 @@ static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_tdb2_context *ctx, struct id_m
                struct idmap_tdb2_set_mapping_context store_state;
 
                DEBUG(10,("Record %s not found\n", keystr));
-               if (idmap_tdb2_state.idmap_script == NULL) {
+               if (ctx->script == NULL) {
                        ret = NT_STATUS_NONE_MAPPED;
                        goto done;
                }
@@ -666,7 +662,7 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m
 
                DEBUG(10,(__location__ " Record %s not found\n", keystr));
 
-               if (idmap_tdb2_state.idmap_script == NULL) {
+               if (ctx->script == NULL) {
                        ret = NT_STATUS_NONE_MAPPED;
                        goto done;
                }