s3:idmap: don't check range for passdb idmap domain
authorMichael Adam <obnox@samba.org>
Tue, 22 Jun 2010 14:29:13 +0000 (16:29 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 23 Jun 2010 09:10:36 +0000 (11:10 +0200)
source3/winbindd/idmap.c

index 714a997510533224345b2466b1c9cc32c335dd4b..4bb54a328e9ad37d1bbd5519676459ce6626194c 100644 (file)
@@ -192,12 +192,14 @@ static bool parse_idmap_module(TALLOC_CTX *mem_ctx, const char *param,
  * @param[in] domainname       which domain is this for
  * @param[in] modulename       which backend module
  * @param[in] params           parameter to pass to the init function
+ * @param[in] check_range      whether range checking should be done
  * @result The initialized structure
  */
 static struct idmap_domain *idmap_init_domain(TALLOC_CTX *mem_ctx,
                                              const char *domainname,
                                              const char *modulename,
-                                             const char *params)
+                                             const char *params,
+                                             bool check_range)
 {
        struct idmap_domain *result;
        NTSTATUS status;
@@ -231,16 +233,20 @@ static struct idmap_domain *idmap_init_domain(TALLOC_CTX *mem_ctx,
                result->high_id = 0;
 
                if (!lp_idmap_uid(&low_uid, &high_uid)) {
-                       DEBUG(1, ("Error: 'idmap uid' not set!\n"));
-                       goto fail;
+                       DEBUG(1, ("'idmap uid' not set!\n"));
+                       if (check_range) {
+                               goto fail;
+                       }
                }
 
                result->low_id = low_uid;
                result->high_id = high_uid;
 
                if (!lp_idmap_gid(&low_gid, &high_gid)) {
-                       DEBUG(1, ("Error: 'idmap gid' not set!\n"));
-                       goto fail;
+                       DEBUG(1, ("'idmap gid' not set!\n"));
+                       if (check_range) {
+                               goto fail;
+                       }
                }
 
                if ((low_gid != low_uid) || (high_gid != high_uid)) {
@@ -265,17 +271,19 @@ static struct idmap_domain *idmap_init_domain(TALLOC_CTX *mem_ctx,
 
                range = lp_parm_const_string(-1, config_option, "range", NULL);
                if (range == NULL) {
-                       DEBUG(1, ("Error: idmap range not specified for "
-                                 "domain %s\n", result ->name));
-                       goto fail;
-               }
-
-               if (sscanf(range, "%u - %u", &result->low_id, &result->high_id)
-                   != 2)
+                       DEBUG(1, ("idmap range not specified for domain %s\n",
+                                 result ->name));
+                       if (check_range) {
+                               goto fail;
+                       }
+               } else if (sscanf(range, "%u - %u", &result->low_id,
+                                 &result->high_id) != 2)
                {
-                       DEBUG(1, ("Error: invalid range '%s' specified for "
-                                 "domain %s\n", range, result->name));
-                       goto fail;
+                       DEBUG(1, ("invalid range '%s' specified for domain "
+                                 "'%s'\n", range, result->name));
+                       if (check_range) {
+                               goto fail;
+                       }
                }
 
                result->read_only = lp_parm_bool(-1, config_option, "read only",
@@ -285,11 +293,12 @@ static struct idmap_domain *idmap_init_domain(TALLOC_CTX *mem_ctx,
        }
 
        if (result->low_id > result->high_id) {
-               DEBUG(1, ("Error: invalid idmap range detected: "
-                         "%lu - %lu\n",
+               DEBUG(1, ("Error: invalid idmap range detected: %lu - %lu\n",
                          (unsigned long)result->low_id,
                          (unsigned long)result->high_id));
-               goto fail;
+               if (check_range) {
+                       goto fail;
+               }
        }
 
        result->methods = get_methods(modulename);
@@ -353,7 +362,7 @@ static struct idmap_domain *idmap_init_default_domain(TALLOC_CTX *mem_ctx)
 
        DEBUG(3, ("idmap_init: using '%s' as remote backend\n", modulename));
 
-       result = idmap_init_domain(mem_ctx, "*", modulename, params);
+       result = idmap_init_domain(mem_ctx, "*", modulename, params, true);
        if (result == NULL) {
                goto fail;
        }
@@ -399,7 +408,7 @@ static struct idmap_domain *idmap_init_named_domain(TALLOC_CTX *mem_ctx,
                goto fail;
        }
 
-       result = idmap_init_domain(mem_ctx, domname, backend, NULL);
+       result = idmap_init_domain(mem_ctx, domname, backend, NULL, true);
        if (result == NULL) {
                goto fail;
        }
@@ -428,7 +437,7 @@ static struct idmap_domain *idmap_init_passdb_domain(TALLOC_CTX *mem_ctx)
        }
 
        passdb_idmap_domain = idmap_init_domain(NULL, get_global_sam_name(),
-                                               "passdb", NULL);
+                                               "passdb", NULL, false);
        if (passdb_idmap_domain == NULL) {
                DEBUG(1, ("Could not init passdb idmap domain\n"));
        }