diff options
author | Volker Lendecke <vl@samba.org> | 2009-09-06 14:47:06 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-09-07 01:28:32 +0200 |
commit | 7159060450e4d5cd3d71e6a5c7837dcd648a6220 (patch) | |
tree | 84b5b2c3514d472cc32555682864bf24327cdf70 /source3/librpc/gen_ndr | |
parent | d9b7fd59b026fbad11263e8a018d654325ede0e4 (diff) | |
download | samba-7159060450e4d5cd3d71e6a5c7837dcd648a6220.tar.gz samba-7159060450e4d5cd3d71e6a5c7837dcd648a6220.tar.bz2 samba-7159060450e4d5cd3d71e6a5c7837dcd648a6220.zip |
s3:winbind: Convert WINBINDD_SET_MAPPING to the new API
Diffstat (limited to 'source3/librpc/gen_ndr')
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.c | 158 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.h | 14 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.c | 99 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.h | 8 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_wbint.c | 80 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_wbint.h | 2 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/wbint.h | 29 |
7 files changed, 388 insertions, 2 deletions
diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c index 1b1152904d..fc4d13f7e7 100644 --- a/source3/librpc/gen_ndr/cli_wbint.c +++ b/source3/librpc/gen_ndr/cli_wbint.c @@ -3075,3 +3075,161 @@ NTSTATUS rpccli_wbint_CheckMachineAccount(struct rpc_pipe_client *cli, return r.out.result; } +struct rpccli_wbint_SetMapping_state { + struct wbint_SetMapping orig; + struct wbint_SetMapping tmp; + TALLOC_CTX *out_mem_ctx; + NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); +}; + +static void rpccli_wbint_SetMapping_done(struct tevent_req *subreq); + +struct tevent_req *rpccli_wbint_SetMapping_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct dom_sid *_sid /* [in] [ref] */, + enum wbint_IdType _type /* [in] */, + uint64_t _id /* [in] */) +{ + struct tevent_req *req; + struct rpccli_wbint_SetMapping_state *state; + struct tevent_req *subreq; + + req = tevent_req_create(mem_ctx, &state, + struct rpccli_wbint_SetMapping_state); + if (req == NULL) { + return NULL; + } + state->out_mem_ctx = NULL; + state->dispatch_recv = cli->dispatch_recv; + + /* In parameters */ + state->orig.in.sid = _sid; + state->orig.in.type = _type; + state->orig.in.id = _id; + + /* Out parameters */ + + /* Result */ + ZERO_STRUCT(state->orig.out.result); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_SetMapping, &state->orig); + } + + /* make a temporary copy, that we pass to the dispatch function */ + state->tmp = state->orig; + + subreq = cli->dispatch_send(state, ev, cli, + &ndr_table_wbint, + NDR_WBINT_SETMAPPING, + &state->tmp); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, rpccli_wbint_SetMapping_done, req); + return req; +} + +static void rpccli_wbint_SetMapping_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct rpccli_wbint_SetMapping_state *state = tevent_req_data( + req, struct rpccli_wbint_SetMapping_state); + NTSTATUS status; + TALLOC_CTX *mem_ctx; + + if (state->out_mem_ctx) { + mem_ctx = state->out_mem_ctx; + } else { + mem_ctx = state; + } + + status = state->dispatch_recv(subreq, mem_ctx); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + + /* Copy out parameters */ + + /* Copy result */ + state->orig.out.result = state->tmp.out.result; + + /* Reset temporary structure */ + ZERO_STRUCT(state->tmp); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_SetMapping, &state->orig); + } + + tevent_req_done(req); +} + +NTSTATUS rpccli_wbint_SetMapping_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result) +{ + struct rpccli_wbint_SetMapping_state *state = tevent_req_data( + req, struct rpccli_wbint_SetMapping_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + tevent_req_received(req); + return status; + } + + /* Steal possbile out parameters to the callers context */ + talloc_steal(mem_ctx, state->out_mem_ctx); + + /* Return result */ + *result = state->orig.out.result; + + tevent_req_received(req); + return NT_STATUS_OK; +} + +NTSTATUS rpccli_wbint_SetMapping(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct dom_sid *sid /* [in] [ref] */, + enum wbint_IdType type /* [in] */, + uint64_t id /* [in] */) +{ + struct wbint_SetMapping r; + NTSTATUS status; + + /* In parameters */ + r.in.sid = sid; + r.in.type = type; + r.in.id = id; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_SetMapping, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_wbint, + NDR_WBINT_SETMAPPING, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_SetMapping, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + return r.out.result; +} + diff --git a/source3/librpc/gen_ndr/cli_wbint.h b/source3/librpc/gen_ndr/cli_wbint.h index 3b61687a88..e9408b44f9 100644 --- a/source3/librpc/gen_ndr/cli_wbint.h +++ b/source3/librpc/gen_ndr/cli_wbint.h @@ -240,4 +240,18 @@ NTSTATUS rpccli_wbint_CheckMachineAccount_recv(struct tevent_req *req, NTSTATUS *result); NTSTATUS rpccli_wbint_CheckMachineAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); +struct tevent_req *rpccli_wbint_SetMapping_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct dom_sid *_sid /* [in] [ref] */, + enum wbint_IdType _type /* [in] */, + uint64_t _id /* [in] */); +NTSTATUS rpccli_wbint_SetMapping_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result); +NTSTATUS rpccli_wbint_SetMapping(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct dom_sid *sid /* [in] [ref] */, + enum wbint_IdType type /* [in] */, + uint64_t id /* [in] */); #endif /* __CLI_WBINT__ */ diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c index 2d5e5c46ca..cac05cc72c 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.c +++ b/source3/librpc/gen_ndr/ndr_wbint.c @@ -492,6 +492,32 @@ _PUBLIC_ void ndr_print_wbint_userinfos(struct ndr_print *ndr, const char *name, ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_wbint_IdType(struct ndr_push *ndr, int ndr_flags, enum wbint_IdType r) +{ + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_wbint_IdType(struct ndr_pull *ndr, int ndr_flags, enum wbint_IdType *r) +{ + uint16_t v; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_wbint_IdType(struct ndr_print *ndr, const char *name, enum wbint_IdType r) +{ + const char *val = NULL; + + switch (r) { + case WBINT_ID_TYPE_NOT_SPECIFIED: val = "WBINT_ID_TYPE_NOT_SPECIFIED"; break; + case WBINT_ID_TYPE_UID: val = "WBINT_ID_TYPE_UID"; break; + case WBINT_ID_TYPE_GID: val = "WBINT_ID_TYPE_GID"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + static enum ndr_err_code ndr_push_wbint_Ping(struct ndr_push *ndr, int flags, const struct wbint_Ping *r) { if (flags & NDR_IN) { @@ -2152,6 +2178,69 @@ _PUBLIC_ void ndr_print_wbint_CheckMachineAccount(struct ndr_print *ndr, const c ndr->depth--; } +static enum ndr_err_code ndr_push_wbint_SetMapping(struct ndr_push *ndr, int flags, const struct wbint_SetMapping *r) +{ + if (flags & NDR_IN) { + if (r->in.sid == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->in.sid)); + NDR_CHECK(ndr_push_wbint_IdType(ndr, NDR_SCALARS, r->in.type)); + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->in.id)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_wbint_SetMapping(struct ndr_pull *ndr, int flags, struct wbint_SetMapping *r) +{ + TALLOC_CTX *_mem_save_sid_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.sid); + } + _mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.sid, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->in.sid)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_wbint_IdType(ndr, NDR_SCALARS, &r->in.type)); + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->in.id)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_wbint_SetMapping(struct ndr_print *ndr, const char *name, int flags, const struct wbint_SetMapping *r) +{ + ndr_print_struct(ndr, name, "wbint_SetMapping"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "wbint_SetMapping"); + ndr->depth++; + ndr_print_ptr(ndr, "sid", r->in.sid); + ndr->depth++; + ndr_print_dom_sid(ndr, "sid", r->in.sid); + ndr->depth--; + ndr_print_wbint_IdType(ndr, "type", r->in.type); + ndr_print_hyper(ndr, "id", r->in.id); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "wbint_SetMapping"); + ndr->depth++; + ndr_print_NTSTATUS(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + static const struct ndr_interface_call wbint_calls[] = { { "wbint_Ping", @@ -2305,6 +2394,14 @@ static const struct ndr_interface_call wbint_calls[] = { (ndr_print_function_t) ndr_print_wbint_CheckMachineAccount, false, }, + { + "wbint_SetMapping", + sizeof(struct wbint_SetMapping), + (ndr_push_flags_fn_t) ndr_push_wbint_SetMapping, + (ndr_pull_flags_fn_t) ndr_pull_wbint_SetMapping, + (ndr_print_function_t) ndr_print_wbint_SetMapping, + false, + }, { NULL, 0, NULL, NULL, NULL, false } }; @@ -2334,7 +2431,7 @@ const struct ndr_interface_table ndr_table_wbint = { NDR_WBINT_VERSION }, .helpstring = NDR_WBINT_HELPSTRING, - .num_calls = 19, + .num_calls = 20, .calls = wbint_calls, .endpoints = &wbint_endpoints, .authservices = &wbint_authservices diff --git a/source3/librpc/gen_ndr/ndr_wbint.h b/source3/librpc/gen_ndr/ndr_wbint.h index d7cfbf0020..bff66acbe4 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.h +++ b/source3/librpc/gen_ndr/ndr_wbint.h @@ -49,7 +49,9 @@ extern const struct ndr_interface_table ndr_table_wbint; #define NDR_WBINT_CHECKMACHINEACCOUNT (0x12) -#define NDR_WBINT_CALL_COUNT (19) +#define NDR_WBINT_SETMAPPING (0x13) + +#define NDR_WBINT_CALL_COUNT (20) enum ndr_err_code ndr_push_wbint_userinfo(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfo *r); enum ndr_err_code ndr_pull_wbint_userinfo(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfo *r); void ndr_print_wbint_userinfo(struct ndr_print *ndr, const char *name, const struct wbint_userinfo *r); @@ -68,6 +70,9 @@ void ndr_print_wbint_Principals(struct ndr_print *ndr, const char *name, const s enum ndr_err_code ndr_push_wbint_userinfos(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfos *r); enum ndr_err_code ndr_pull_wbint_userinfos(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfos *r); void ndr_print_wbint_userinfos(struct ndr_print *ndr, const char *name, const struct wbint_userinfos *r); +enum ndr_err_code ndr_push_wbint_IdType(struct ndr_push *ndr, int ndr_flags, enum wbint_IdType r); +enum ndr_err_code ndr_pull_wbint_IdType(struct ndr_pull *ndr, int ndr_flags, enum wbint_IdType *r); +void ndr_print_wbint_IdType(struct ndr_print *ndr, const char *name, enum wbint_IdType r); void ndr_print_wbint_Ping(struct ndr_print *ndr, const char *name, int flags, const struct wbint_Ping *r); void ndr_print_wbint_LookupSid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupSid *r); void ndr_print_wbint_LookupName(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupName *r); @@ -87,4 +92,5 @@ void ndr_print_wbint_QueryGroupList(struct ndr_print *ndr, const char *name, int void ndr_print_wbint_DsGetDcName(struct ndr_print *ndr, const char *name, int flags, const struct wbint_DsGetDcName *r); void ndr_print_wbint_LookupRids(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupRids *r); void ndr_print_wbint_CheckMachineAccount(struct ndr_print *ndr, const char *name, int flags, const struct wbint_CheckMachineAccount *r); +void ndr_print_wbint_SetMapping(struct ndr_print *ndr, const char *name, int flags, const struct wbint_SetMapping *r); #endif /* _HEADER_NDR_wbint */ diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c index a55a9a7145..e55d19cd0f 100644 --- a/source3/librpc/gen_ndr/srv_wbint.c +++ b/source3/librpc/gen_ndr/srv_wbint.c @@ -1537,6 +1537,79 @@ static bool api_wbint_CheckMachineAccount(pipes_struct *p) return true; } +static bool api_wbint_SetMapping(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct wbint_SetMapping *r; + + call = &ndr_table_wbint.calls[NDR_WBINT_SETMAPPING]; + + r = talloc(talloc_tos(), struct wbint_SetMapping); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_SetMapping, r); + } + + r->out.result = _wbint_SetMapping(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_SetMapping, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + /* Tables */ static struct api_struct api_wbint_cmds[] = @@ -1560,6 +1633,7 @@ static struct api_struct api_wbint_cmds[] = {"WBINT_DSGETDCNAME", NDR_WBINT_DSGETDCNAME, api_wbint_DsGetDcName}, {"WBINT_LOOKUPRIDS", NDR_WBINT_LOOKUPRIDS, api_wbint_LookupRids}, {"WBINT_CHECKMACHINEACCOUNT", NDR_WBINT_CHECKMACHINEACCOUNT, api_wbint_CheckMachineAccount}, + {"WBINT_SETMAPPING", NDR_WBINT_SETMAPPING, api_wbint_SetMapping}, }; void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns) @@ -1813,6 +1887,12 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co return NT_STATUS_OK; } + case NDR_WBINT_SETMAPPING: { + struct wbint_SetMapping *r = (struct wbint_SetMapping *)_r; + r->out.result = _wbint_SetMapping(cli->pipes_struct, r); + return NT_STATUS_OK; + } + default: return NT_STATUS_NOT_IMPLEMENTED; } diff --git a/source3/librpc/gen_ndr/srv_wbint.h b/source3/librpc/gen_ndr/srv_wbint.h index bd56f698aa..b74bb11ded 100644 --- a/source3/librpc/gen_ndr/srv_wbint.h +++ b/source3/librpc/gen_ndr/srv_wbint.h @@ -20,6 +20,7 @@ NTSTATUS _wbint_QueryGroupList(pipes_struct *p, struct wbint_QueryGroupList *r); NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r); NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r); NTSTATUS _wbint_CheckMachineAccount(pipes_struct *p, struct wbint_CheckMachineAccount *r); +NTSTATUS _wbint_SetMapping(pipes_struct *p, struct wbint_SetMapping *r); void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns); NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r); void _wbint_Ping(pipes_struct *p, struct wbint_Ping *r); @@ -41,5 +42,6 @@ NTSTATUS _wbint_QueryGroupList(pipes_struct *p, struct wbint_QueryGroupList *r); NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r); NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r); NTSTATUS _wbint_CheckMachineAccount(pipes_struct *p, struct wbint_CheckMachineAccount *r); +NTSTATUS _wbint_SetMapping(pipes_struct *p, struct wbint_SetMapping *r); NTSTATUS rpc_wbint_init(void); #endif /* __SRV_WBINT__ */ diff --git a/source3/librpc/gen_ndr/wbint.h b/source3/librpc/gen_ndr/wbint.h index 87ce4794d8..4be5e46afb 100644 --- a/source3/librpc/gen_ndr/wbint.h +++ b/source3/librpc/gen_ndr/wbint.h @@ -44,6 +44,21 @@ struct wbint_userinfos { struct wbint_userinfo *userinfos;/* [size_is(num_userinfos)] */ }/* [public] */; +enum wbint_IdType +#ifndef USE_UINT_ENUMS + { + WBINT_ID_TYPE_NOT_SPECIFIED, + WBINT_ID_TYPE_UID, + WBINT_ID_TYPE_GID +} +#else + { __donnot_use_enum_wbint_IdType=0x7FFFFFFF} +#define WBINT_ID_TYPE_NOT_SPECIFIED ( 0 ) +#define WBINT_ID_TYPE_UID ( 1 ) +#define WBINT_ID_TYPE_GID ( 2 ) +#endif +; + struct wbint_Ping { struct { @@ -278,4 +293,18 @@ struct wbint_CheckMachineAccount { }; + +struct wbint_SetMapping { + struct { + struct dom_sid *sid;/* [ref] */ + enum wbint_IdType type; + uint64_t id; + } in; + + struct { + NTSTATUS result; + } out; + +}; + #endif /* _HEADER_wbint */ |