s4-libnet: Add mem_ctx to libnet_DomainOpen calls (bug #8889)
authorAndrew Bartlett <abartlet@samba.org>
Mon, 30 Apr 2012 09:57:45 +0000 (19:57 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 30 Apr 2012 11:08:28 +0000 (13:08 +0200)
source4/libnet/libnet_domain.c
source4/libnet/libnet_group.c
source4/libnet/libnet_lookup.c
source4/libnet/libnet_user.c
source4/libnet/prereq_domain.c

index acd2ece..0829de9 100644 (file)
@@ -268,6 +268,7 @@ static void continue_domain_open_open(struct tevent_req *subreq)
  */
 
 struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx,
+                                                    TALLOC_CTX *mem_ctx,
                                                     struct libnet_DomainOpen *io,
                                                     void (*monitor)(struct monitor_msg*))
 {
@@ -276,7 +277,7 @@ struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx,
        struct composite_context *rpcconn_req;
        struct tevent_req *subreq;
 
-       c = composite_create(ctx, ctx->event_ctx);
+       c = composite_create(mem_ctx, ctx->event_ctx);
        if (c == NULL) return NULL;
 
        s = talloc_zero(c, struct domain_open_samr_state);
@@ -414,6 +415,7 @@ static void continue_lsa_policy_open(struct tevent_req *subreq);
  */
 
 struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx,
+                                                   TALLOC_CTX *mem_ctx,
                                                    struct libnet_DomainOpen *io,
                                                    void (*monitor)(struct monitor_msg*))
 {
@@ -424,7 +426,7 @@ struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx,
        struct lsa_QosInfo *qos;
 
        /* create composite context and state */
-       c = composite_create(ctx, ctx->event_ctx);
+       c = composite_create(mem_ctx, ctx->event_ctx);
        if (c == NULL) return c;
 
        s = talloc_zero(c, struct domain_open_lsa_state);
@@ -606,6 +608,7 @@ NTSTATUS libnet_DomainOpenLsa_recv(struct composite_context *c, struct libnet_co
  */
 
 struct composite_context* libnet_DomainOpen_send(struct libnet_context *ctx,
+                                                TALLOC_CTX *mem_ctx,
                                                 struct libnet_DomainOpen *io,
                                                 void (*monitor)(struct monitor_msg*))
 {
@@ -614,13 +617,13 @@ struct composite_context* libnet_DomainOpen_send(struct libnet_context *ctx,
        switch (io->in.type) {
        case DOMAIN_LSA:
                /* reques to open a policy handle on \pipe\lsarpc */
-               c = libnet_DomainOpenLsa_send(ctx, io, monitor);
+               c = libnet_DomainOpenLsa_send(ctx, mem_ctx, io, monitor);
                break;
 
        case DOMAIN_SAMR:
        default:
                /* request to open a domain policy handle on \pipe\samr */
-               c = libnet_DomainOpenSamr_send(ctx, io, monitor);
+               c = libnet_DomainOpenSamr_send(ctx, mem_ctx, io, monitor);
                break;
        }
 
@@ -670,7 +673,7 @@ NTSTATUS libnet_DomainOpen(struct libnet_context *ctx,
                           TALLOC_CTX *mem_ctx,
                           struct libnet_DomainOpen *io)
 {
-       struct composite_context *c = libnet_DomainOpen_send(ctx, io, NULL);
+       struct composite_context *c = libnet_DomainOpen_send(ctx, mem_ctx, io, NULL);
        return libnet_DomainOpen_recv(c, ctx, mem_ctx, io);
 }
 
index 928ce69..c98a477 100644 (file)
@@ -67,7 +67,7 @@ struct composite_context* libnet_CreateGroup_send(struct libnet_context *ctx,
        ZERO_STRUCT(s->r.out);
 
        /* prerequisite: make sure we have a valid samr domain handle */
-       prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,
+       prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open,
                                        continue_domain_opened, monitor);
        if (!prereq_met) return c;
 
@@ -232,7 +232,7 @@ struct composite_context* libnet_GroupInfo_send(struct libnet_context *ctx,
        }
 
        /* prerequisite: make sure the domain is opened */
-       prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,
+       prereq_met = samr_domain_opened(ctx, c, s->domain_name, &c, &s->domopen,
                                        continue_domain_open_info, monitor);
        if (!prereq_met) return c;
 
@@ -487,7 +487,7 @@ struct composite_context *libnet_GroupList_send(struct libnet_context *ctx,
        s->monitor_fn   = monitor;
 
        /* make sure we have lsa domain handle before doing anything */
-       prereq_met = lsa_domain_opened(ctx, s->domain_name, &c, &s->domain_open,
+       prereq_met = lsa_domain_opened(ctx, c, s->domain_name, &c, &s->domain_open,
                                       continue_lsa_domain_opened, monitor);
        if (!prereq_met) return c;
 
@@ -563,7 +563,7 @@ static void continue_domain_queried(struct tevent_req *subreq)
        s->dominfo = (*s->query_domain.out.info)->domain;
 
        /* make sure we have samr domain handle before continuing */
-       prereq_met = samr_domain_opened(s->ctx, s->domain_name, &c, &s->domain_open,
+       prereq_met = samr_domain_opened(s->ctx, c, s->domain_name, &c, &s->domain_open,
                                        continue_samr_domain_opened, s->monitor_fn);
        if (!prereq_met) return;
 
index f5e084f..31ac6e4 100644 (file)
@@ -283,7 +283,7 @@ struct composite_context* libnet_LookupName_send(struct libnet_context *ctx,
        s->monitor_fn = monitor;
        s->ctx = ctx;
 
-       prereq_met = lsa_domain_opened(ctx, io->in.domain_name, &c, &s->domopen,
+       prereq_met = lsa_domain_opened(ctx, c, io->in.domain_name, &c, &s->domopen,
                                       continue_lookup_name, monitor);
        if (!prereq_met) return c;
 
index eef480a..c94e636 100644 (file)
@@ -79,7 +79,7 @@ struct composite_context* libnet_CreateUser_send(struct libnet_context *ctx,
        ZERO_STRUCT(s->r.out);
 
        /* prerequisite: make sure the domain is opened */
-       prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,
+       prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open,
                                        continue_domain_open_create, monitor);
        if (!prereq_met) return c;
 
@@ -247,7 +247,7 @@ struct composite_context *libnet_DeleteUser_send(struct libnet_context *ctx,
        ZERO_STRUCT(s->r.out);
        
        /* prerequisite: make sure the domain is opened before proceeding */
-       prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,
+       prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open,
                                        continue_domain_open_delete, monitor);
        if (!prereq_met) return c;
 
@@ -415,7 +415,7 @@ struct composite_context *libnet_ModifyUser_send(struct libnet_context *ctx,
        s->ctx = ctx;
        s->r = *r;
 
-       prereq_met = samr_domain_opened(ctx, s->r.in.domain_name, &c, &s->domain_open,
+       prereq_met = samr_domain_opened(ctx, c, s->r.in.domain_name, &c, &s->domain_open,
                                        continue_domain_open_modify, monitor);
        if (!prereq_met) return c;
 
@@ -661,7 +661,7 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
        }
 
        /* prerequisite: make sure the domain is opened */
-       prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,
+       prereq_met = samr_domain_opened(ctx, c, s->domain_name, &c, &s->domopen,
                                        continue_domain_open_info, monitor);
        if (!prereq_met) return c;
 
@@ -953,7 +953,7 @@ struct composite_context* libnet_UserList_send(struct libnet_context *ctx,
        s->monitor_fn   = monitor;
 
        /* make sure we have lsa domain handle before doing anything */
-       prereq_met = lsa_domain_opened(ctx, s->domain_name, &c, &s->domain_open,
+       prereq_met = lsa_domain_opened(ctx, c, s->domain_name, &c, &s->domain_open,
                                       continue_lsa_domain_opened, monitor);
        if (!prereq_met) return c;
 
@@ -1029,7 +1029,7 @@ static void continue_domain_queried(struct tevent_req *subreq)
        s->dominfo = (*s->query_domain.out.info)->domain;
 
        /* make sure we have samr domain handle before continuing */
-       prereq_met = samr_domain_opened(s->ctx, s->domain_name, &c, &s->domain_open,
+       prereq_met = samr_domain_opened(s->ctx, c, s->domain_name, &c, &s->domain_open,
                                        continue_samr_domain_opened, s->monitor_fn);
        if (!prereq_met) return;
 
index 039d99d..679669e 100644 (file)
@@ -29,7 +29,8 @@
 #include "librpc/gen_ndr/ndr_lsa.h"
 
 
-bool samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
+bool samr_domain_opened(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+                       const char *domain_name,
                        struct composite_context **parent_ctx,
                        struct libnet_DomainOpen *domain_open,
                        void (*continue_fn)(struct composite_context*),
@@ -76,7 +77,7 @@ bool samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
        }
 
        /* send request to open the domain */
-       domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
+       domopen_req = libnet_DomainOpen_send(ctx, mem_ctx, domain_open, monitor);
        if (composite_nomem(domopen_req, *parent_ctx)) return false;
        
        composite_continue(*parent_ctx, domopen_req, continue_fn, *parent_ctx);
@@ -84,7 +85,8 @@ bool samr_domain_opened(struct libnet_context *ctx, const char *domain_name,
 }
 
 
-bool lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
+bool lsa_domain_opened(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+                      const char *domain_name,
                       struct composite_context **parent_ctx,
                       struct libnet_DomainOpen *domain_open,
                       void (*continue_fn)(struct composite_context*),
@@ -133,7 +135,7 @@ bool lsa_domain_opened(struct libnet_context *ctx, const char *domain_name,
        }
 
        /* send request to open the domain */
-       domopen_req = libnet_DomainOpen_send(ctx, domain_open, monitor);
+       domopen_req = libnet_DomainOpen_send(ctx, mem_ctx, domain_open, monitor);
        /* see the comment above to find out why true is returned here */
        if (composite_nomem(domopen_req, *parent_ctx)) return true;