diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-03-08 16:32:45 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-03-12 15:25:42 +0100 |
commit | 8dc4fd921b3d49d757f382d5546447eed37ea9f2 (patch) | |
tree | 0bca6de837db9409d92d1df8f0a8cf5882e14c7c | |
parent | a3ae9802d47f7a39030be089d15fc42f8e8917e6 (diff) | |
download | samba-8dc4fd921b3d49d757f382d5546447eed37ea9f2.tar.gz samba-8dc4fd921b3d49d757f382d5546447eed37ea9f2.tar.bz2 samba-8dc4fd921b3d49d757f382d5546447eed37ea9f2.zip |
s4:libnet/group*: make use of tevent_req based dcerpc_binding_handle stubs
metze
-rw-r--r-- | source4/libnet/groupinfo.c | 82 | ||||
-rw-r--r-- | source4/libnet/groupman.c | 74 |
2 files changed, 89 insertions, 67 deletions
diff --git a/source4/libnet/groupinfo.c b/source4/libnet/groupinfo.c index 4b60d45f7e..44c21eed3f 100644 --- a/source4/libnet/groupinfo.c +++ b/source4/libnet/groupinfo.c @@ -46,28 +46,28 @@ struct groupinfo_state { }; -static void continue_groupinfo_lookup(struct rpc_request *req); -static void continue_groupinfo_opengroup(struct rpc_request *req); -static void continue_groupinfo_getgroup(struct rpc_request *req); -static void continue_groupinfo_closegroup(struct rpc_request *req); +static void continue_groupinfo_lookup(struct tevent_req *subreq); +static void continue_groupinfo_opengroup(struct tevent_req *subreq); +static void continue_groupinfo_getgroup(struct tevent_req *subreq); +static void continue_groupinfo_closegroup(struct tevent_req *subreq); /** * Stage 1 (optional): Look for a group name in SAM server. */ -static void continue_groupinfo_lookup(struct rpc_request *req) +static void continue_groupinfo_lookup(struct tevent_req *subreq) { struct composite_context *c; struct groupinfo_state *s; - struct rpc_request *opengroup_req; struct monitor_msg msg; struct msg_rpc_lookup_name *msg_lookup; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupinfo_state); /* receive samr_Lookup reply */ - c->status = dcerpc_samr_LookupNames_recv(req); + c->status = dcerpc_samr_LookupNames_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; /* there could be a problem with name resolving itself */ @@ -104,29 +104,31 @@ static void continue_groupinfo_lookup(struct rpc_request *req) s->opengroup.out.group_handle = &s->group_handle; /* send request */ - opengroup_req = dcerpc_samr_OpenGroup_send(s->pipe, c, &s->opengroup); - if (composite_nomem(opengroup_req, c)) return; + subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx, + s->pipe->binding_handle, + &s->opengroup); + if (composite_nomem(subreq, c)) return; - composite_continue_rpc(c, opengroup_req, continue_groupinfo_opengroup, c); + tevent_req_set_callback(subreq, continue_groupinfo_opengroup, c); } /** * Stage 2: Open group policy handle. */ -static void continue_groupinfo_opengroup(struct rpc_request *req) +static void continue_groupinfo_opengroup(struct tevent_req *subreq) { struct composite_context *c; struct groupinfo_state *s; - struct rpc_request *querygroup_req; struct monitor_msg msg; struct msg_rpc_open_group *msg_open; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupinfo_state); /* receive samr_OpenGroup reply */ - c->status = dcerpc_samr_OpenGroup_recv(req); + c->status = dcerpc_samr_OpenGroup_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; if (!NT_STATUS_IS_OK(s->querygroupinfo.out.result)) { @@ -153,29 +155,32 @@ static void continue_groupinfo_opengroup(struct rpc_request *req) if (composite_nomem(s->querygroupinfo.out.info, c)) return; /* queue rpc call, set event handling and new state */ - querygroup_req = dcerpc_samr_QueryGroupInfo_send(s->pipe, c, &s->querygroupinfo); - if (composite_nomem(querygroup_req, c)) return; + subreq = dcerpc_samr_QueryGroupInfo_r_send(s, + c->event_ctx, + s->pipe->binding_handle, + &s->querygroupinfo); + if (composite_nomem(subreq, c)) return; - composite_continue_rpc(c, querygroup_req, continue_groupinfo_getgroup, c); + tevent_req_set_callback(subreq, continue_groupinfo_getgroup, c); } /** * Stage 3: Get requested group information. */ -static void continue_groupinfo_getgroup(struct rpc_request *req) +static void continue_groupinfo_getgroup(struct tevent_req *subreq) { struct composite_context *c; struct groupinfo_state *s; - struct rpc_request *close_req; struct monitor_msg msg; struct msg_rpc_query_group *msg_query; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupinfo_state); /* receive samr_QueryGroupInfo reply */ - c->status = dcerpc_samr_QueryGroupInfo_recv(req); + c->status = dcerpc_samr_QueryGroupInfo_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; /* check if querygroup itself went ok */ @@ -202,28 +207,31 @@ static void continue_groupinfo_getgroup(struct rpc_request *req) s->samrclose.out.handle = &s->group_handle; /* queue rpc call, set event handling and new state */ - close_req = dcerpc_samr_Close_send(s->pipe, c, &s->samrclose); - if (composite_nomem(close_req, c)) return; + subreq = dcerpc_samr_Close_r_send(s, c->event_ctx, + s->pipe->binding_handle, + &s->samrclose); + if (composite_nomem(subreq, c)) return; - composite_continue_rpc(c, close_req, continue_groupinfo_closegroup, c); + tevent_req_set_callback(subreq, continue_groupinfo_closegroup, c); } /** * Stage 4: Close policy handle associated with opened group. */ -static void continue_groupinfo_closegroup(struct rpc_request *req) +static void continue_groupinfo_closegroup(struct tevent_req *subreq) { struct composite_context *c; struct groupinfo_state *s; struct monitor_msg msg; struct msg_rpc_close_group *msg_close; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupinfo_state); /* receive samr_Close reply */ - c->status = dcerpc_samr_Close_recv(req); + c->status = dcerpc_samr_Close_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; if (!NT_STATUS_IS_OK(s->samrclose.out.result)) { @@ -259,7 +267,7 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p, struct composite_context *c; struct groupinfo_state *s; struct dom_sid *sid; - struct rpc_request *opengroup_req, *lookup_req; + struct tevent_req *subreq; if (!p || !io) return NULL; @@ -286,10 +294,12 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p, s->opengroup.out.group_handle = &s->group_handle; /* send request */ - opengroup_req = dcerpc_samr_OpenGroup_send(p, c, &s->opengroup); - if (composite_nomem(opengroup_req, c)) return c; + subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx, + p->binding_handle, + &s->opengroup); + if (composite_nomem(subreq, c)) return c; - composite_continue_rpc(c, opengroup_req, continue_groupinfo_opengroup, c); + tevent_req_set_callback(subreq, continue_groupinfo_opengroup, c); } else { /* preparing parameters to send rpc request */ @@ -306,10 +316,12 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p, if (composite_nomem(s->lookup.out.types, c)) return c; /* send request */ - lookup_req = dcerpc_samr_LookupNames_send(p, c, &s->lookup); - if (composite_nomem(lookup_req, c)) return c; + subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx, + p->binding_handle, + &s->lookup); + if (composite_nomem(subreq, c)) return c; - composite_continue_rpc(c, lookup_req, continue_groupinfo_lookup, c); + tevent_req_set_callback(subreq, continue_groupinfo_lookup, c); } return c; diff --git a/source4/libnet/groupman.c b/source4/libnet/groupman.c index 8e84d3cdb9..c8762f4f14 100644 --- a/source4/libnet/groupman.c +++ b/source4/libnet/groupman.c @@ -38,7 +38,7 @@ struct groupadd_state { }; -static void continue_groupadd_created(struct rpc_request *req); +static void continue_groupadd_created(struct tevent_req *subreq); struct composite_context* libnet_rpc_groupadd_send(struct dcerpc_pipe *p, @@ -47,7 +47,7 @@ struct composite_context* libnet_rpc_groupadd_send(struct dcerpc_pipe *p, { struct composite_context *c; struct groupadd_state *s; - struct rpc_request *create_req; + struct tevent_req *subreq; if (!p || !io) return NULL; @@ -76,10 +76,12 @@ struct composite_context* libnet_rpc_groupadd_send(struct dcerpc_pipe *p, s->creategroup.out.group_handle = &s->group_handle; s->creategroup.out.rid = &s->group_rid; - create_req = dcerpc_samr_CreateDomainGroup_send(s->pipe, c, &s->creategroup); - if (composite_nomem(create_req, c)) return c; + subreq = dcerpc_samr_CreateDomainGroup_r_send(s, c->event_ctx, + s->pipe->binding_handle, + &s->creategroup); + if (composite_nomem(subreq, c)) return c; - composite_continue_rpc(c, create_req, continue_groupadd_created, c); + tevent_req_set_callback(subreq, continue_groupadd_created, c); return c; } @@ -99,15 +101,16 @@ NTSTATUS libnet_rpc_groupadd_recv(struct composite_context *c, TALLOC_CTX *mem_c } -static void continue_groupadd_created(struct rpc_request *req) +static void continue_groupadd_created(struct tevent_req *subreq) { struct composite_context *c; struct groupadd_state *s; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupadd_state); - c->status = dcerpc_samr_CreateDomainGroup_recv(req); + c->status = dcerpc_samr_CreateDomainGroup_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; c->status = s->creategroup.out.result; @@ -140,9 +143,9 @@ struct groupdel_state { }; -static void continue_groupdel_name_found(struct rpc_request *req); -static void continue_groupdel_group_opened(struct rpc_request *req); -static void continue_groupdel_deleted(struct rpc_request *req); +static void continue_groupdel_name_found(struct tevent_req *subreq); +static void continue_groupdel_group_opened(struct tevent_req *subreq); +static void continue_groupdel_deleted(struct tevent_req *subreq); struct composite_context* libnet_rpc_groupdel_send(struct dcerpc_pipe *p, @@ -151,7 +154,7 @@ struct composite_context* libnet_rpc_groupdel_send(struct dcerpc_pipe *p, { struct composite_context *c; struct groupdel_state *s; - struct rpc_request *lookup_req; + struct tevent_req *subreq; /* composite context allocation and setup */ c = composite_create(p, dcerpc_event_context(p)); @@ -178,25 +181,27 @@ struct composite_context* libnet_rpc_groupdel_send(struct dcerpc_pipe *p, if (composite_nomem(s->lookupname.out.types, c)) return c; /* send the request */ - lookup_req = dcerpc_samr_LookupNames_send(p, c, &s->lookupname); - if (composite_nomem(lookup_req, c)) return c; + subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx, + p->binding_handle, + &s->lookupname); + if (composite_nomem(subreq, c)) return c; - composite_continue_rpc(c, lookup_req, continue_groupdel_name_found, c); + tevent_req_set_callback(subreq, continue_groupdel_name_found, c); return c; } -static void continue_groupdel_name_found(struct rpc_request *req) +static void continue_groupdel_name_found(struct tevent_req *subreq) { struct composite_context *c; struct groupdel_state *s; - struct rpc_request *opengroup_req; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupdel_state); /* receive samr_LookupNames result */ - c->status = dcerpc_samr_LookupNames_recv(req); + c->status = dcerpc_samr_LookupNames_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; c->status = s->lookupname.out.result; @@ -225,24 +230,26 @@ static void continue_groupdel_name_found(struct rpc_request *req) s->opengroup.out.group_handle = &s->group_handle; /* send rpc request */ - opengroup_req = dcerpc_samr_OpenGroup_send(s->pipe, c, &s->opengroup); - if (composite_nomem(opengroup_req, c)) return; + subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx, + s->pipe->binding_handle, + &s->opengroup); + if (composite_nomem(subreq, c)) return; - composite_continue_rpc(c, opengroup_req, continue_groupdel_group_opened, c); + tevent_req_set_callback(subreq, continue_groupdel_group_opened, c); } -static void continue_groupdel_group_opened(struct rpc_request *req) +static void continue_groupdel_group_opened(struct tevent_req *subreq) { struct composite_context *c; struct groupdel_state *s; - struct rpc_request *delgroup_req; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupdel_state); /* receive samr_OpenGroup result */ - c->status = dcerpc_samr_OpenGroup_recv(req); + c->status = dcerpc_samr_OpenGroup_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; c->status = s->opengroup.out.result; @@ -256,24 +263,27 @@ static void continue_groupdel_group_opened(struct rpc_request *req) s->deletegroup.out.group_handle = &s->group_handle; /* send rpc request */ - delgroup_req = dcerpc_samr_DeleteDomainGroup_send(s->pipe, c, &s->deletegroup); - if (composite_nomem(delgroup_req, c)) return; + subreq = dcerpc_samr_DeleteDomainGroup_r_send(s, c->event_ctx, + s->pipe->binding_handle, + &s->deletegroup); + if (composite_nomem(subreq, c)) return; /* callback handler setup */ - composite_continue_rpc(c, delgroup_req, continue_groupdel_deleted, c); + tevent_req_set_callback(subreq, continue_groupdel_deleted, c); } -static void continue_groupdel_deleted(struct rpc_request *req) +static void continue_groupdel_deleted(struct tevent_req *subreq) { struct composite_context *c; struct groupdel_state *s; - c = talloc_get_type(req->async.private_data, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct groupdel_state); /* receive samr_DeleteGroup result */ - c->status = dcerpc_samr_DeleteDomainGroup_recv(req); + c->status = dcerpc_samr_DeleteDomainGroup_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; /* return the actual function call status */ |