diff options
Diffstat (limited to 'source4/libnet')
-rw-r--r-- | source4/libnet/composite.h | 19 | ||||
-rw-r--r-- | source4/libnet/domain.c | 20 | ||||
-rw-r--r-- | source4/libnet/libnet_lookup.c | 7 | ||||
-rw-r--r-- | source4/libnet/userinfo.c | 24 | ||||
-rw-r--r-- | source4/libnet/userman.c | 67 |
5 files changed, 72 insertions, 65 deletions
diff --git a/source4/libnet/composite.h b/source4/libnet/composite.h index 6d805812c0..0500e19f5a 100644 --- a/source4/libnet/composite.h +++ b/source4/libnet/composite.h @@ -24,6 +24,25 @@ #include "librpc/gen_ndr/ndr_samr.h" +/* + * Monitor structure and message types definitions. Composite function monitoring + * allows client application to be notified on function progress. This enables + * eg. gui client to display progress bars, status messages, etc. + */ + + +#define rpc_create_user (0x00000001) /* userman.h */ +#define rpc_open_user (0x00000002) /* userinfo.h */ +#define rpc_query_user (0x00000003) /* userinfo.h */ +#define rpc_close_user (0x00000004) /* userinfo.h */ +#define rpc_lookup_name (0x00000005) /* userman.h */ +#define rpc_delete_user (0x00000006) /* userman.h */ + +struct monitor_msg { + uint32_t type; + void *data; + size_t data_size; +}; struct libnet_rpc_userinfo { struct { diff --git a/source4/libnet/domain.c b/source4/libnet/domain.c index 94a2412261..3a5aecb92e 100644 --- a/source4/libnet/domain.c +++ b/source4/libnet/domain.c @@ -23,9 +23,7 @@ */ #include "includes.h" -#include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" -#include "libcli/composite/monitor.h" #include "librpc/gen_ndr/ndr_samr.h" #include "libnet/composite.h" @@ -119,7 +117,7 @@ static NTSTATUS domain_open_open(struct composite_context *c, c->status = dcerpc_ndr_request_recv(s->req); NT_STATUS_NOT_OK_RETURN(c->status); - c->state = SMBCLI_REQUEST_DONE; + c->state = COMPOSITE_STATE_DONE; return NT_STATUS_OK; } @@ -134,8 +132,7 @@ static NTSTATUS domain_open_open(struct composite_context *c, static void domain_open_handler(struct rpc_request *req) { struct composite_context *c = req->async.private; - struct domain_open_state *s = talloc_get_type(c->private, struct domain_open_state); - struct monitor_msg msg; + struct domain_open_state *s = talloc_get_type(c->private_data, struct domain_open_state); /* Stages of the call */ switch (s->stage) { @@ -151,11 +148,7 @@ static void domain_open_handler(struct rpc_request *req) } if (!NT_STATUS_IS_OK(c->status)) { - c->state = SMBCLI_REQUEST_ERROR; - } - - if (c->monitor_fn) { - c->monitor_fn(&msg); + c->state = COMPOSITE_STATE_ERROR; } } @@ -179,10 +172,9 @@ struct composite_context *libnet_rpc_domain_open_send(struct dcerpc_pipe *p, s = talloc_zero(c, struct domain_open_state); if (s == NULL) goto failure; - c->state = SMBCLI_REQUEST_SEND; - c->private = s; + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->private_data= s; c->event_ctx = dcerpc_event_context(p); - c->monitor_fn = monitor; s->pipe = p; s->access_mask = io->in.access_mask; @@ -227,7 +219,7 @@ NTSTATUS libnet_rpc_domain_open_recv(struct composite_context *c, TALLOC_CTX *me status = composite_wait(c); if (NT_STATUS_IS_OK(status) && io) { - s = talloc_get_type(c->private, struct domain_open_state); + s = talloc_get_type(c->private_data, struct domain_open_state); io->out.domain_handle = s->domain_handle; } diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c index ba806e4e44..010d30ac4a 100644 --- a/source4/libnet/libnet_lookup.c +++ b/source4/libnet/libnet_lookup.c @@ -27,7 +27,6 @@ #include "lib/events/events.h" #include "libnet/libnet.h" #include "libcli/composite/composite.h" -#include "libcli/composite/monitor.h" #include "libnet/composite.h" #include "librpc/gen_ndr/ndr_nbt.h" @@ -78,8 +77,8 @@ struct composite_context *libnet_Lookup_send(struct libnet_context *ctx, methods = (const char**)ctx->name_res_methods; } - c->private = s; - c->state = SMBCLI_REQUEST_SEND; + c->private_data = s; + c->state = COMPOSITE_STATE_IN_PROGRESS; /* send resolve request */ s->resolve_ctx = resolve_name_send(&s->hostname, c->event_ctx, methods); @@ -107,7 +106,7 @@ NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, NTSTATUS status; struct lookup_state *s; - s = talloc_get_type(c->private, struct lookup_state); + s = talloc_get_type(c->private_data, struct lookup_state); status = resolve_name_recv(s->resolve_ctx, mem_ctx, s->address); return status; diff --git a/source4/libnet/userinfo.c b/source4/libnet/userinfo.c index def9c87147..378bc814bd 100644 --- a/source4/libnet/userinfo.c +++ b/source4/libnet/userinfo.c @@ -23,9 +23,7 @@ */ #include "includes.h" -#include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" -#include "libcli/composite/monitor.h" #include "librpc/gen_ndr/ndr_samr.h" #include "libnet/composite.h" #include "libnet/userinfo.h" @@ -44,6 +42,8 @@ struct userinfo_state { struct samr_QueryUserInfo queryuserinfo; struct samr_Close samrclose; union samr_UserInfo *info; + /* information about the progress */ + void (*monitor_fn)(struct monitor_msg *); }; @@ -113,7 +113,7 @@ static NTSTATUS userinfo_closeuser(struct composite_context *c, c->status = dcerpc_ndr_request_recv(s->req); NT_STATUS_NOT_OK_RETURN(c->status); - c->state = SMBCLI_REQUEST_DONE; + c->state = COMPOSITE_STATE_DONE; return NT_STATUS_OK; } @@ -128,7 +128,7 @@ static NTSTATUS userinfo_closeuser(struct composite_context *c, static void userinfo_handler(struct rpc_request *req) { struct composite_context *c = req->async.private; - struct userinfo_state *s = talloc_get_type(c->private, struct userinfo_state); + struct userinfo_state *s = talloc_get_type(c->private_data, struct userinfo_state); struct monitor_msg msg; struct msg_rpc_open_user *msg_open; struct msg_rpc_query_user *msg_query; @@ -169,14 +169,14 @@ static void userinfo_handler(struct rpc_request *req) } if (!NT_STATUS_IS_OK(c->status)) { - c->state = SMBCLI_REQUEST_ERROR; + c->state = COMPOSITE_STATE_ERROR; } - if (c->monitor_fn) { - c->monitor_fn(&msg); + if (s->monitor_fn) { + s->monitor_fn(&msg); } - if (c->state >= SMBCLI_REQUEST_DONE && + if (c->state >= COMPOSITE_STATE_DONE && c->async.fn) { c->async.fn(c); } @@ -207,13 +207,13 @@ struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p, s->level = io->in.level; s->pipe = p; + s->monitor_fn = monitor; sid = dom_sid_parse_talloc(s, io->in.sid); if (sid == NULL) goto failure; - c->state = SMBCLI_REQUEST_SEND; - c->private = s; + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->private_data= s; c->event_ctx = dcerpc_event_context(p); - c->monitor_fn = monitor; /* preparing parameters to send rpc request */ s->openuser.in.domain_handle = &io->in.domain_handle; @@ -256,7 +256,7 @@ NTSTATUS libnet_rpc_userinfo_recv(struct composite_context *c, TALLOC_CTX *mem_c status = composite_wait(c); if (NT_STATUS_IS_OK(status) && io) { - s = talloc_get_type(c->private, struct userinfo_state); + s = talloc_get_type(c->private_data, struct userinfo_state); talloc_steal(mem_ctx, s->info); io->out.info = *s->info; } diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c index eacc1a2b42..e38f4dcb7c 100644 --- a/source4/libnet/userman.c +++ b/source4/libnet/userman.c @@ -23,9 +23,7 @@ */ #include "includes.h" -#include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" -#include "libcli/composite/monitor.h" #include "librpc/gen_ndr/ndr_samr.h" #include "libnet/composite.h" #include "libnet/userman.h" @@ -47,6 +45,8 @@ struct useradd_state { struct samr_CreateUser createuser; struct policy_handle user_handle; uint32_t user_rid; + /* information about the progress */ + void (*monitor_fn)(struct monitor_msg *); }; @@ -59,7 +59,7 @@ static NTSTATUS useradd_create(struct composite_context *c, c->status = dcerpc_ndr_request_recv(s->req); NT_STATUS_NOT_OK_RETURN(c->status); - c->state = SMBCLI_REQUEST_DONE; + c->state = COMPOSITE_STATE_DONE; return NT_STATUS_OK; } @@ -73,7 +73,7 @@ static NTSTATUS useradd_create(struct composite_context *c, static void useradd_handler(struct rpc_request *req) { struct composite_context *c = req->async.private; - struct useradd_state *s = talloc_get_type(c->private, struct useradd_state); + struct useradd_state *s = talloc_get_type(c->private_data, struct useradd_state); struct monitor_msg msg; struct msg_rpc_create_user *rpc_create; @@ -90,14 +90,14 @@ static void useradd_handler(struct rpc_request *req) } if (!NT_STATUS_IS_OK(c->status)) { - c->state = SMBCLI_REQUEST_ERROR; + c->state = COMPOSITE_STATE_ERROR; } - if (c->monitor_fn) { - c->monitor_fn(&msg); + if (s->monitor_fn) { + s->monitor_fn(&msg); } - if (c->state >= SMBCLI_REQUEST_DONE && + if (c->state >= COMPOSITE_STATE_DONE && c->async.fn) { c->async.fn(c); } @@ -126,11 +126,11 @@ struct composite_context *libnet_rpc_useradd_send(struct dcerpc_pipe *p, s->domain_handle = io->in.domain_handle; s->pipe = p; + s->monitor_fn = monitor; - c->state = SMBCLI_REQUEST_SEND; - c->private = s; + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->private_data= s; c->event_ctx = dcerpc_event_context(p); - c->monitor_fn = monitor; /* preparing parameters to send rpc request */ s->createuser.in.domain_handle = &io->in.domain_handle; @@ -174,7 +174,7 @@ NTSTATUS libnet_rpc_useradd_recv(struct composite_context *c, TALLOC_CTX *mem_ct if (NT_STATUS_IS_OK(status) && io) { /* get and return result of the call */ - s = talloc_get_type(c->private, struct useradd_state); + s = talloc_get_type(c->private_data, struct useradd_state); io->out.user_handle = s->user_handle; } @@ -218,6 +218,8 @@ struct userdel_state { struct samr_LookupNames lookupname; struct samr_OpenUser openuser; struct samr_DeleteUser deleteuser; + /* information about the progress */ + void (*monitor_fn)(struct monitor_msg *); }; @@ -287,7 +289,7 @@ static NTSTATUS userdel_delete(struct composite_context *c, c->status = dcerpc_ndr_request_recv(s->req); NT_STATUS_NOT_OK_RETURN(c->status); - c->state = SMBCLI_REQUEST_DONE; + c->state = COMPOSITE_STATE_DONE; return NT_STATUS_OK; } @@ -302,7 +304,7 @@ static NTSTATUS userdel_delete(struct composite_context *c, static void userdel_handler(struct rpc_request *req) { struct composite_context *c = req->async.private; - struct userdel_state *s = talloc_get_type(c->private, struct userdel_state); + struct userdel_state *s = talloc_get_type(c->private_data, struct userdel_state); struct monitor_msg msg; struct msg_rpc_lookup_name *msg_lookup; struct msg_rpc_open_user *msg_open; @@ -340,14 +342,14 @@ static void userdel_handler(struct rpc_request *req) } if (!NT_STATUS_IS_OK(c->status)) { - c->state = SMBCLI_REQUEST_ERROR; + c->state = COMPOSITE_STATE_ERROR; } - if (c->monitor_fn) { - c->monitor_fn(&msg); + if (s->monitor_fn) { + s->monitor_fn(&msg); } - if (c->state >= SMBCLI_REQUEST_DONE && + if (c->state >= COMPOSITE_STATE_DONE && c->async.fn) { c->async.fn(c); } @@ -373,9 +375,9 @@ struct composite_context *libnet_rpc_userdel_send(struct dcerpc_pipe *p, s = talloc_zero(c, struct userdel_state); if (s == NULL) goto failure; - c->state = SMBCLI_REQUEST_SEND; - c->private = s; - c->event_ctx = dcerpc_event_context(p); + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->private_data= s; + c->event_ctx = dcerpc_event_context(p); s->pipe = p; s->domain_handle = io->in.domain_handle; @@ -403,7 +405,7 @@ failure: /** - * Waits for and receives results of asynchronous userdel call +1 * Waits for and receives results of asynchronous userdel call * * @param c composite context returned by asynchronous userdel call * @param mem_ctx memory context of the call @@ -420,7 +422,7 @@ NTSTATUS libnet_rpc_userdel_recv(struct composite_context *c, TALLOC_CTX *mem_ct status = composite_wait(c); if (NT_STATUS_IS_OK(status) && io) { - s = talloc_get_type(c->private, struct userdel_state); + s = talloc_get_type(c->private_data, struct userdel_state); io->out.user_handle = s->user_handle; } @@ -672,7 +674,7 @@ static NTSTATUS usermod_modify(struct composite_context *c, c->status = dcerpc_ndr_request_recv(s->req); NT_STATUS_NOT_OK_RETURN(c->status); - c->state = SMBCLI_REQUEST_DONE; + c->state = COMPOSITE_STATE_DONE; return NT_STATUS_OK; } @@ -688,8 +690,7 @@ static NTSTATUS usermod_modify(struct composite_context *c, static void usermod_handler(struct rpc_request *req) { struct composite_context *c = req->async.private; - struct usermod_state *s = talloc_get_type(c->private, struct usermod_state); - struct monitor_msg msg; + struct usermod_state *s = talloc_get_type(c->private_data, struct usermod_state); switch (s->stage) { case USERMOD_LOOKUP: @@ -710,14 +711,10 @@ static void usermod_handler(struct rpc_request *req) } if (!NT_STATUS_IS_OK(c->status)) { - c->state = SMBCLI_REQUEST_ERROR; - } - - if (c->monitor_fn) { - c->monitor_fn(&msg); + c->state = COMPOSITE_STATE_ERROR; } - if (c->state >= SMBCLI_REQUEST_DONE && + if (c->state >= COMPOSITE_STATE_DONE && c->async.fn) { c->async.fn(c); } @@ -743,9 +740,9 @@ struct composite_context *libnet_rpc_usermod_send(struct dcerpc_pipe *p, s = talloc_zero(c, struct usermod_state); if (s == NULL) goto failure; - c->state = SMBCLI_REQUEST_SEND; - c->private = s; - c->event_ctx = dcerpc_event_context(p); + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->private_data = s; + c->event_ctx = dcerpc_event_context(p); s->pipe = p; s->domain_handle = io->in.domain_handle; |