s3:idmap_tdb2: deprecate the idmap:script parameter and use "idmap config * : script...
authorMichael Adam <obnox@samba.org>
Tue, 7 Jun 2011 16:00:36 +0000 (18:00 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 27 Jul 2011 02:29:05 +0000 (04:29 +0200)
With this patch, "idmap config * : script" will override "idmap : script".
If "idmap : script" is present, a deprecation warning will be printed in any
case. If "idmap config * : script" is not set, then the value of "idmap :script"
will be used for backwards compatibility.

source3/winbindd/idmap_tdb2.c

index 2a152444595121f5504798a288c10584c5f6fe9b..5612d57da777bace27ac453c89340fcf5ffc7713 100644 (file)
@@ -279,6 +279,8 @@ static NTSTATUS idmap_tdb2_db_init(struct idmap_domain *dom)
 {
        NTSTATUS ret;
        struct idmap_tdb2_context *ctx;
+       char *config_option = NULL;
+       const char * idmap_script = NULL;
 
        ctx = talloc_zero(dom, struct idmap_tdb2_context);
        if ( ! ctx) {
@@ -286,27 +288,28 @@ static NTSTATUS idmap_tdb2_db_init(struct idmap_domain *dom)
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (strequal(dom->name, "*")) {
-               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;
+       config_option = talloc_asprintf(ctx, "idmap config %s", dom->name);
+       if (config_option == NULL) {
+               DEBUG(0, ("Out of memory!\n"));
+               ret = NT_STATUS_NO_MEMORY;
+               goto failed;
+       }
+       ctx->script = lp_parm_const_string(-1, config_option, "script", "NULL");
+       talloc_free(config_option);
 
-               config_option = talloc_asprintf(ctx, "idmap config %s", dom->name);
-               if ( ! config_option) {
-                       DEBUG(0, ("Out of memory!\n"));
-                       ret = NT_STATUS_NO_MEMORY;
-                       goto failed;
-               }
+       idmap_script = lp_parm_const_string(-1, "idmap", "script", NULL);
+       if (idmap_script != NULL) {
+               DEBUG(0, ("Warning: 'idmap:script' is deprecated. "
+                         " Please use 'idmap config * : script' instead!\n"));
+       }
 
-               ctx->script = lp_parm_const_string(-1, config_option, "script", NULL);
-               if (ctx->script) {
-                       DEBUG(1, ("using idmap script '%s'\n", ctx->script));
-               }
+       if (strequal(dom->name, "*") && ctx->script == NULL) {
+               /* fall back to idmap:script for backwards compatibility */
+               ctx->script = idmap_script;
+       }
 
-               talloc_free(config_option);
+       if (ctx->script) {
+               DEBUG(1, ("using idmap script '%s'\n", ctx->script));
        }
 
        ctx->rw_ops = talloc_zero(ctx, struct idmap_rw_ops);