s3:idmap: remove unused method dump_data() from the idmap API
[amitay/samba.git] / source3 / winbindd / idmap_tdb2.c
index ec83cae8a3cdeb103bbafabb87e4c290ee70622c..bd30a253938ac8a1840ea1ae6e5d512f7dee54f5 100644 (file)
@@ -289,7 +289,7 @@ static NTSTATUS idmap_tdb2_allocate_id(struct unixid *xid)
 
        if (NT_STATUS_IS_OK(status)) {
                xid->id = state.hwm;
-               DEBUG(10,("New %s = %d\n", hwmtype, hwm));
+               DEBUG(10,("New %s = %d\n", hwmtype, state.hwm));
        } else {
                DEBUG(1, ("Error allocating a new %s\n", hwmtype));
        }
@@ -718,6 +718,19 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m
                        goto done;
                }
 
+               /* apply filters before returning result */
+               if ((ctx->filter_low_id
+                    && (map->xid.id < ctx->filter_low_id)) ||
+                   (ctx->filter_high_id
+                    && (map->xid.id > ctx->filter_high_id))) {
+                       DEBUG(5, ("Script returned id (%u) out of range "
+                                 "(%u - %u). Filtered!\n",
+                                 map->xid.id,
+                                 ctx->filter_low_id, ctx->filter_high_id));
+                       ret = NT_STATUS_NONE_MAPPED;
+                       goto done;
+               }
+
                idstr = talloc_asprintf(tmp_ctx, "%cID %lu",
                                        map->xid.type == ID_TYPE_UID?'U':'G',
                                        (unsigned long)map->xid.id);
@@ -750,6 +763,7 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m
        } else { /* Unknown record type ! */
                DEBUG(2, ("Found INVALID record %s -> %s\n", keystr, (const char *)data.dptr));
                ret = NT_STATUS_INTERNAL_DB_ERROR;
+               goto done;
        }
 
        /* apply filters before returning result */
@@ -892,7 +906,8 @@ static NTSTATUS idmap_tdb2_set_mapping(struct idmap_domain *dom, const struct id
                goto done;
        }
 
-       if (!(ksidstr = sid_string_talloc(ctx, map->sid))) {
+       ksidstr = sid_string_talloc(ctx, map->sid);
+       if (ksidstr == NULL) {
                DEBUG(0, ("Out of memory!\n"));
                ret = NT_STATUS_NO_MEMORY;
                goto done;
@@ -910,17 +925,6 @@ done:
        return ret;
 }
 
-/*
-  remove a mapping. 
-*/
-static NTSTATUS idmap_tdb2_remove_mapping(struct idmap_domain *dom, const struct id_map *map)
-{
-       /* not supported as it would invalidate the cache tdb on other
-          nodes */
-       DEBUG(0,("idmap_tdb2_remove_mapping not supported\n"));
-       return NT_STATUS_NOT_SUPPORTED;
-}
-
 /*
   Close the idmap tdb instance
 */
@@ -930,23 +934,11 @@ static NTSTATUS idmap_tdb2_close(struct idmap_domain *dom)
        return NT_STATUS_OK;
 }
 
-
-/*
-  Dump all mappings out
-*/
-static NTSTATUS idmap_tdb2_dump_data(struct idmap_domain *dom, struct id_map **maps, int *num_maps)
-{
-       DEBUG(0,("idmap_tdb2_dump_data not supported\n"));
-       return NT_STATUS_NOT_SUPPORTED;
-}
-
 static struct idmap_methods db_methods = {
        .init            = idmap_tdb2_db_init,
        .unixids_to_sids = idmap_tdb2_unixids_to_sids,
        .sids_to_unixids = idmap_tdb2_sids_to_unixids,
        .set_mapping     = idmap_tdb2_set_mapping,
-       .remove_mapping  = idmap_tdb2_remove_mapping,
-       .dump_data       = idmap_tdb2_dump_data,
        .close_fn        = idmap_tdb2_close
 };