s3:winbind:idmap_tdb2_sids_to_unixids: only allocate an id for sid == NULL
authorMichael Adam <obnox@samba.org>
Sun, 30 May 2010 22:24:18 +0000 (00:24 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 31 May 2010 15:34:02 +0000 (17:34 +0200)
This special treatment allows to eliminate the alloc methods from the
surface while still keeping the WINBINDD_ALLOCATE_[U|G]ID methods.

source3/winbindd/idmap_tdb2.c

index 01cb020451e1c58734dcba0c9aa27cad25629a24..1ffce071eb56a474e17724c7c6a0cbb5f8fe91db 100644 (file)
@@ -847,9 +847,25 @@ static NTSTATUS idmap_tdb2_sids_to_unixids_action(struct db_context *db,
                if ((state->ids[i]->status == ID_UNMAPPED) &&
                    state->allocate_unmapped)
                {
-                       ret = idmap_tdb2_new_mapping(state->dom, state->ids[i]);
-                       if (!NT_STATUS_IS_OK(ret)) {
-                               goto done;
+                       if (state->ids[i]->sid != NULL) {
+                               ret = idmap_tdb2_new_mapping(state->dom,
+                                                            state->ids[i]);
+                               if (!NT_STATUS_IS_OK(ret)) {
+                                       goto done;
+                               }
+                       } else {
+                               /*
+                                *  Special treatment to only allocate an ID.
+                                *  (No mapping is stored.)
+                                */
+                               ret = idmap_tdb2_get_new_id(state->dom,
+                                                       &state->ids[i]->xid);
+                               if (!NT_STATUS_IS_OK(ret)) {
+                                       DEBUG(3, ("Could not allocate id: "
+                                                 "%s\n", nt_errstr(ret)));
+                                       goto done;
+                               }
+                               state->ids[i]->status = ID_MAPPED;
                        }
                }
        }