s4:libnet: let libnet_rpc_groupinfo_send() take tevent_context/dcerpc_binding_handle
authorStefan Metzmacher <metze@samba.org>
Tue, 14 Jan 2014 11:11:17 +0000 (12:11 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 16 Jan 2014 15:22:51 +0000 (16:22 +0100)
This avoids usage/dereferencing 'struct dcerpc_pipe'.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/libnet/groupinfo.c
source4/libnet/libnet_group.c

index 5c8b0f734caebd9d03cda2239c3d809ddcd54697..4e5fea632111ca01c1357fc534b14c5ff887faf2 100644 (file)
@@ -31,7 +31,7 @@
 
 
 struct groupinfo_state {
-       struct dcerpc_pipe         *pipe;
+       struct dcerpc_binding_handle *binding_handle;
        struct policy_handle       domain_handle;
        struct policy_handle       group_handle;
        uint16_t                   level;
@@ -109,7 +109,7 @@ static void continue_groupinfo_lookup(struct tevent_req *subreq)
 
        /* send request */
        subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx,
-                                             s->pipe->binding_handle,
+                                             s->binding_handle,
                                              &s->opengroup);
        if (composite_nomem(subreq, c)) return;
 
@@ -161,7 +161,7 @@ static void continue_groupinfo_opengroup(struct tevent_req *subreq)
        /* queue rpc call, set event handling and new state */
        subreq = dcerpc_samr_QueryGroupInfo_r_send(s,
                                                   c->event_ctx,
-                                                  s->pipe->binding_handle,
+                                                  s->binding_handle,
                                                   &s->querygroupinfo);
        if (composite_nomem(subreq, c)) return;
        
@@ -212,7 +212,7 @@ static void continue_groupinfo_getgroup(struct tevent_req *subreq)
        
        /* queue rpc call, set event handling and new state */
        subreq = dcerpc_samr_Close_r_send(s, c->event_ctx,
-                                         s->pipe->binding_handle,
+                                         s->binding_handle,
                                          &s->samrclose);
        if (composite_nomem(subreq, c)) return;
        
@@ -264,8 +264,9 @@ static void continue_groupinfo_closegroup(struct tevent_req *subreq)
  * @param p dce/rpc call pipe 
  * @param io arguments and results of the call
  */
-struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p,
-                                                   TALLOC_CTX *mem_ctx,
+struct composite_context *libnet_rpc_groupinfo_send(TALLOC_CTX *mem_ctx,
+                                                   struct tevent_context *ev,
+                                                   struct dcerpc_binding_handle *b,
                                                    struct libnet_rpc_groupinfo *io,
                                                    void (*monitor)(struct monitor_msg*))
 {
@@ -274,9 +275,9 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p,
        struct dom_sid *sid;
        struct tevent_req *subreq;
 
-       if (!p || !io) return NULL;
+       if (!b || !io) return NULL;
        
-       c = composite_create(mem_ctx, dcerpc_event_context(p));
+       c = composite_create(mem_ctx, ev);
        if (c == NULL) return c;
        
        s = talloc_zero(c, struct groupinfo_state);
@@ -285,7 +286,7 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p,
        c->private_data = s;
 
        s->level         = io->in.level;
-       s->pipe          = p;
+       s->binding_handle= b;
        s->domain_handle = io->in.domain_handle;
        s->monitor_fn    = monitor;
 
@@ -300,7 +301,7 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p,
                
                /* send request */
                subreq = dcerpc_samr_OpenGroup_r_send(s, c->event_ctx,
-                                                     p->binding_handle,
+                                                     s->binding_handle,
                                                      &s->opengroup);
                if (composite_nomem(subreq, c)) return c;
 
@@ -322,7 +323,7 @@ struct composite_context *libnet_rpc_groupinfo_send(struct dcerpc_pipe *p,
 
                /* send request */
                subreq = dcerpc_samr_LookupNames_r_send(s, c->event_ctx,
-                                                       p->binding_handle,
+                                                       s->binding_handle,
                                                        &s->lookup);
                if (composite_nomem(subreq, c)) return c;
                
@@ -376,6 +377,9 @@ NTSTATUS libnet_rpc_groupinfo(struct dcerpc_pipe *p,
                              TALLOC_CTX *mem_ctx,
                              struct libnet_rpc_groupinfo *io)
 {
-       struct composite_context *c = libnet_rpc_groupinfo_send(p, mem_ctx, io, NULL);
+       struct composite_context *c = libnet_rpc_groupinfo_send(mem_ctx,
+                                                               p->conn->event_ctx,
+                                                               p->binding_handle,
+                                                               io, NULL);
        return libnet_rpc_groupinfo_recv(c, mem_ctx, io);
 }
index c8a95d74a899c28164af406dc6d72a0d06a98552..2ca0cc1b18eaa2eaa08944e41ae8f5424b3e6021 100644 (file)
@@ -257,7 +257,9 @@ struct composite_context* libnet_GroupInfo_send(struct libnet_context *ctx,
                s->info.in.level         = GROUPINFOALL;
 
                /* send the request */
-               info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, s, &s->info, s->monitor_fn);
+               info_req = libnet_rpc_groupinfo_send(s, s->ctx->event_ctx,
+                                                    s->ctx->samr.samr_handle,
+                                                    &s->info, s->monitor_fn);
                if (composite_nomem(info_req, c)) return c;
 
                /* set the next stage */
@@ -306,7 +308,9 @@ static void continue_domain_open_info(struct composite_context *ctx)
                s->info.in.level         = GROUPINFOALL;
 
                /* send the request */
-               info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, s, &s->info, s->monitor_fn);
+               info_req = libnet_rpc_groupinfo_send(s, s->ctx->event_ctx,
+                                                    s->ctx->samr.samr_handle,
+                                                    &s->info, s->monitor_fn);
                if (composite_nomem(info_req, c)) return;
 
                /* set the next stage */
@@ -348,7 +352,9 @@ static void continue_name_found(struct composite_context *ctx)
        s->info.in.level         = GROUPINFOALL;
 
        /* send the request */
-       info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, s, &s->info, s->monitor_fn);
+       info_req = libnet_rpc_groupinfo_send(s, s->ctx->event_ctx,
+                                            s->ctx->samr.samr_handle,
+                                            &s->info, s->monitor_fn);
        if (composite_nomem(info_req, c)) return;
 
        /* set the next stage */