let winbindd_allocate_uid() use WINBIND_SET_IDMAP_LEVEL_ALLOCATE_UID...
authorStefan Metzmacher <metze@sernet.de>
Wed, 12 Dec 2007 16:09:06 +0000 (17:09 +0100)
committerStefan Metzmacher <metze@sernet.de>
Fri, 2 May 2008 14:12:44 +0000 (16:12 +0200)
source/winbindd/winbindd_sid.c

index f68399538b3c288abfcce051c6cfaa160834355e..59e9af843d7dbfb5c0d8b8e00762a091c1fd9095 100644 (file)
@@ -442,8 +442,45 @@ void winbindd_gid_to_sid(struct winbindd_cli_state *state)
        winbindd_gid2sid_async(state->mem_ctx, state->request.data.gid, gid2sid_recv, state);
 }
 
+static void winbindd_allocate_uid_recv(TALLOC_CTX *mem_ctx, bool success,
+                                      struct winbindd_ndr_call *c,
+                                      void *private_data,
+                                      void *_cont,
+                                      void *_cont_private)
+{
+       struct winbindd_cli_state *state =
+               talloc_get_type_abort(private_data, struct winbindd_cli_state);
+       struct winbind_set_idmap *r =
+               talloc_get_type_abort(c->ndr.r, struct winbind_set_idmap);
+
+       if (!success) {
+               DEBUG(5, ("Could not set_idmap(allocate_uid)\n"));
+               request_error(state);
+               return;
+       }
+
+       if (r->out.result != WINBIND_STATUS_OK) {
+               DEBUG(5, ("set_idmap(allocate_uid) returned an error:0x%08X\n",
+                       r->out.result));
+               request_error(state);
+               return;
+       }
+
+       if (r->out.rep->uid > UINT32_MAX) {
+               DEBUG(1, ("set_idmap(allocate_uid) returned a 64bit uid %llu\n",
+                       (unsigned long long)r->out.rep->uid));
+               request_error(state);
+               return;
+       }
+
+       state->response.data.uid = r->out.rep->uid;
+       request_ok(state);
+}
+
 void winbindd_allocate_uid(struct winbindd_cli_state *state)
 {
+       struct winbind_set_idmap *r = NULL;
+
        if ( !state->privileged ) {
                DEBUG(2, ("winbindd_allocate_uid: non-privileged access "
                          "denied!\n"));
@@ -451,7 +488,21 @@ void winbindd_allocate_uid(struct winbindd_cli_state *state)
                return;
        }
 
-       sendto_child(state, idmap_child());
+       r = TALLOC_P(state->mem_ctx, struct winbind_set_idmap);
+       if (!r) goto nomem;
+       r->in.level = TALLOC_P(r, enum winbind_set_idmap_level);
+       if (!r->in.level) goto nomem;
+
+       *r->in.level = WINBIND_SET_IDMAP_LEVEL_ALLOCATE_UID;
+
+       do_async_ndr(state->mem_ctx, idmap_child(),
+                    NDR_WINBIND_SET_IDMAP, r,
+                    winbindd_allocate_uid_recv, state,
+                    NULL, NULL);
+       return;
+nomem:
+       request_error(state);
+       return;
 }
 
 enum winbindd_result winbindd_dual_allocate_uid(struct winbindd_domain *domain,