s3:param: add a utility function lp_idmap_range() to get the configured range for...
authorMichael Adam <obnox@samba.org>
Mon, 28 Jan 2013 15:31:23 +0000 (16:31 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 5 Feb 2013 16:36:32 +0000 (17:36 +0100)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
source3/include/proto.h
source3/param/loadparm.c

index 6856dd7730063cdec3b124f262108f34b621b614..454ffa57217c7d79721c780066af7e244ddb69f5 100644 (file)
@@ -1083,6 +1083,7 @@ int lp_winbind_max_domain_connections(void);
 const char *lp_idmap_backend(void);
 int lp_idmap_cache_time(void);
 int lp_idmap_negative_cache_time(void);
+bool lp_idmap_range(const char *domain_name, uint32_t *low, uint32_t *high);
 int lp_keepalive(void);
 bool lp_passdb_expand_explicit(void);
 char *lp_ldap_suffix(TALLOC_CTX *ctx);
index 240883942663f35469ef75018db19f77bf458e49..f581c8e1b699fc0163a3203e4f4f4259799da41a 100644 (file)
@@ -2952,6 +2952,46 @@ static bool handle_idmap_gid(struct loadparm_context *unused, int snum, const ch
        return true;
 }
 
+bool lp_idmap_range(const char *domain_name, uint32_t *low, uint32_t *high)
+{
+       char *config_option = NULL;
+       const char *range = NULL;
+       bool ret = false;
+
+       SMB_ASSERT(low != NULL);
+       SMB_ASSERT(high != NULL);
+
+       if ((domain_name == NULL) || (domain_name[0] == '\0')) {
+               domain_name = "*";
+       }
+
+       config_option = talloc_asprintf(talloc_tos(), "idmap config %s",
+                                       domain_name);
+       if (config_option == NULL) {
+               DEBUG(0, ("out of memory\n"));
+               return false;
+       }
+
+       range = lp_parm_const_string(-1, config_option, "range", NULL);
+       if (range == NULL) {
+               DEBUG(1, ("idmap range not specified for domain '%s'\n", domain_name));
+               goto done;
+       }
+
+       if (sscanf(range, "%u - %u", low, high) != 2) {
+               DEBUG(1, ("error parsing idmap range '%s' for domain '%s'\n",
+                         range, domain_name));
+               goto done;
+       }
+
+       ret = true;
+
+done:
+       talloc_free(config_option);
+       return ret;
+
+}
+
 /***************************************************************************
  Handle the DEBUG level list.
 ***************************************************************************/