From: Stefan Metzmacher Date: Wed, 12 Dec 2007 16:09:06 +0000 (+0100) Subject: let winbindd_allocate_uid() use WINBIND_SET_IDMAP_LEVEL_ALLOCATE_UID... X-Git-Url: http://git.samba.org/?a=commitdiff_plain;ds=sidebyside;h=e74fd8d90d9f4a1a7abee115f5e690ecba1a1c17;p=metze%2Fsamba%2Fwb-ndr.git let winbindd_allocate_uid() use WINBIND_SET_IDMAP_LEVEL_ALLOCATE_UID... --- diff --git a/source/winbindd/winbindd_sid.c b/source/winbindd/winbindd_sid.c index f68399538b3..59e9af843d7 100644 --- a/source/winbindd/winbindd_sid.c +++ b/source/winbindd/winbindd_sid.c @@ -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,