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

index eca5d12364bc86dbc1a673fbd3361c26355409e8..a0a7f632eae5ae13d14598436d73d09daf2e637c 100644 (file)
@@ -505,8 +505,45 @@ nomem:
        return;
 }
 
+static void winbindd_allocate_gid_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_gid)\n"));
+               request_error(state);
+               return;
+       }
+
+       if (r->out.result != WINBIND_STATUS_OK) {
+               DEBUG(5, ("set_idmap(allocate_gid) returned an error:0x%08X\n",
+                       r->out.result));
+               request_error(state);
+               return;
+       }
+
+       if (r->out.rep->gid > UINT32_MAX) {
+               DEBUG(1, ("set_idmap(allocate_gid) returned a 64bit gid %llu\n",
+                       (unsigned long long)r->out.rep->gid));
+               request_error(state);
+               return;
+       }
+
+       state->response.data.gid = r->out.rep->gid;
+       request_ok(state);
+}
+
 void winbindd_allocate_gid(struct winbindd_cli_state *state)
 {
+       struct winbind_set_idmap *r = NULL;
+
        if ( !state->privileged ) {
                DEBUG(2, ("winbindd_allocate_gid: non-privileged access "
                          "denied!\n"));
@@ -514,7 +551,21 @@ void winbindd_allocate_gid(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_GID;
+
+       do_async_ndr(state->mem_ctx, idmap_child(),
+                    NDR_WINBIND_SET_IDMAP, r,
+                    winbindd_allocate_gid_recv, state,
+                    NULL, NULL);
+       return;
+nomem:
+       request_error(state);
+       return;
 }
 
 enum winbindd_result winbindd_dual_allocate_gid(struct winbindd_domain *domain,