s3:idmap: remove unused idmap_set_uid_hwm()
[amitay/samba.git] / source3 / winbindd / idmap.c
index aaba7e53eed4cef688dc2796107b1fc4dfc03fc2..841adc8ef007e685320c6e8644ad6ebb41b0c3e1 100644 (file)
 
 static_decl_idmap;
 
+static void idmap_init(void)
+{
+       static bool initialized;
+
+       if (initialized) {
+               return;
+       }
+
+       DEBUG(10, ("idmap_init(): calling static_init_idmap\n"));
+
+       static_init_idmap;
+
+       initialized = true;
+}
+
 /**
  * Pointer to the backend methods. Modules register themselves here via
  * smb_register_idmap.
@@ -346,9 +361,7 @@ static struct idmap_domain *idmap_init_default_domain(TALLOC_CTX *mem_ctx)
        char *modulename;
        char *params;
 
-       DEBUG(10, ("idmap_init_default_domain: calling static_init_idmap\n"));
-
-       static_init_idmap;
+       idmap_init();
 
        if (!parse_idmap_module(talloc_tos(), lp_idmap_backend(), &modulename,
                                &params)) {
@@ -428,6 +441,8 @@ fail:
 
 static struct idmap_domain *idmap_init_passdb_domain(TALLOC_CTX *mem_ctx)
 {
+       idmap_init();
+
        if (passdb_idmap_domain != NULL) {
                return passdb_idmap_domain;
        }
@@ -536,6 +551,8 @@ static NTSTATUS idmap_alloc_init(struct idmap_alloc_context **ctx)
        char *modulename, *params;
        NTSTATUS ret = NT_STATUS_NO_MEMORY;;
 
+       idmap_init();
+
        if (idmap_alloc_ctx != NULL) {
                *ctx = idmap_alloc_ctx;
                return NT_STATUS_OK;
@@ -629,19 +646,6 @@ NTSTATUS idmap_allocate_gid(struct unixid *id)
        return ctx->methods->allocate_id(id);
 }
 
-NTSTATUS idmap_set_uid_hwm(struct unixid *id)
-{
-       struct idmap_alloc_context *ctx;
-       NTSTATUS ret;
-
-       if (!NT_STATUS_IS_OK(ret = idmap_alloc_init(&ctx))) {
-               return ret;
-       }
-
-       id->type = ID_TYPE_UID;
-       return ctx->methods->set_id_hwm(id);
-}
-
 NTSTATUS idmap_set_gid_hwm(struct unixid *id)
 {
        struct idmap_alloc_context *ctx;
@@ -741,7 +745,8 @@ NTSTATUS idmap_backends_unixid_to_sid(const char *domname, struct id_map *id)
 
        dom = idmap_init_passdb_domain(NULL);
        if ((dom != NULL)
-           && NT_STATUS_IS_OK(dom->methods->unixids_to_sids(dom, maps))) {
+           && NT_STATUS_IS_OK(dom->methods->unixids_to_sids(dom, maps))
+           && id->status == ID_MAPPED) {
                return NT_STATUS_OK;
        }
 
@@ -758,7 +763,7 @@ NTSTATUS idmap_backends_sid_to_unixid(const char *domain, struct id_map *id)
        struct idmap_domain *dom;
        struct id_map *maps[2];
 
-        DEBUG(10, ("idmap_backend_sid_to_unixid: domain = '%s', sid = [%s]\n",
+        DEBUG(10, ("idmap_backends_sid_to_unixid: domain = '%s', sid = [%s]\n",
                    domain?domain:"NULL", sid_string_dbg(id->sid)));
 
        maps[0] = id;