diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-03-09 21:42:13 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-03-09 21:42:13 +0100 |
commit | 3b181564c552ed3bc464534714148556deeeca2c (patch) | |
tree | 7e5a1d454dbec89cd85f9b5804566161a6790a24 | |
parent | 0d2de5380d13d544c382e3626e3b84fbea4b70a7 (diff) | |
parent | c666aef471174ca5d95afcc48924325e7caded14 (diff) | |
download | samba-3b181564c552ed3bc464534714148556deeeca2c.tar.gz samba-3b181564c552ed3bc464534714148556deeeca2c.tar.bz2 samba-3b181564c552ed3bc464534714148556deeeca2c.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba
50 files changed, 2040 insertions, 1834 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index 424da952eb..f803b9cc36 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -379,11 +379,13 @@ struct writev_state { size_t total_size; }; +static void writev_trigger(struct tevent_req *req, void *private_data); static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, void *private_data); struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - int fd, struct iovec *iov, int count) + struct tevent_queue *queue, int fd, + struct iovec *iov, int count) { struct tevent_req *result; struct writev_state *state; @@ -403,18 +405,42 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, goto fail; } + /* + * This if () should go away once our callers are converted to always + * pass in a queue. + */ + + if (queue != NULL) { + if (!tevent_queue_add(queue, ev, result, writev_trigger, + NULL)) { + goto fail; + } + return result; + } + fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, writev_handler, result); if (fde == NULL) { goto fail; } return result; - fail: TALLOC_FREE(result); return NULL; } +static void writev_trigger(struct tevent_req *req, void *private_data) +{ + struct writev_state *state = tevent_req_data(req, struct writev_state); + struct tevent_fd *fde; + + fde = tevent_add_fd(state->ev, state, state->fd, TEVENT_FD_WRITE, + writev_handler, req); + if (fde == NULL) { + tevent_req_error(req, ENOMEM); + } +} + static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, void *private_data) { diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h index e001709d27..c5d9400eb6 100644 --- a/lib/async_req/async_sock.h +++ b/lib/async_req/async_sock.h @@ -43,7 +43,8 @@ struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx, int async_connect_recv(struct tevent_req *req, int *perrno); struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - int fd, struct iovec *iov, int count); + struct tevent_queue *queue, int fd, + struct iovec *iov, int count); ssize_t writev_recv(struct tevent_req *req, int *perrno); struct tevent_req *read_packet_send(TALLOC_CTX *mem_ctx, diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index 8ad9e1d93e..97e60468c4 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -149,11 +149,24 @@ /* * FD00::5357:5FXX */ -static const struct in6_addr swrap_ipv6 = -{ { { -0xFD,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x53,0x57,0x5F,0x00 -} } }; +static const struct in6_addr *swrap_ipv6(void) +{ + static struct in6_addr v; + static int initialized; + int ret; + + if (initialized) { + return &v; + } + initialized = 1; + + ret = inet_pton(AF_INET6, "FD00::5357:5F00", &v); + if (ret <= 0) { + abort(); + } + + return &v; +} #endif static struct sockaddr *sockaddr_dup(const void *data, socklen_t len) @@ -202,6 +215,7 @@ struct socket_info int bound; int bcast; int is_server; + int connected; char *path; char *tmp_path; @@ -304,7 +318,7 @@ static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, sock memset(in2, 0, sizeof(*in2)); in2->sin6_family = AF_INET6; - in2->sin6_addr = swrap_ipv6; + in2->sin6_addr = *swrap_ipv6(); in2->sin6_addr.s6_addr[15] = iface; in2->sin6_port = htons(prt); @@ -394,7 +408,7 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i cmp = in->sin6_addr; cmp.s6_addr[15] = 0; - if (IN6_ARE_ADDR_EQUAL(&swrap_ipv6, &cmp)) { + if (IN6_ARE_ADDR_EQUAL(swrap_ipv6(), &cmp)) { iface = in->sin6_addr.s6_addr[15]; } else { errno = ENETUNREACH; @@ -510,7 +524,9 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in cmp = in->sin6_addr; cmp.s6_addr[15] = 0; - if (IN6_ARE_ADDR_EQUAL(&swrap_ipv6, &cmp)) { + if (IN6_IS_ADDR_UNSPECIFIED(&in->sin6_addr)) { + iface = socket_wrapper_default_iface(); + } else if (IN6_ARE_ADDR_EQUAL(swrap_ipv6(), &cmp)) { iface = in->sin6_addr.s6_addr[15]; } else { errno = EADDRNOTAVAIL; @@ -1485,6 +1501,7 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen) child_si->protocol = parent_si->protocol; child_si->bound = 1; child_si->is_server = 1; + child_si->connected = 1; child_si->peername_len = len; child_si->peername = sockaddr_dup(my_addr, len); @@ -1532,8 +1549,10 @@ static int autobind_start; /* using sendto() or connect() on an unbound socket would give the recipient no way to reply, as unlike UDP and TCP, a unix domain socket can't auto-assign emphemeral port numbers, so we need to - assign it here */ -static int swrap_auto_bind(struct socket_info *si) + assign it here. + Note: this might change the family from ipv6 to ipv4 +*/ +static int swrap_auto_bind(struct socket_info *si, int family) { struct sockaddr_un un_addr; int i; @@ -1551,7 +1570,7 @@ static int swrap_auto_bind(struct socket_info *si) un_addr.sun_family = AF_UNIX; - switch (si->family) { + switch (family) { case AF_INET: { struct sockaddr_in in; @@ -1580,6 +1599,11 @@ static int swrap_auto_bind(struct socket_info *si) case AF_INET6: { struct sockaddr_in6 in6; + if (si->family != family) { + errno = ENETUNREACH; + return -1; + } + switch (si->type) { case SOCK_STREAM: type = SOCKET_TYPE_CHAR_TCP_V6; @@ -1594,7 +1618,7 @@ static int swrap_auto_bind(struct socket_info *si) memset(&in6, 0, sizeof(in6)); in6.sin6_family = AF_INET6; - in6.sin6_addr = swrap_ipv6; + in6.sin6_addr = *swrap_ipv6(); in6.sin6_addr.s6_addr[15] = socket_wrapper_default_iface(); si->myname_len = sizeof(in6); si->myname = sockaddr_dup(&in6, si->myname_len); @@ -1630,6 +1654,7 @@ static int swrap_auto_bind(struct socket_info *si) return -1; } + si->family = family; set_port(si->family, port, si->myname); return 0; @@ -1647,7 +1672,7 @@ _PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t ad } if (si->bound == 0) { - ret = swrap_auto_bind(si); + ret = swrap_auto_bind(si, serv_addr->sa_family); if (ret == -1) return -1; } @@ -1672,7 +1697,14 @@ _PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t ad if (ret == 0) { si->peername_len = addrlen; si->peername = sockaddr_dup(serv_addr, addrlen); + si->connected = 1; + } + if (si->type != SOCK_STREAM) { + return ret; + } + + if (ret == 0) { swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_RECV, NULL, 0); swrap_dump_packet(si, serv_addr, SWRAP_CONNECT_ACK, NULL, 0); } else { @@ -1801,11 +1833,18 @@ _PUBLIC_ ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct socklen_t un_addrlen = sizeof(un_addr); int ret; struct socket_info *si = find_socket_info(s); + struct sockaddr_storage ss; + socklen_t ss_len = sizeof(ss); if (!si) { return real_recvfrom(s, buf, len, flags, from, fromlen); } + if (!from) { + from = (struct sockaddr *)&ss; + fromlen = &ss_len; + } + len = MIN(len, 1500); /* irix 6.4 forgets to null terminate the sun_path string :-( */ @@ -1836,6 +1875,16 @@ _PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, con return real_sendto(s, buf, len, flags, to, tolen); } + if (si->connected) { + if (to) { + errno = EISCONN; + return -1; + } + + to = si->peername; + tolen = si->peername_len; + } + len = MIN(len, 1500); switch (si->type) { @@ -1844,7 +1893,7 @@ _PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, con break; case SOCK_DGRAM: if (si->bound == 0) { - ret = swrap_auto_bind(si); + ret = swrap_auto_bind(si, si->family); if (ret == -1) return -1; } diff --git a/librpc/gen_ndr/cli_spoolss.c b/librpc/gen_ndr/cli_spoolss.c index 87e305f09e..2e0582e088 100644 --- a/librpc/gen_ndr/cli_spoolss.c +++ b/librpc/gen_ndr/cli_spoolss.c @@ -2431,12 +2431,25 @@ NTSTATUS rpccli_spoolss_DeletePrintProvidor(struct rpc_pipe_client *cli, NTSTATUS rpccli_spoolss_EnumPrintProcDataTypes(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + const char *print_processor_name /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + uint32_t *count /* [out] [ref] */, + union spoolss_PrintProcDataTypesInfo **info /* [out] [ref,switch_is(level),size_is(,*count)] */, + uint32_t *needed /* [out] [ref] */, WERROR *werror) { struct spoolss_EnumPrintProcDataTypes r; NTSTATUS status; /* In parameters */ + r.in.servername = servername; + r.in.print_processor_name = print_processor_name; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(spoolss_EnumPrintProcDataTypes, &r); @@ -2461,6 +2474,9 @@ NTSTATUS rpccli_spoolss_EnumPrintProcDataTypes(struct rpc_pipe_client *cli, } /* Return variables */ + *count = *r.out.count; + *info = *r.out.info; + *needed = *r.out.needed; /* Return result */ if (werror) { diff --git a/librpc/gen_ndr/cli_spoolss.h b/librpc/gen_ndr/cli_spoolss.h index ba766d9638..3aebf3308e 100644 --- a/librpc/gen_ndr/cli_spoolss.h +++ b/librpc/gen_ndr/cli_spoolss.h @@ -315,6 +315,14 @@ NTSTATUS rpccli_spoolss_DeletePrintProvidor(struct rpc_pipe_client *cli, WERROR *werror); NTSTATUS rpccli_spoolss_EnumPrintProcDataTypes(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + const char *print_processor_name /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + uint32_t *count /* [out] [ref] */, + union spoolss_PrintProcDataTypesInfo **info /* [out] [ref,switch_is(level),size_is(,*count)] */, + uint32_t *needed /* [out] [ref] */, WERROR *werror); NTSTATUS rpccli_spoolss_ResetPrinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c index c8bc26db6e..3d1237cc8b 100644 --- a/librpc/gen_ndr/ndr_spoolss.c +++ b/librpc/gen_ndr/ndr_spoolss.c @@ -13749,7 +13749,7 @@ _PUBLIC_ size_t ndr_size_spoolss_DriverDirectoryInfo(const union spoolss_DriverD return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverDirectoryInfo, ic); } -static enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrintProcessorInfo1 *r) +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrintProcessorInfo1 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -13774,7 +13774,7 @@ static enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo1(struct ndr_push *n return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrintProcessorInfo1 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrintProcessorInfo1 *r) { uint32_t _ptr_print_processor_name; TALLOC_CTX *_mem_save_print_processor_name_0; @@ -13826,6 +13826,11 @@ _PUBLIC_ void ndr_print_spoolss_PrintProcessorInfo1(struct ndr_print *ndr, const ndr->depth--; } +_PUBLIC_ size_t ndr_size_spoolss_PrintProcessorInfo1(const struct spoolss_PrintProcessorInfo1 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrintProcessorInfo1, ic); +} + _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrintProcessorInfo *r) { uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); @@ -15622,7 +15627,7 @@ _PUBLIC_ void ndr_print_spoolss_AddFormInfo(struct ndr_print *ndr, const char *n } } -static enum ndr_err_code ndr_push_spoolss_PortInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo1 *r) +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo1 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -15647,7 +15652,7 @@ static enum ndr_err_code ndr_push_spoolss_PortInfo1(struct ndr_push *ndr, int nd return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_PortInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo1 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo1 *r) { uint32_t _ptr_port_name; TALLOC_CTX *_mem_save_port_name_0; @@ -15699,6 +15704,11 @@ _PUBLIC_ void ndr_print_spoolss_PortInfo1(struct ndr_print *ndr, const char *nam ndr->depth--; } +_PUBLIC_ size_t ndr_size_spoolss_PortInfo1(const struct spoolss_PortInfo1 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PortInfo1, ic); +} + static enum ndr_err_code ndr_push_spoolss_PortType(struct ndr_push *ndr, int ndr_flags, uint32_t r) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); @@ -15724,7 +15734,7 @@ _PUBLIC_ void ndr_print_spoolss_PortType(struct ndr_print *ndr, const char *name ndr->depth--; } -static enum ndr_err_code ndr_push_spoolss_PortInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo2 *r) +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo2 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -15781,7 +15791,7 @@ static enum ndr_err_code ndr_push_spoolss_PortInfo2(struct ndr_push *ndr, int nd return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_PortInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo2 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo2 *r) { uint32_t _ptr_port_name; TALLOC_CTX *_mem_save_port_name_0; @@ -15907,6 +15917,11 @@ _PUBLIC_ void ndr_print_spoolss_PortInfo2(struct ndr_print *ndr, const char *nam ndr->depth--; } +_PUBLIC_ size_t ndr_size_spoolss_PortInfo2(const struct spoolss_PortInfo2 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PortInfo2, ic); +} + static enum ndr_err_code ndr_push_spoolss_PortStatus(struct ndr_push *ndr, int ndr_flags, enum spoolss_PortStatus r) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); @@ -15969,7 +15984,7 @@ _PUBLIC_ void ndr_print_spoolss_PortSeverity(struct ndr_print *ndr, const char * ndr_print_enum(ndr, name, "ENUM", val, r); } -static enum ndr_err_code ndr_push_spoolss_PortInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo3 *r) +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo3 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -15996,7 +16011,7 @@ static enum ndr_err_code ndr_push_spoolss_PortInfo3(struct ndr_push *ndr, int nd return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_PortInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo3 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo3 *r) { uint32_t _ptr_status_string; TALLOC_CTX *_mem_save_status_string_0; @@ -16052,7 +16067,12 @@ _PUBLIC_ void ndr_print_spoolss_PortInfo3(struct ndr_print *ndr, const char *nam ndr->depth--; } -static enum ndr_err_code ndr_push_spoolss_PortInfoFF(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfoFF *r) +_PUBLIC_ size_t ndr_size_spoolss_PortInfo3(const struct spoolss_PortInfo3 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PortInfo3, ic); +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfoFF(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfoFF *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -16078,7 +16098,7 @@ static enum ndr_err_code ndr_push_spoolss_PortInfoFF(struct ndr_push *ndr, int n return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_PortInfoFF(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfoFF *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfoFF(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfoFF *r) { uint32_t _ptr_port_name; TALLOC_CTX *_mem_save_port_name_0; @@ -16132,6 +16152,11 @@ _PUBLIC_ void ndr_print_spoolss_PortInfoFF(struct ndr_print *ndr, const char *na ndr->depth--; } +_PUBLIC_ size_t ndr_size_spoolss_PortInfoFF(const struct spoolss_PortInfoFF *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PortInfoFF, ic); +} + _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PortInfo *r) { uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); @@ -16288,7 +16313,7 @@ _PUBLIC_ void ndr_print_spoolss_PortInfo(struct ndr_print *ndr, const char *name } } -static enum ndr_err_code ndr_push_spoolss_MonitorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo1 *r) +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_MonitorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo1 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -16313,7 +16338,7 @@ static enum ndr_err_code ndr_push_spoolss_MonitorInfo1(struct ndr_push *ndr, int return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_MonitorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo1 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_MonitorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo1 *r) { uint32_t _ptr_monitor_name; TALLOC_CTX *_mem_save_monitor_name_0; @@ -16365,7 +16390,12 @@ _PUBLIC_ void ndr_print_spoolss_MonitorInfo1(struct ndr_print *ndr, const char * ndr->depth--; } -static enum ndr_err_code ndr_push_spoolss_MonitorInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo2 *r) +_PUBLIC_ size_t ndr_size_spoolss_MonitorInfo1(const struct spoolss_MonitorInfo1 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_MonitorInfo1, ic); +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_MonitorInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo2 *r) { if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); @@ -16420,7 +16450,7 @@ static enum ndr_err_code ndr_push_spoolss_MonitorInfo2(struct ndr_push *ndr, int return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_MonitorInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo2 *r) +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_MonitorInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo2 *r) { uint32_t _ptr_monitor_name; TALLOC_CTX *_mem_save_monitor_name_0; @@ -16542,6 +16572,11 @@ _PUBLIC_ void ndr_print_spoolss_MonitorInfo2(struct ndr_print *ndr, const char * ndr->depth--; } +_PUBLIC_ size_t ndr_size_spoolss_MonitorInfo2(const struct spoolss_MonitorInfo2 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_MonitorInfo2, ic); +} + _PUBLIC_ enum ndr_err_code ndr_push_spoolss_MonitorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_MonitorInfo *r) { uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); @@ -16650,6 +16685,172 @@ _PUBLIC_ void ndr_print_spoolss_MonitorInfo(struct ndr_print *ndr, const char *n } } +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrintProcDataTypesInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrintProcDataTypesInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->name_array)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->name_array) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->name_array)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name_array)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrintProcDataTypesInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrintProcDataTypesInfo1 *r) +{ + uint32_t _ptr_name_array; + TALLOC_CTX *_mem_save_name_array_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name_array)); + if (_ptr_name_array) { + NDR_PULL_ALLOC(ndr, r->name_array); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->name_array, _ptr_name_array)); + } else { + r->name_array = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->name_array) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->name_array)); + _mem_save_name_array_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->name_array, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name_array)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_array_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrintProcDataTypesInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrintProcDataTypesInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrintProcDataTypesInfo1"); + ndr->depth++; + ndr_print_ptr(ndr, "name_array", r->name_array); + ndr->depth++; + if (r->name_array) { + ndr_print_string(ndr, "name_array", r->name_array); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_spoolss_PrintProcDataTypesInfo1(const struct spoolss_PrintProcDataTypesInfo1 *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrintProcDataTypesInfo1, ic); +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrintProcDataTypesInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrintProcDataTypesInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrintProcDataTypesInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_PrintProcDataTypesInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrintProcDataTypesInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrintProcDataTypesInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrintProcDataTypesInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_PrintProcDataTypesInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrintProcDataTypesInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrintProcDataTypesInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_PrintProcDataTypesInfo"); + switch (level) { + case 1: + ndr_print_spoolss_PrintProcDataTypesInfo1(ndr, "info1", &r->info1); + break; + + default: + break; + + } +} + static enum ndr_err_code ndr_push_spoolss_PrinterChangeFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); @@ -23320,28 +23521,198 @@ _PUBLIC_ void ndr_print_spoolss_DeletePrintProvidor(struct ndr_print *ndr, const ndr->depth--; } -static enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r) +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrintProcDataTypes *r) { if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); + if (r->in.servername) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.servername, ndr_charset_length(r->in.servername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.print_processor_name)); + if (r->in.print_processor_name) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.print_processor_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.print_processor_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.print_processor_name, ndr_charset_length(r->in.print_processor_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); } if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + if (r->out.needed == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.needed)); + if (r->out.count == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.count)); NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r) +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrintProcDataTypes *r) { + uint32_t _ptr_servername; + uint32_t _ptr_print_processor_name; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_servername_0; + TALLOC_CTX *_mem_save_print_processor_name_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_needed_0; + TALLOC_CTX *_mem_save_count_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->in.servername); + } else { + r->in.servername = NULL; + } + if (r->in.servername) { + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.servername, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.servername)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.servername)); + if (ndr_get_array_length(ndr, &r->in.servername) > ndr_get_array_size(ndr, &r->in.servername)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.servername), ndr_get_array_length(ndr, &r->in.servername)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.servername, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_print_processor_name)); + if (_ptr_print_processor_name) { + NDR_PULL_ALLOC(ndr, r->in.print_processor_name); + } else { + r->in.print_processor_name = NULL; + } + if (r->in.print_processor_name) { + _mem_save_print_processor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.print_processor_name, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.print_processor_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.print_processor_name)); + if (ndr_get_array_length(ndr, &r->in.print_processor_name) > ndr_get_array_size(ndr, &r->in.print_processor_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.print_processor_name), ndr_get_array_length(ndr, &r->in.print_processor_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.print_processor_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.print_processor_name, ndr_get_array_length(ndr, &r->in.print_processor_name), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_print_processor_name_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + NDR_PULL_ALLOC(ndr, r->out.needed); + ZERO_STRUCTP(r->out.needed); + NDR_PULL_ALLOC(ndr, r->out.count); + ZERO_STRUCTP(r->out.count); } if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.needed); + } + _mem_save_needed_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.needed, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.count); + } + _mem_save_count_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.count, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_count_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; } +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrintProcDataTypes *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_PrintProcDataTypesInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_PrintProcDataTypesInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrintProcDataTypes *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_PrintProcDataTypesInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_PrintProcDataTypesInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + _PUBLIC_ void ndr_print_spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrintProcDataTypes *r) { + uint32_t cntr_info_2; ndr_print_struct(ndr, name, "spoolss_EnumPrintProcDataTypes"); ndr->depth++; if (flags & NDR_SET_VALUES) { @@ -23350,11 +23721,58 @@ _PUBLIC_ void ndr_print_spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, co if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "spoolss_EnumPrintProcDataTypes"); ndr->depth++; + ndr_print_ptr(ndr, "servername", r->in.servername); + ndr->depth++; + if (r->in.servername) { + ndr_print_string(ndr, "servername", r->in.servername); + } + ndr->depth--; + ndr_print_ptr(ndr, "print_processor_name", r->in.print_processor_name); + ndr->depth++; + if (r->in.print_processor_name) { + ndr_print_string(ndr, "print_processor_name", r->in.print_processor_name); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "spoolss_EnumPrintProcDataTypes"); ndr->depth++; + ndr_print_ptr(ndr, "count", r->out.count); + ndr->depth++; + ndr_print_uint32(ndr, "count", *r->out.count); + ndr->depth--; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + ndr_print_ptr(ndr, "info", *r->out.info); + ndr->depth++; + if (*r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)*r->out.count); + ndr->depth++; + for (cntr_info_2=0;cntr_info_2<*r->out.count;cntr_info_2++) { + char *idx_2=NULL; + if (asprintf(&idx_2, "[%d]", cntr_info_2) != -1) { + ndr_print_set_switch_value(ndr, &(*r->out.info)[cntr_info_2], r->in.level); + ndr_print_spoolss_PrintProcDataTypesInfo(ndr, "info", &(*r->out.info)[cntr_info_2]); + free(idx_2); + } + } + ndr->depth--; + } + ndr->depth--; + ndr->depth--; + ndr_print_ptr(ndr, "needed", r->out.needed); + ndr->depth++; + ndr_print_uint32(ndr, "needed", *r->out.needed); + ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; } diff --git a/librpc/gen_ndr/ndr_spoolss.h b/librpc/gen_ndr/ndr_spoolss.h index e2160f142c..c45b796b60 100644 --- a/librpc/gen_ndr/ndr_spoolss.h +++ b/librpc/gen_ndr/ndr_spoolss.h @@ -323,7 +323,10 @@ enum ndr_err_code ndr_push_spoolss_DriverDirectoryInfo(struct ndr_push *ndr, int enum ndr_err_code ndr_pull_spoolss_DriverDirectoryInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverDirectoryInfo *r); void ndr_print_spoolss_DriverDirectoryInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverDirectoryInfo *r); size_t ndr_size_spoolss_DriverDirectoryInfo(const union spoolss_DriverDirectoryInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags); +enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrintProcessorInfo1 *r); +enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrintProcessorInfo1 *r); void ndr_print_spoolss_PrintProcessorInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrintProcessorInfo1 *r); +size_t ndr_size_spoolss_PrintProcessorInfo1(const struct spoolss_PrintProcessorInfo1 *r, struct smb_iconv_convenience *ic, int flags); enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrintProcessorInfo *r); enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrintProcessorInfo *r); void ndr_print_spoolss_PrintProcessorInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrintProcessorInfo *r); @@ -369,21 +372,46 @@ size_t ndr_size_spoolss_FormInfo(const union spoolss_FormInfo *r, uint32_t level void ndr_print_spoolss_AddFormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo1 *r); void ndr_print_spoolss_AddFormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo2 *r); void ndr_print_spoolss_AddFormInfo(struct ndr_print *ndr, const char *name, const union spoolss_AddFormInfo *r); +enum ndr_err_code ndr_push_spoolss_PortInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo1 *r); +enum ndr_err_code ndr_pull_spoolss_PortInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo1 *r); void ndr_print_spoolss_PortInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo1 *r); +size_t ndr_size_spoolss_PortInfo1(const struct spoolss_PortInfo1 *r, struct smb_iconv_convenience *ic, int flags); void ndr_print_spoolss_PortType(struct ndr_print *ndr, const char *name, uint32_t r); +enum ndr_err_code ndr_push_spoolss_PortInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo2 *r); +enum ndr_err_code ndr_pull_spoolss_PortInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo2 *r); void ndr_print_spoolss_PortInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo2 *r); +size_t ndr_size_spoolss_PortInfo2(const struct spoolss_PortInfo2 *r, struct smb_iconv_convenience *ic, int flags); void ndr_print_spoolss_PortStatus(struct ndr_print *ndr, const char *name, enum spoolss_PortStatus r); void ndr_print_spoolss_PortSeverity(struct ndr_print *ndr, const char *name, enum spoolss_PortSeverity r); +enum ndr_err_code ndr_push_spoolss_PortInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo3 *r); +enum ndr_err_code ndr_pull_spoolss_PortInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo3 *r); void ndr_print_spoolss_PortInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo3 *r); +size_t ndr_size_spoolss_PortInfo3(const struct spoolss_PortInfo3 *r, struct smb_iconv_convenience *ic, int flags); +enum ndr_err_code ndr_push_spoolss_PortInfoFF(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfoFF *r); +enum ndr_err_code ndr_pull_spoolss_PortInfoFF(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfoFF *r); void ndr_print_spoolss_PortInfoFF(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfoFF *r); +size_t ndr_size_spoolss_PortInfoFF(const struct spoolss_PortInfoFF *r, struct smb_iconv_convenience *ic, int flags); enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PortInfo *r); enum ndr_err_code ndr_pull_spoolss_PortInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PortInfo *r); void ndr_print_spoolss_PortInfo(struct ndr_print *ndr, const char *name, const union spoolss_PortInfo *r); +enum ndr_err_code ndr_push_spoolss_MonitorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo1 *r); +enum ndr_err_code ndr_pull_spoolss_MonitorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo1 *r); void ndr_print_spoolss_MonitorInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_MonitorInfo1 *r); +size_t ndr_size_spoolss_MonitorInfo1(const struct spoolss_MonitorInfo1 *r, struct smb_iconv_convenience *ic, int flags); +enum ndr_err_code ndr_push_spoolss_MonitorInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo2 *r); +enum ndr_err_code ndr_pull_spoolss_MonitorInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo2 *r); void ndr_print_spoolss_MonitorInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_MonitorInfo2 *r); +size_t ndr_size_spoolss_MonitorInfo2(const struct spoolss_MonitorInfo2 *r, struct smb_iconv_convenience *ic, int flags); enum ndr_err_code ndr_push_spoolss_MonitorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_MonitorInfo *r); enum ndr_err_code ndr_pull_spoolss_MonitorInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_MonitorInfo *r); void ndr_print_spoolss_MonitorInfo(struct ndr_print *ndr, const char *name, const union spoolss_MonitorInfo *r); +enum ndr_err_code ndr_push_spoolss_PrintProcDataTypesInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrintProcDataTypesInfo1 *r); +enum ndr_err_code ndr_pull_spoolss_PrintProcDataTypesInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrintProcDataTypesInfo1 *r); +void ndr_print_spoolss_PrintProcDataTypesInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrintProcDataTypesInfo1 *r); +size_t ndr_size_spoolss_PrintProcDataTypesInfo1(const struct spoolss_PrintProcDataTypesInfo1 *r, struct smb_iconv_convenience *ic, int flags); +enum ndr_err_code ndr_push_spoolss_PrintProcDataTypesInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrintProcDataTypesInfo *r); +enum ndr_err_code ndr_pull_spoolss_PrintProcDataTypesInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrintProcDataTypesInfo *r); +void ndr_print_spoolss_PrintProcDataTypesInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrintProcDataTypesInfo *r); void ndr_print_spoolss_PrinterChangeFlags(struct ndr_print *ndr, const char *name, uint32_t r); void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, enum spoolss_Field r); void ndr_print_spoolss_NotifyType(struct ndr_print *ndr, const char *name, enum spoolss_NotifyType r); @@ -547,6 +575,14 @@ void ndr_print_spoolss_DeleteMonitor(struct ndr_print *ndr, const char *name, in void ndr_print_spoolss_DeletePrintProcessor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrintProcessor *r); void ndr_print_spoolss_AddPrintProvidor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrintProvidor *r); void ndr_print_spoolss_DeletePrintProvidor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrintProvidor *r); +enum ndr_err_code ndr_push__spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrintProcDataTypes *r); +enum ndr_err_code ndr_pull__spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrintProcDataTypes *r); +void ndr_print__spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumPrintProcDataTypes *r); +enum ndr_err_code ndr_push___spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrintProcDataTypes *r); +enum ndr_err_code ndr_pull___spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrintProcDataTypes *r); +void ndr_print___spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumPrintProcDataTypes *r); +enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r); +enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r); void ndr_print_spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrintProcDataTypes *r); void ndr_print_spoolss_ResetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ResetPrinter *r); void ndr_print_spoolss_GetPrinterDriver2(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriver2 *r); diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h index 608c52b6eb..83a582efb2 100644 --- a/librpc/gen_ndr/spoolss.h +++ b/librpc/gen_ndr/spoolss.h @@ -1014,7 +1014,7 @@ union spoolss_DriverDirectoryInfo { struct spoolss_PrintProcessorInfo1 { const char * print_processor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ -}; +}/* [gensize,public] */; union spoolss_PrintProcessorInfo { struct spoolss_PrintProcessorInfo1 info1;/* [case] */ @@ -1169,7 +1169,7 @@ union spoolss_AddFormInfo { struct spoolss_PortInfo1 { const char * port_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ -}; +}/* [gensize,public] */; /* bitmap spoolss_PortType */ #define SPOOLSS_PORT_TYPE_WRITE ( 0x00000001 ) @@ -1183,7 +1183,7 @@ struct spoolss_PortInfo2 { const char * description;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ uint32_t port_type; uint32_t reserved; -}; +}/* [gensize,public] */; enum spoolss_PortStatus #ifndef USE_UINT_ENUMS @@ -1239,12 +1239,12 @@ struct spoolss_PortInfo3 { enum spoolss_PortStatus status; const char * status_string;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ enum spoolss_PortSeverity severity; -}; +}/* [gensize,public] */; struct spoolss_PortInfoFF { const char * port_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ DATA_BLOB monitor_data; -}; +}/* [gensize,public] */; union spoolss_PortInfo { struct spoolss_PortInfo1 info1;/* [case] */ @@ -1255,19 +1255,27 @@ union spoolss_PortInfo { struct spoolss_MonitorInfo1 { const char * monitor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ -}; +}/* [gensize,public] */; struct spoolss_MonitorInfo2 { const char * monitor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ const char * environment;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ const char * dll_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ -}; +}/* [gensize,public] */; union spoolss_MonitorInfo { struct spoolss_MonitorInfo1 info1;/* [case] */ struct spoolss_MonitorInfo2 info2;/* [case(2)] */ }/* [relative_base,nodiscriminant,public] */; +struct spoolss_PrintProcDataTypesInfo1 { + const char * name_array;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */ +}/* [gensize,public] */; + +union spoolss_PrintProcDataTypesInfo { + struct spoolss_PrintProcDataTypesInfo1 info1;/* [case] */ +}/* [relative_base,nodiscriminant,public] */; + /* bitmap spoolss_PrinterChangeFlags */ #define PRINTER_CHANGE_ADD_PRINTER ( 0x00000001 ) #define PRINTER_CHANGE_SET_PRINTER ( 0x00000002 ) @@ -2507,8 +2515,51 @@ struct spoolss_DeletePrintProvidor { }; +struct _spoolss_EnumPrintProcDataTypes { + struct { + const char *servername;/* [unique,charset(UTF16)] */ + const char *print_processor_name;/* [unique,charset(UTF16)] */ + uint32_t level; + DATA_BLOB *buffer;/* [unique] */ + uint32_t offered; + } in; + + struct { + DATA_BLOB *info;/* [unique] */ + uint32_t *needed;/* [ref] */ + uint32_t *count;/* [ref] */ + WERROR result; + } out; + +}; + + +struct __spoolss_EnumPrintProcDataTypes { + struct { + uint32_t level; + uint32_t count; + } in; + + struct { + union spoolss_PrintProcDataTypesInfo *info;/* [switch_is(level)] */ + } out; + +}; + + struct spoolss_EnumPrintProcDataTypes { struct { + const char *servername;/* [unique,charset(UTF16)] */ + const char *print_processor_name;/* [unique,charset(UTF16)] */ + uint32_t level; + DATA_BLOB *buffer;/* [unique] */ + uint32_t offered; + } in; + + struct { + uint32_t *count;/* [ref] */ + union spoolss_PrintProcDataTypesInfo **info;/* [ref,switch_is(level),size_is(,*count)] */ + uint32_t *needed;/* [ref] */ WERROR result; } out; diff --git a/librpc/gen_ndr/srv_spoolss.c b/librpc/gen_ndr/srv_spoolss.c index 72a9f3187b..9cb930f979 100644 --- a/librpc/gen_ndr/srv_spoolss.c +++ b/librpc/gen_ndr/srv_spoolss.c @@ -4022,6 +4022,25 @@ static bool api_spoolss_EnumPrintProcDataTypes(pipes_struct *p) NDR_PRINT_IN_DEBUG(spoolss_EnumPrintProcDataTypes, r); } + ZERO_STRUCT(r->out); + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.info = talloc_zero(r, union spoolss_PrintProcDataTypesInfo *); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + r->out.result = _spoolss_EnumPrintProcDataTypes(p, r); if (p->rng_fault_state) { @@ -8067,6 +8086,22 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, case NDR_SPOOLSS_ENUMPRINTPROCDATATYPES: { struct spoolss_EnumPrintProcDataTypes *r = (struct spoolss_EnumPrintProcDataTypes *)_r; + ZERO_STRUCT(r->out); + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.info = talloc_zero(mem_ctx, union spoolss_PrintProcDataTypesInfo *); + if (r->out.info == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.needed = talloc_zero(mem_ctx, uint32_t); + if (r->out.needed == NULL) { + return NT_STATUS_NO_MEMORY; + } + r->out.result = _spoolss_EnumPrintProcDataTypes(cli->pipes_struct, r); return NT_STATUS_OK; } diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index e1402f2afb..9765fd3969 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -1140,7 +1140,7 @@ import "misc.idl", "security.idl", "winreg.idl"; /******************/ /* Function: 0x0f */ - typedef struct { + typedef [public,gensize] struct { [relative] nstring *print_processor_name; } spoolss_PrintProcessorInfo1; @@ -1509,7 +1509,7 @@ import "misc.idl", "security.idl", "winreg.idl"; [out,ref] uint32 *needed ); - typedef struct { + typedef [public,gensize] struct { [relative] nstring *port_name; } spoolss_PortInfo1; @@ -1520,7 +1520,7 @@ import "misc.idl", "security.idl", "winreg.idl"; SPOOLSS_PORT_TYPE_NET_ATTACHED = 0x00000008 } spoolss_PortType; - typedef struct { + typedef [public,gensize] struct { [relative] nstring *port_name; [relative] nstring *monitor_name; [relative] nstring *description; @@ -1550,13 +1550,13 @@ import "misc.idl", "security.idl", "winreg.idl"; PORT_STATUS_TYPE_INFO = 0x00000003 } spoolss_PortSeverity; - typedef struct { + typedef [public,gensize] struct { spoolss_PortStatus status; [relative] nstring *status_string; spoolss_PortSeverity severity; } spoolss_PortInfo3; - typedef struct { + typedef [public,gensize] struct { [relative] nstring *port_name; DATA_BLOB monitor_data; /* relative ?? */ } spoolss_PortInfoFF; @@ -1597,11 +1597,11 @@ import "misc.idl", "security.idl", "winreg.idl"; /******************/ /* Function: 0x24 */ - typedef struct { + typedef [public,gensize] struct { [relative] nstring *monitor_name; } spoolss_MonitorInfo1; - typedef struct { + typedef [public,gensize] struct { [relative] nstring *monitor_name; [relative] nstring *environment; [relative] nstring *dll_name; @@ -1714,7 +1714,40 @@ import "misc.idl", "security.idl", "winreg.idl"; /******************/ /* Function: 0x33 */ - [todo] WERROR spoolss_EnumPrintProcDataTypes( + + typedef [public,gensize] struct { + [relative] nstring *name_array; + } spoolss_PrintProcDataTypesInfo1; + + typedef [nodiscriminant,relative_base,public] union { + [case(1)] spoolss_PrintProcDataTypesInfo1 info1; + [default]; + } spoolss_PrintProcDataTypesInfo; + + [public,noopnum,noprint] WERROR _spoolss_EnumPrintProcDataTypes( + [in,unique] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *print_processor_name, + [in] uint32 level, + [in,unique] DATA_BLOB *buffer, + [in] uint32 offered, + [out,unique] DATA_BLOB *info, + [out,ref] uint32 *needed, + [out,ref] uint32 *count + ); + [public,noopnum,noprint] void __spoolss_EnumPrintProcDataTypes( + [in] uint32 level, + [in] uint32 count, + [out,switch_is(level)] spoolss_PrintProcDataTypesInfo info[count] + ); + [nopull,nopush] WERROR spoolss_EnumPrintProcDataTypes( + [in,unique] [string,charset(UTF16)] uint16 *servername, + [in,unique] [string,charset(UTF16)] uint16 *print_processor_name, + [in] uint32 level, + [in,unique] DATA_BLOB *buffer, + [in] uint32 offered, + [out,ref] uint32 *count, + [out,ref,switch_is(level),size_is(,*count)] spoolss_PrintProcDataTypesInfo **info, + [out,ref] uint32 *needed ); /******************/ diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c index bcc2afaa6e..8fa018b112 100644 --- a/librpc/ndr/ndr_spoolss_buf.c +++ b/librpc/ndr/ndr_spoolss_buf.c @@ -405,6 +405,39 @@ uint32_t ndr_size_spoolss_EnumPrinterProcessors_info(TALLOC_CTX *mem_ctx, struct } /* + spoolss_EnumPrintProcessors +*/ +enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcDataTypes,{ + _r.in.servername = r->in.servername; + _r.in.print_processor_name = r->in.print_processor_name; + },{ + _r.in.servername = r->in.servername; + _r.in.print_processor_name = r->in.print_processor_name; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcDataTypes,{ + r->in.servername = _r.in.servername; + r->in.print_processor_name = _r.in.print_processor_name; + },{ + _r.in.servername = r->in.servername; + _r.in.print_processor_name = r->in.print_processor_name; + }); + return NDR_ERR_SUCCESS; +} + +uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, + uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info) +{ + NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcDataTypes); +} + +/* spoolss_GetPrinterData */ enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r) diff --git a/librpc/ndr/ndr_spoolss_buf.h b/librpc/ndr/ndr_spoolss_buf.h index 5ed848d7e0..352a14b731 100644 --- a/librpc/ndr/ndr_spoolss_buf.h +++ b/librpc/ndr/ndr_spoolss_buf.h @@ -33,7 +33,12 @@ uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, struct smb_icon enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r); enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r); uint32_t ndr_size_spoolss_EnumPrinterProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, - uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info); + uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info); +enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r); +enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r); +uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, + uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info); + enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r); enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r); enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r); diff --git a/packaging/RHEL/samba.spec.tmpl b/packaging/RHEL/samba.spec.tmpl index f674e8386c..94794ccfd0 100644 --- a/packaging/RHEL/samba.spec.tmpl +++ b/packaging/RHEL/samba.spec.tmpl @@ -348,6 +348,7 @@ fi %{_mandir}/man1/vfstest.1* %{_mandir}/man5/smbpasswd.5* %{_mandir}/man7/samba.7* +%{_mandir}/man7/winbind_krb5_locator.7* %{_mandir}/man8/nmbd.8* %{_mandir}/man8/pdbedit.8* %{_mandir}/man8/smbd.8* @@ -396,6 +397,7 @@ fi %{_bindir}/rpcclient %{_bindir}/smbcacls +%{_bindir}/sharesec %{_bindir}/findsmb %{_bindir}/smbcquotas %{_bindir}/nmblookup @@ -417,6 +419,7 @@ fi %{_mandir}/man1/nmblookup.1* %{_mandir}/man1/rpcclient.1* %{_mandir}/man1/smbcacls.1* +%{_mandir}/man1/sharesec.1* %{_mandir}/man1/smbclient.1* %{_mandir}/man1/smbtar.1* %{_mandir}/man1/smbtree.1* @@ -437,6 +440,7 @@ fi %attr(755,root,root) /%{_libarch}/libnss_winbind.so* %attr(755,root,root) /%{_libarch}/security/pam_winbind.so %attr(755,root,root) /%{_libarch}/security/pam_smbpass.so +/usr/share/locale/de/LC_MESSAGES/pam_winbind.mo %{_includedir}/libsmbclient.h %{_libarchdir}/libsmbclient.* @@ -464,6 +468,7 @@ fi %{_bindir}/ldbdel %{_bindir}/ldbedit %{_bindir}/ldbmodify +%{_bindir}/ldbrename %{_bindir}/ldbsearch %{_mandir}/man1/profiles.1* @@ -478,6 +483,7 @@ fi %{_mandir}/man1/ldbdel.1* %{_mandir}/man1/ldbedit.1* %{_mandir}/man1/ldbmodify.1* +%{_mandir}/man1/ldbrename.1* %{_mandir}/man1/ldbsearch.1* %changelog diff --git a/packaging/bin/fill-templates b/packaging/bin/fill-templates index 204003c53b..cbd49337ed 100755 --- a/packaging/bin/fill-templates +++ b/packaging/bin/fill-templates @@ -4,7 +4,7 @@ # information that is created by mkversion in advance. # # This is a standalone wrapper for update-pkginfo, which -# is ususally called from release-scripts/create-tarball. +# is usually called from release-scripts/create-tarball. # This allows for testing some aspects of packaging without # the need to go through all of create-tarball. # diff --git a/source3/include/client.h b/source3/include/client.h index d62d1c05d2..646d54aa05 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -104,7 +104,7 @@ struct rpc_cli_transport { uint32_t max_rdata_len, void *priv); /** - * Get the result from the read_send operation. + * Get the result from the trans_send operation. */ NTSTATUS (*trans_recv)(struct async_req *req, TALLOC_CTX *mem_ctx, uint8_t **prdata, uint32_t *prdata_len); diff --git a/source3/include/passdb.h b/source3/include/passdb.h index 93c1e3f0ab..9cbc6bd340 100644 --- a/source3/include/passdb.h +++ b/source3/include/passdb.h @@ -186,7 +186,6 @@ enum pdb_search_type { }; struct pdb_search { - TALLOC_CTX *mem_ctx; enum pdb_search_type type; struct samr_displayentry *cache; uint32 num_entries; diff --git a/source3/include/proto.h b/source3/include/proto.h index 95806d2d9d..a1cafb6837 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2427,8 +2427,8 @@ void cli_setup_packet_buf(struct cli_state *cli, char *buf); void cli_setup_packet(struct cli_state *cli); void cli_setup_bcc(struct cli_state *cli, void *p); void cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password); -void cli_setup_signing_state(struct cli_state *cli, int signing_state); struct cli_state *cli_initialise(void); +struct cli_state *cli_initialise_ex(int signing_state); void cli_nt_pipes_close(struct cli_state *cli); void cli_shutdown(struct cli_state *cli); void cli_sockopt(struct cli_state *cli, const char *options); @@ -3206,7 +3206,7 @@ bool srv_oplock_set_signing(bool onoff); bool srv_check_sign_mac(const char *inbuf, bool must_be_ok); void srv_calculate_sign_mac(char *outbuf); void srv_defer_sign_response(uint16 mid); -void srv_cancel_sign_response(uint16 mid); +void srv_cancel_sign_response(uint16 mid, bool cancel); void srv_set_signing_negotiated(void); bool srv_is_signing_active(void); bool srv_is_signing_negotiated(void); @@ -4614,14 +4614,14 @@ bool pdb_sid_to_id(const DOM_SID *sid, union unid_t *id, bool pdb_rid_algorithm(void); bool pdb_new_rid(uint32 *rid); bool initialize_password_db(bool reload, struct event_context *event_ctx); -struct pdb_search *pdb_search_init(enum pdb_search_type type); -struct pdb_search *pdb_search_users(uint32 acct_flags); -struct pdb_search *pdb_search_groups(void); -struct pdb_search *pdb_search_aliases(const DOM_SID *sid); +struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx, + enum pdb_search_type type); +struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32 acct_flags); +struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx); +struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const DOM_SID *sid); uint32 pdb_search_entries(struct pdb_search *search, uint32 start_idx, uint32 max_entries, struct samr_displayentry **result); -void pdb_search_destroy(struct pdb_search *search); bool pdb_get_trusteddom_pw(const char *domain, char** pwd, DOM_SID *sid, time_t *pass_last_set_time); bool pdb_set_trusteddom_pw(const char* domain, const char* pwd, @@ -5478,11 +5478,39 @@ WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, uint32_t offered, uint32_t *count, union spoolss_FormInfo **info); +WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + const char *environment, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PrintProcessorInfo **info); +WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + const char *print_processor_name, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PrintProcDataTypesInfo **info); +WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PortInfo **info); +WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_MonitorInfo **info); WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, char *name, uint32 flags, uint32 level, uint32 *num_printers, PRINTER_INFO_CTR *ctr); -WERROR rpccli_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - uint32 level, uint32 *num_ports, PORT_INFO_CTR *ctr); WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 level, const char *env, @@ -5807,20 +5835,12 @@ bool smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 bool smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_6 *info, int depth); bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth); -bool smb_io_port_info_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth); -bool smb_io_port_info_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth); bool smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth) ; bool smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth) ; bool smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth); bool smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth); bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth); bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth); -bool smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth); -bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth); -bool smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth); -bool smb_io_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth); -bool smb_io_printmonitor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth); -bool smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth); uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info); uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info); uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info); @@ -5836,13 +5856,7 @@ uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info); uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info); uint32 spoolss_size_job_info_1(JOB_INFO_1 *info); uint32 spoolss_size_job_info_2(JOB_INFO_2 *info); -uint32 spoolss_size_port_info_1(PORT_INFO_1 *info); -uint32 spoolss_size_port_info_2(PORT_INFO_2 *info); -uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info); -uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info); uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p); -uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info); -uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info); bool spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth); bool spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth); bool make_spoolss_q_enumprinters( @@ -5853,9 +5867,6 @@ bool make_spoolss_q_enumprinters( RPC_BUFFER *buffer, uint32 offered ); -bool make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u, - fstring servername, uint32 level, - RPC_BUFFER *buffer, uint32 offered); bool spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth); bool spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth); bool spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth); @@ -5875,15 +5886,7 @@ bool make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, uint32 level, RPC_BUFFER *buffer, uint32 offered); bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth); -bool spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth); -bool spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth); bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src); -bool spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth); -bool spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth); -bool spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth); -bool spoolss_io_q_enumprintprocdatatypes(const char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth); -bool spoolss_io_q_enumprintmonitors(const char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth); -bool spoolss_io_r_enumprintmonitors(const char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth); bool spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth); bool spoolss_io_q_enumprinterdata(const char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth); bool make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, @@ -6117,12 +6120,8 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u); WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u); WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ); -WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u); WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u); WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u); -WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u); -WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u); -WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u); WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u); WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u); WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index e101a27ca8..fdce63aba3 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -683,59 +683,6 @@ typedef struct spool_r_enumjobs } SPOOL_R_ENUMJOBS; -typedef struct s_port_info_1 -{ - UNISTR port_name; -} -PORT_INFO_1; - -typedef struct s_port_info_2 -{ - UNISTR port_name; - UNISTR monitor_name; - UNISTR description; - uint32 port_type; - uint32 reserved; -} -PORT_INFO_2; - -/* Port Type bits */ -#define PORT_TYPE_WRITE 0x0001 -#define PORT_TYPE_READ 0x0002 -#define PORT_TYPE_REDIRECTED 0x0004 -#define PORT_TYPE_NET_ATTACHED 0x0008 - -typedef struct spool_q_enumports -{ - uint32 name_ptr; - UNISTR2 name; - uint32 level; - RPC_BUFFER *buffer; - uint32 offered; -} -SPOOL_Q_ENUMPORTS; - -typedef struct port_info_ctr_info -{ - union - { - PORT_INFO_1 *info_1; - PORT_INFO_2 *info_2; - } - port; - -} -PORT_INFO_CTR; - -typedef struct spool_r_enumports -{ - RPC_BUFFER *buffer; - uint32 needed; /* bytes needed */ - uint32 returned; /* number of printers */ - WERROR status; -} -SPOOL_R_ENUMPORTS; - typedef struct job_info_info { union @@ -771,94 +718,6 @@ SPOOL_R_ENUMPRINTERDRIVERS; /********************************************/ -typedef struct spool_q_enumprintprocessors -{ - uint32 name_ptr; - UNISTR2 name; - uint32 environment_ptr; - UNISTR2 environment; - uint32 level; - RPC_BUFFER *buffer; - uint32 offered; -} -SPOOL_Q_ENUMPRINTPROCESSORS; - -typedef struct printprocessor_1 -{ - UNISTR name; -} -PRINTPROCESSOR_1; - -typedef struct spool_r_enumprintprocessors -{ - RPC_BUFFER *buffer; - uint32 needed; - uint32 returned; - WERROR status; -} -SPOOL_R_ENUMPRINTPROCESSORS; - -typedef struct spool_q_enumprintprocdatatypes -{ - uint32 name_ptr; - UNISTR2 name; - uint32 processor_ptr; - UNISTR2 processor; - uint32 level; - RPC_BUFFER *buffer; - uint32 offered; -} -SPOOL_Q_ENUMPRINTPROCDATATYPES; - -typedef struct ppdatatype_1 -{ - UNISTR name; -} -PRINTPROCDATATYPE_1; - -typedef struct spool_r_enumprintprocdatatypes -{ - RPC_BUFFER *buffer; - uint32 needed; - uint32 returned; - WERROR status; -} -SPOOL_R_ENUMPRINTPROCDATATYPES; - -typedef struct printmonitor_1 -{ - UNISTR name; -} -PRINTMONITOR_1; - -typedef struct printmonitor_2 -{ - UNISTR name; - UNISTR environment; - UNISTR dll_name; -} -PRINTMONITOR_2; - -typedef struct spool_q_enumprintmonitors -{ - uint32 name_ptr; - UNISTR2 name; - uint32 level; - RPC_BUFFER *buffer; - uint32 offered; -} -SPOOL_Q_ENUMPRINTMONITORS; - -typedef struct spool_r_enumprintmonitors -{ - RPC_BUFFER *buffer; - uint32 needed; - uint32 returned; - WERROR status; -} -SPOOL_R_ENUMPRINTMONITORS; - - typedef struct spool_q_enumprinterdata { POLICY_HND handle; diff --git a/source3/include/wbc_async.h b/source3/include/wbc_async.h index 7a8768029a..b5e769f8c3 100644 --- a/source3/include/wbc_async.h +++ b/source3/include/wbc_async.h @@ -30,7 +30,7 @@ struct wb_context { struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct wb_context *wb_ctx, bool need_priv, - const struct winbindd_request *wb_req); + struct winbindd_request *wb_req); wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, struct winbindd_response **presponse); struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx); @@ -40,29 +40,29 @@ bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err); wbcErr map_wbc_err_from_errno(int error); wbcErr async_req_simple_recv_wbcerr(struct async_req *req); -struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - int fd, size_t max_extra_data); +bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err); +wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req); -wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +struct tevent_req *wb_req_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + int fd, size_t max_extra_data); +wbcErr wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct winbindd_request **preq); -struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_request *wb_req); +struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, + struct winbindd_request *wb_req); +wbcErr wb_req_write_recv(struct tevent_req *req); -wbcErr wb_req_write_recv(struct async_req *req); - -struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd); - -wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, int fd); +wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct winbindd_response **presp); -struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_response *wb_resp); - -wbcErr wb_resp_write_recv(struct async_req *req); +struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, int fd, + struct winbindd_response *wb_resp); +wbcErr wb_resp_write_recv(struct tevent_req *req); #endif /*_WBC_ASYNC_H_*/ diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c index 9adb237096..bb09726ee0 100644 --- a/source3/lib/errmap_unix.c +++ b/source3/lib/errmap_unix.c @@ -95,6 +95,9 @@ const struct unix_error_map unix_dos_nt_errmap[] = { #ifdef ENOATTR { ENOATTR, ERRDOS, ERRbadfile, NT_STATUS_NOT_FOUND }, #endif +#ifdef ECANCELED + { ECANCELED, ERRDOS, ERRbadfid, NT_STATUS_CANCELLED}, +#endif { 0, 0, 0, NT_STATUS_OK } }; diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 4567fe457b..2535418d99 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -18,79 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* working out the interfaces for a OS is an incredibly non-portable - thing. We have several possible implementations below, and autoconf - tries each of them to see what works - - Note that this file does _not_ include includes.h. That is so this code - can be called directly from the autoconf tests. That also means - this code cannot use any of the normal Samba debug stuff or defines. - This is standalone code. - -*/ - -#ifndef AUTOCONF_TEST -#include "config.h" -#endif - -#include <unistd.h> -#include <stdio.h> -#include <sys/types.h> -#include <netdb.h> -#include <sys/ioctl.h> -#include <netdb.h> -#include <sys/ioctl.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -#ifdef HAVE_IFADDRS_H -#include <ifaddrs.h> -#endif - -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif - -#ifndef SIOCGIFCONF -#ifdef HAVE_SYS_SOCKIO_H -#include <sys/sockio.h> -#endif -#endif - -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef HAVE_STRING_H -#include <string.h> -#endif - -#ifdef HAVE_STRINGS_H -#include <strings.h> -#endif - -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif - -#ifdef HAVE_NET_IF_H -#include <net/if.h> -#endif - -#define SOCKET_WRAPPER_NOT_REPLACE -#include "interfaces.h" -#include "../replace/replace.h" - -/**************************************************************************** - Utility functions. -****************************************************************************/ +#include "includes.h" /**************************************************************************** Create a struct sockaddr_storage with the netmask bits set to 1. diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c index b31dec0438..c83eeb805d 100644 --- a/source3/lib/smbconf/testsuite.c +++ b/source3/lib/smbconf/testsuite.c @@ -214,7 +214,7 @@ static bool torture_smbconf_txt(void) printf("TEST: init\n"); werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename); if (!W_ERROR_IS_OK(werr)) { - printf("FAIL: text backend\[ failed: %s\n", win_errstr(werr)); + printf("FAIL: text backend failed: %s\n", win_errstr(werr)); ret = false; goto done; } diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 222b64667c..6ae1d1bb9b 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -25,11 +25,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -struct req_read_state { - struct winbindd_request *wb_req; - size_t max_extra_data; -}; - bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err) { enum async_req_state state; @@ -81,19 +76,60 @@ wbcErr async_req_simple_recv_wbcerr(struct async_req *req) return WBC_ERR_SUCCESS; } +bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err) +{ + enum tevent_req_state state; + uint64_t error; + if (!tevent_req_is_error(req, &state, &error)) { + *pwbc_err = WBC_ERR_SUCCESS; + return false; + } + + switch (state) { + case TEVENT_REQ_USER_ERROR: + *pwbc_err = error; + break; + case TEVENT_REQ_TIMED_OUT: + *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; + break; + case TEVENT_REQ_NO_MEMORY: + *pwbc_err = WBC_ERR_NO_MEMORY; + break; + default: + *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; + break; + } + return true; +} + +wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req) +{ + wbcErr wbc_err; + + if (tevent_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; + } + + return WBC_ERR_SUCCESS; +} + +struct req_read_state { + struct winbindd_request *wb_req; + size_t max_extra_data; +}; + static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data); static void wb_req_read_done(struct tevent_req *subreq); -struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - int fd, size_t max_extra_data) +struct tevent_req *wb_req_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + int fd, size_t max_extra_data) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct req_read_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct req_read_state)) { + result = tevent_req_create(mem_ctx, &state, struct req_read_state); + if (result == NULL) { return NULL; } state->max_extra_data = max_extra_data; @@ -139,10 +175,10 @@ static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data) static void wb_req_read_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); - struct req_read_state *state = talloc_get_type_abort( - req->private_data, struct req_read_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct req_read_state *state = tevent_req_data( + req, struct req_read_state); int err; ssize_t ret; uint8_t *buf; @@ -150,7 +186,7 @@ static void wb_req_read_done(struct tevent_req *subreq) ret = read_packet_recv(subreq, state, &buf, &err); TALLOC_FREE(subreq); if (ret == -1) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -162,17 +198,17 @@ static void wb_req_read_done(struct tevent_req *subreq) } else { state->wb_req->extra_data.data = NULL; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +wbcErr wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct winbindd_request **preq) { - struct req_read_state *state = talloc_get_type_abort( - req->private_data, struct req_read_state); + struct req_read_state *state = tevent_req_data( + req, struct req_read_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } *preq = talloc_move(mem_ctx, &state->wb_req); @@ -185,17 +221,17 @@ struct req_write_state { static void wb_req_write_done(struct tevent_req *subreq); -struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_request *wb_req) +struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, + struct winbindd_request *wb_req) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct req_write_state *state; int count = 1; - if (!async_req_setup(mem_ctx, &result, &state, - struct req_write_state)) { + result = tevent_req_create(mem_ctx, &state, struct req_write_state); + if (result == NULL) { return NULL; } @@ -208,7 +244,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, fd, state->iov, count); + subreq = writev_send(state, ev, queue, fd, state->iov, count); if (subreq == NULL) { goto fail; } @@ -222,23 +258,23 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, static void wb_req_write_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); int err; ssize_t ret; ret = writev_recv(subreq, &err); TALLOC_FREE(subreq); if (ret < 0) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_req_write_recv(struct async_req *req) +wbcErr wb_req_write_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } struct resp_read_state { @@ -248,15 +284,14 @@ struct resp_read_state { static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data); static void wb_resp_read_done(struct tevent_req *subreq); -struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd) +struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, int fd) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct resp_read_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct resp_read_state)) { + result = tevent_req_create(mem_ctx, &state, struct resp_read_state); + if (result == NULL) { return NULL; } @@ -290,10 +325,10 @@ static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data) static void wb_resp_read_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); - struct resp_read_state *state = talloc_get_type_abort( - req->private_data, struct resp_read_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct resp_read_state *state = tevent_req_data( + req, struct resp_read_state); uint8_t *buf; int err; ssize_t ret; @@ -301,7 +336,7 @@ static void wb_resp_read_done(struct tevent_req *subreq) ret = read_packet_recv(subreq, state, &buf, &err); TALLOC_FREE(subreq); if (ret == -1) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -313,17 +348,17 @@ static void wb_resp_read_done(struct tevent_req *subreq) } else { state->wb_resp->extra_data.data = NULL; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct winbindd_response **presp) { - struct resp_read_state *state = talloc_get_type_abort( - req->private_data, struct resp_read_state); + struct resp_read_state *state = tevent_req_data( + req, struct resp_read_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } *presp = talloc_move(mem_ctx, &state->wb_resp); @@ -336,17 +371,16 @@ struct resp_write_state { static void wb_resp_write_done(struct tevent_req *subreq); -struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_response *wb_resp) +struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, int fd, + struct winbindd_response *wb_resp) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct resp_write_state *state; int count = 1; - if (!async_req_setup(mem_ctx, &result, &state, - struct resp_write_state)) { + result = tevent_req_create(mem_ctx, &state, struct resp_write_state); + if (result == NULL) { return NULL; } @@ -360,7 +394,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, fd, state->iov, count); + subreq = writev_send(state, ev, NULL, fd, state->iov, count); if (subreq == NULL) { goto fail; } @@ -374,21 +408,21 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, static void wb_resp_write_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); int err; ssize_t ret; ret = writev_recv(subreq, &err); TALLOC_FREE(subreq); if (ret < 0) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_resp_write_recv(struct async_req *req) +wbcErr wb_resp_write_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 7034e668ed..80937641e6 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -153,21 +153,20 @@ struct wb_connect_state { static void wbc_connect_connected(struct tevent_req *subreq); -static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, +static struct tevent_req *wb_connect_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct wb_context *wb_ctx, const char *dir) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct wb_connect_state *state; struct sockaddr_un sunaddr; struct stat st; char *path = NULL; wbcErr wbc_err; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_connect_state)) { + result = tevent_req_create(mem_ctx, &state, struct wb_connect_state); + if (result == NULL) { return NULL; } @@ -232,59 +231,32 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, return result; - nomem: - wbc_err = WBC_ERR_NO_MEMORY; post_status: - if (async_post_error(result, ev, wbc_err)) { - return result; - } + tevent_req_error(result, wbc_err); + return tevent_req_post(result, ev); + nomem: TALLOC_FREE(result); return NULL; } static void wbc_connect_connected(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); int res, err; res = async_connect_recv(subreq, &err); TALLOC_FREE(subreq); if (res == -1) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } - async_req_done(req); -} - -static wbcErr wb_connect_recv(struct async_req *req) -{ - return async_req_simple_recv_wbcerr(req); + tevent_req_done(req); } -static struct winbindd_request *winbindd_request_copy( - TALLOC_CTX *mem_ctx, - const struct winbindd_request *req) +static wbcErr wb_connect_recv(struct tevent_req *req) { - struct winbindd_request *result; - - result = (struct winbindd_request *)TALLOC_MEMDUP( - mem_ctx, req, sizeof(struct winbindd_request)); - if (result == NULL) { - return NULL; - } - - if (result->extra_len == 0) { - return result; - } - - result->extra_data.data = (char *)TALLOC_MEMDUP( - result, result->extra_data.data, result->extra_len); - if (result->extra_data.data == NULL) { - TALLOC_FREE(result); - return NULL; - } - return result; + return tevent_req_simple_recv_wbcerr(req); } struct wb_int_trans_state { @@ -294,43 +266,40 @@ struct wb_int_trans_state { struct winbindd_response *wb_resp; }; -static void wb_int_trans_write_done(struct async_req *subreq); -static void wb_int_trans_read_done(struct async_req *subreq); +static void wb_int_trans_write_done(struct tevent_req *subreq); +static void wb_int_trans_read_done(struct tevent_req *subreq); -static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_request *wb_req) +static struct tevent_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, + struct winbindd_request *wb_req) { - struct async_req *result; - struct async_req *subreq; + struct tevent_req *result, *subreq; struct wb_int_trans_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_int_trans_state)) { + result = tevent_req_create(mem_ctx, &state, + struct wb_int_trans_state); + if (result == NULL) { return NULL; } if (winbind_closed_fd(fd)) { - if (!async_post_error(result, ev, - WBC_ERR_WINBIND_NOT_AVAILABLE)) { - goto fail; - } - return result; + tevent_req_error(result, WBC_ERR_WINBIND_NOT_AVAILABLE); + return tevent_req_post(result, ev); } state->ev = ev; state->fd = fd; state->wb_req = wb_req; - state->wb_req->length = sizeof(struct winbindd_request); state->wb_req->pid = getpid(); - subreq = wb_req_write_send(state, state->ev, state->fd, state->wb_req); + subreq = wb_req_write_send(state, state->ev, queue, state->fd, + state->wb_req); if (subreq == NULL) { goto fail; } - subreq->async.fn = wb_int_trans_write_done; - subreq->async.priv = result; + tevent_req_set_callback(subreq, wb_int_trans_write_done, result); return result; @@ -339,56 +308,55 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, return NULL; } -static void wb_int_trans_write_done(struct async_req *subreq) +static void wb_int_trans_write_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); - struct wb_int_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_int_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_int_trans_state *state = tevent_req_data( + req, struct wb_int_trans_state); wbcErr wbc_err; wbc_err = wb_req_write_recv(subreq); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } subreq = wb_resp_read_send(state, state->ev, state->fd); - if (subreq == NULL) { - async_req_error(req, WBC_ERR_NO_MEMORY); + if (tevent_req_nomem(subreq, req)) { + return; } - subreq->async.fn = wb_int_trans_read_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_int_trans_read_done, req); } -static void wb_int_trans_read_done(struct async_req *subreq) +static void wb_int_trans_read_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); - struct wb_int_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_int_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_int_trans_state *state = tevent_req_data( + req, struct wb_int_trans_state); wbcErr wbc_err; wbc_err = wb_resp_read_recv(subreq, state, &state->wb_resp); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } - async_req_done(req); + tevent_req_done(req); } -static wbcErr wb_int_trans_recv(struct async_req *req, +static wbcErr wb_int_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct winbindd_response **presponse) { - struct wb_int_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_int_trans_state); + struct wb_int_trans_state *state = tevent_req_data( + req, struct wb_int_trans_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } @@ -417,22 +385,21 @@ struct wb_open_pipe_state { struct winbindd_request wb_req; }; -static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq); -static void wb_open_pipe_ping_done(struct async_req *subreq); -static void wb_open_pipe_getpriv_done(struct async_req *subreq); -static void wb_open_pipe_connect_priv_done(struct async_req *subreq); +static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq); +static void wb_open_pipe_ping_done(struct tevent_req *subreq); +static void wb_open_pipe_getpriv_done(struct tevent_req *subreq); +static void wb_open_pipe_connect_priv_done(struct tevent_req *subreq); -static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct wb_context *wb_ctx, - bool need_priv) +static struct tevent_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct wb_context *wb_ctx, + bool need_priv) { - struct async_req *result; - struct async_req *subreq; + struct tevent_req *result, *subreq; struct wb_open_pipe_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_open_pipe_state)) { + result = tevent_req_create(mem_ctx, &state, struct wb_open_pipe_state); + if (result == NULL) { return NULL; } state->wb_ctx = wb_ctx; @@ -448,9 +415,8 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto fail; } - - subreq->async.fn = wb_open_pipe_connect_nonpriv_done; - subreq->async.priv = result; + tevent_req_set_callback(subreq, wb_open_pipe_connect_nonpriv_done, + result); return result; fail: @@ -458,81 +424,77 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, return NULL; } -static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) +static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); wbcErr wbc_err; wbc_err = wb_connect_recv(subreq); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { state->wb_ctx->is_priv = true; - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } ZERO_STRUCT(state->wb_req); state->wb_req.cmd = WINBINDD_INTERFACE_VERSION; - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } - - subreq->async.fn = wb_open_pipe_ping_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_open_pipe_ping_done, req); } -static void wb_open_pipe_ping_done(struct async_req *subreq) +static void wb_open_pipe_ping_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); struct winbindd_response *wb_resp; wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } if (!state->need_priv) { - async_req_done(req); + tevent_req_done(req); return; } state->wb_req.cmd = WINBINDD_PRIV_PIPE_DIR; - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } - - subreq->async.fn = wb_open_pipe_getpriv_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_open_pipe_getpriv_done, req); } -static void wb_open_pipe_getpriv_done(struct async_req *subreq) +static void wb_open_pipe_getpriv_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); struct winbindd_response *wb_resp = NULL; wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } @@ -540,37 +502,35 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq) state->wb_ctx->fd = -1; subreq = wb_connect_send(state, state->ev, state->wb_ctx, - (char *)wb_resp->extra_data.data); + (char *)wb_resp->extra_data.data); TALLOC_FREE(wb_resp); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } - - subreq->async.fn = wb_open_pipe_connect_priv_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_open_pipe_connect_priv_done, req); } -static void wb_open_pipe_connect_priv_done(struct async_req *subreq) +static void wb_open_pipe_connect_priv_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); wbcErr wbc_err; wbc_err = wb_connect_recv(subreq); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } state->wb_ctx->is_priv = true; - async_req_done(req); + tevent_req_done(req); } -static wbcErr wb_open_pipe_recv(struct async_req *req) +static wbcErr wb_open_pipe_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } struct wb_trans_state { @@ -583,15 +543,15 @@ struct wb_trans_state { bool need_priv; }; -static void wb_trans_connect_done(struct async_req *subreq); -static void wb_trans_done(struct async_req *subreq); +static void wb_trans_connect_done(struct tevent_req *subreq); +static void wb_trans_done(struct tevent_req *subreq); static void wb_trans_retry_wait_done(struct async_req *subreq); static void wb_trigger_trans(struct async_req *req) { struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - struct async_req *subreq; + struct tevent_req *subreq; if ((state->wb_ctx->fd == -1) || (state->need_priv && !state->wb_ctx->is_priv)) { @@ -601,23 +561,21 @@ static void wb_trigger_trans(struct async_req *req) if (async_req_nomem(subreq, req)) { return; } - subreq->async.fn = wb_trans_connect_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_trans_connect_done, req); return; } - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, state->wb_req); if (async_req_nomem(subreq, req)) { return; } - subreq->async.fn = wb_trans_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_trans_done, req); } struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct wb_context *wb_ctx, bool need_priv, - const struct winbindd_request *wb_req) + struct winbindd_request *wb_req) { struct async_req *result; struct wb_trans_state *state; @@ -628,10 +586,7 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, } state->wb_ctx = wb_ctx; state->ev = ev; - state->wb_req = winbindd_request_copy(state, wb_req); - if (state->wb_req == NULL) { - goto fail; - } + state->wb_req = wb_req; state->num_retries = 10; state->need_priv = need_priv; @@ -695,6 +650,7 @@ static void wb_trans_retry_wait_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); + struct tevent_req *subreq2; bool ret; ret = async_wait_recv(subreq); @@ -704,21 +660,21 @@ static void wb_trans_retry_wait_done(struct async_req *subreq) return; } - subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, - state->need_priv); - if (async_req_nomem(subreq, req)) { + subreq2 = wb_open_pipe_send(state, state->ev, state->wb_ctx, + state->need_priv); + if (async_req_nomem(subreq2, req)) { return; } - subreq->async.fn = wb_trans_connect_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq2, wb_trans_connect_done, req); } -static void wb_trans_connect_done(struct async_req *subreq) +static void wb_trans_connect_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); + struct tevent_req *subreq2; wbcErr wbc_err; wbc_err = wb_open_pipe_recv(subreq); @@ -728,20 +684,18 @@ static void wb_trans_connect_done(struct async_req *subreq) return; } - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, - state->wb_req); - if (async_req_nomem(subreq, req)) { + subreq2 = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, + state->wb_req); + if (async_req_nomem(subreq2, req)) { return; } - - subreq->async.fn = wb_trans_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq2, wb_trans_done, req); } -static void wb_trans_done(struct async_req *subreq) +static void wb_trans_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); wbcErr wbc_err; diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index ad11ee0ed4..ec2932488e 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -379,6 +379,7 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user, DATA_BLOB session_key = data_blob_null; NTSTATUS result; char *p; + bool ok; if (passlen == 0) { /* do nothing - guest login */ @@ -436,11 +437,7 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user, SMBsesskeygen_ntv1(nt_hash, NULL, session_key.data); #endif } -#ifdef LANMAN_ONLY - cli_simple_set_signing(cli, session_key, lm_response); -#else - cli_simple_set_signing(cli, session_key, nt_response); -#endif + cli_temp_set_signing(cli); } else { /* pre-encrypted password supplied. Only used for security=server, can't do @@ -492,6 +489,22 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user, goto end; } +#ifdef LANMAN_ONLY + ok = cli_simple_set_signing(cli, session_key, lm_response); +#else + ok = cli_simple_set_signing(cli, session_key, nt_response); +#endif + if (ok) { + /* 'resign' the last message, so we get the right sequence numbers + for checking the first reply from the server */ + cli_calculate_sign_mac(cli, cli->outbuf); + + if (!cli_check_sign_mac(cli, cli->inbuf)) { + result = NT_STATUS_ACCESS_DENIED; + goto end; + } + } + /* use the returned vuid from now on */ cli->vuid = SVAL(cli->inbuf,smb_uid); @@ -1284,10 +1297,17 @@ struct async_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx, return result; access_denied: - result = async_req_new(mem_ctx); - if (async_post_ntstatus(result, ev, NT_STATUS_ACCESS_DENIED)) { - return result; + { + struct cli_request *state; + if (!async_req_setup(mem_ctx, &result, &state, + struct cli_request)) { + goto fail; + } + if (async_post_ntstatus(result, ev, NT_STATUS_ACCESS_DENIED)) { + return result; + } } + fail: TALLOC_FREE(result); return NULL; } @@ -1936,7 +1956,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli, if (!my_name) my_name = global_myname(); - if (!(cli = cli_initialise())) { + if (!(cli = cli_initialise_ex(signing_state))) { return NT_STATUS_NO_MEMORY; } @@ -1984,8 +2004,6 @@ again: return NT_STATUS_BAD_NETWORK_NAME; } - cli_setup_signing_state(cli, signing_state); - if (flags & CLI_FULL_CONNECTION_DONT_SPNEGO) cli->use_spnego = False; else if (flags & CLI_FULL_CONNECTION_USE_KERBEROS) diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index e642f169f9..1153d8dc89 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -151,7 +151,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, zero_sockaddr(&ss); /* have to open a new connection */ - if (!(c=cli_initialise())) { + if (!(c=cli_initialise_ex(cm_creds.signing_state))) { d_printf("Connection to %s failed\n", server_n); if (c) { cli_shutdown(c); @@ -177,7 +177,6 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, c->protocol = max_protocol; c->use_kerberos = cm_creds.use_kerberos; c->fallback_after_kerberos = cm_creds.fallback_after_kerberos; - cli_setup_signing_state(c, cm_creds.signing_state); if (!cli_session_request(c, &calling, &called)) { char *p; diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 0382ef5fae..2983f7771a 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -425,33 +425,15 @@ void cli_init_creds(struct cli_state *cli, const char *username, const char *dom } /**************************************************************************** - Set the signing state (used from the command line). -****************************************************************************/ - -void cli_setup_signing_state(struct cli_state *cli, int signing_state) -{ - if (signing_state == Undefined) - return; - - if (signing_state == false) { - cli->sign_info.allow_smb_signing = false; - cli->sign_info.mandatory_signing = false; - return; - } - - cli->sign_info.allow_smb_signing = true; - - if (signing_state == Required) - cli->sign_info.mandatory_signing = true; -} - -/**************************************************************************** Initialise a client structure. Always returns a malloc'ed struct. + Set the signing state (used from the command line). ****************************************************************************/ -struct cli_state *cli_initialise(void) +struct cli_state *cli_initialise_ex(int signing_state) { struct cli_state *cli = NULL; + bool allow_smb_signing = false; + bool mandatory_signing = false; /* Check the effective uid - make sure we are not setuid */ if (is_setuid_root()) { @@ -490,12 +472,27 @@ struct cli_state *cli_initialise(void) if (getenv("CLI_FORCE_DOSERR")) cli->force_dos_errors = true; - if (lp_client_signing()) - cli->sign_info.allow_smb_signing = true; + if (lp_client_signing()) { + allow_smb_signing = true; + } + + if (lp_client_signing() == Required) { + mandatory_signing = true; + } + + if (signing_state != Undefined) { + allow_smb_signing = true; + } + + if (signing_state == false) { + allow_smb_signing = false; + mandatory_signing = false; + } + + if (signing_state == Required) { + mandatory_signing = true; + } - if (lp_client_signing() == Required) - cli->sign_info.mandatory_signing = true; - if (!cli->outbuf || !cli->inbuf) goto error; @@ -510,6 +507,8 @@ struct cli_state *cli_initialise(void) #endif /* initialise signing */ + cli->sign_info.allow_smb_signing = allow_smb_signing; + cli->sign_info.mandatory_signing = mandatory_signing; cli_null_set_signing(cli); cli->initialised = 1; @@ -526,6 +525,11 @@ struct cli_state *cli_initialise(void) return NULL; } +struct cli_state *cli_initialise(void) +{ + return cli_initialise_ex(Undefined); +} + /**************************************************************************** Close all pipes open on this session. ****************************************************************************/ diff --git a/source3/libsmb/smb_signing.c b/source3/libsmb/smb_signing.c index ea1eb05cfb..a3ed0e7572 100644 --- a/source3/libsmb/smb_signing.c +++ b/source3/libsmb/smb_signing.c @@ -3,17 +3,17 @@ SMB Signing Code Copyright (C) Jeremy Allison 2003. Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -119,14 +119,14 @@ static bool cli_set_smb_signing_common(struct cli_state *cli) if (cli->sign_info.doing_signing) { return False; } - + if (cli->sign_info.free_signing_context) cli->sign_info.free_signing_context(&cli->sign_info); /* These calls are INCOMPATIBLE with SMB signing */ cli->readbraw_supported = False; cli->writebraw_supported = False; - + return True; } @@ -196,7 +196,7 @@ static void null_free_signing_context(struct smb_sign_info *si) static bool null_set_signing(struct smb_sign_info *si) { si->signing_context = NULL; - + si->sign_outgoing_message = null_sign_outgoing_message; si->check_incoming_message = null_check_incoming_message; si->free_signing_context = null_free_signing_context; @@ -207,7 +207,7 @@ static bool null_set_signing(struct smb_sign_info *si) /** * Free the signing context */ - + static void free_signing_context(struct smb_sign_info *si) { if (si->free_signing_context) { @@ -227,7 +227,7 @@ static bool signing_good(const char *inbuf, struct smb_sign_info *si, if (!si->doing_signing) { si->doing_signing = True; } - + if (!si->seen_valid) { si->seen_valid = True; } @@ -289,7 +289,7 @@ static void simple_packet_signature(struct smb_basic_signing_context *data, /* Calculate the 16 byte MAC - but don't alter the data in the incoming packet. - + This makes for a bit of fussing about, but it's not too bad. */ MD5Init(&md5_ctx); @@ -368,7 +368,7 @@ static void client_sign_outgoing_message(char *outbuf, struct smb_sign_info *si) I can isolate the fix here rather than re-adding the trans signing on/off calls in libsmb/clitrans2.c JRA. */ - + if (store_sequence_for_reply(&data->outstanding_packet_list, SVAL(outbuf,smb_mid), data->send_seq_num + 1)) { data->send_seq_num += 2; } @@ -409,11 +409,11 @@ static bool client_check_incoming_message(const char *inbuf, server_sent_mac = (unsigned char *)&inbuf[smb_ss_field]; good = (memcmp(server_sent_mac, calc_md5_mac, 8) == 0); - + if (!good) { DEBUG(5, ("client_check_incoming_message: BAD SIG: wanted SMB signature of\n")); dump_data(5, calc_md5_mac, 8); - + DEBUG(5, ("client_check_incoming_message: BAD SIG: got SMB signature of\n")); dump_data(5, server_sent_mac, 8); #if 1 /* JRATEST */ @@ -447,7 +447,7 @@ static void simple_free_signing_context(struct smb_sign_info *si) (struct smb_basic_signing_context *)si->signing_context; struct outstanding_packet_lookup *list; struct outstanding_packet_lookup *next; - + for (list = data->outstanding_packet_list; list; list = next) { next = list->next; DLIST_REMOVE(data->outstanding_packet_list, list); @@ -486,7 +486,7 @@ bool cli_simple_set_signing(struct cli_state *cli, memset(data, '\0', sizeof(*data)); cli->sign_info.signing_context = data; - + data->mac_key = data_blob(NULL, response.length + user_session_key.length); memcpy(&data->mac_key.data[0], user_session_key.data, user_session_key.length); @@ -571,7 +571,7 @@ bool cli_temp_set_signing(struct cli_state *cli) } cli->sign_info.signing_context = NULL; - + cli->sign_info.sign_outgoing_message = temp_sign_outgoing_message; cli->sign_info.check_incoming_message = temp_check_incoming_message; cli->sign_info.free_signing_context = temp_free_signing_context; @@ -587,7 +587,7 @@ void cli_free_signing_context(struct cli_state *cli) /** * Sign a packet with the current mechanism */ - + void cli_calculate_sign_mac(struct cli_state *cli, char *buf) { cli->sign_info.sign_outgoing_message(buf, &cli->sign_info); @@ -598,7 +598,7 @@ void cli_calculate_sign_mac(struct cli_state *cli, char *buf) * @return False if we had an established signing connection * which had a bad checksum, True otherwise. */ - + bool cli_check_sign_mac(struct cli_state *cli, char *buf) { if (!cli->sign_info.check_incoming_message(buf, &cli->sign_info, True)) { @@ -746,7 +746,7 @@ static bool srv_check_incoming_message(const char *inbuf, server_sent_mac = (unsigned char *)&inbuf[smb_ss_field]; good = (memcmp(server_sent_mac, calc_md5_mac, 8) == 0); - + if (!good) { if (saved_seq) { @@ -758,7 +758,7 @@ static bool srv_check_incoming_message(const char *inbuf, (unsigned int)reply_seq_number)); dump_data(5, server_sent_mac, 8); } - + #if 1 /* JRATEST */ { int i; @@ -865,7 +865,7 @@ void srv_defer_sign_response(uint16 mid) cancelled by mid. This should never find one.... ************************************************************/ -void srv_cancel_sign_response(uint16 mid) +void srv_cancel_sign_response(uint16 mid, bool cancel) { struct smb_basic_signing_context *data; uint32 dummy_seq; @@ -884,7 +884,9 @@ void srv_cancel_sign_response(uint16 mid) ; /* cancel doesn't send a reply so doesn't burn a sequence number. */ - data->send_seq_num -= 1; + if (cancel) { + data->send_seq_num -= 1; + } } /*********************************************************** @@ -969,17 +971,17 @@ void srv_set_signing(const DATA_BLOB user_session_key, const DATA_BLOB response) if (srv_sign_info.doing_signing) { return; } - + if (srv_sign_info.free_signing_context) srv_sign_info.free_signing_context(&srv_sign_info); - + srv_sign_info.doing_signing = True; data = SMB_XMALLOC_P(struct smb_basic_signing_context); memset(data, '\0', sizeof(*data)); srv_sign_info.signing_context = data; - + data->mac_key = data_blob(NULL, response.length + user_session_key.length); memcpy(&data->mac_key.data[0], user_session_key.data, user_session_key.length); diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index e618b425e0..1909bd0da4 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -1709,24 +1709,25 @@ static NTSTATUS pdb_default_lookup_names(struct pdb_methods *methods, } #endif -struct pdb_search *pdb_search_init(enum pdb_search_type type) +static int pdb_search_destructor(struct pdb_search *search) { - TALLOC_CTX *mem_ctx; - struct pdb_search *result; - - mem_ctx = talloc_init("pdb_search"); - if (mem_ctx == NULL) { - DEBUG(0, ("talloc_init failed\n")); - return NULL; + if (!search->search_ended) { + search->search_end(search); } + return 0; +} - result = TALLOC_P(mem_ctx, struct pdb_search); +struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx, + enum pdb_search_type type) +{ + struct pdb_search *result; + + result = talloc(mem_ctx, struct pdb_search); if (result == NULL) { DEBUG(0, ("talloc failed\n")); return NULL; } - result->mem_ctx = mem_ctx; result->type = type; result->cache = NULL; result->num_entries = 0; @@ -1737,6 +1738,8 @@ struct pdb_search *pdb_search_init(enum pdb_search_type type) result->next_entry = NULL; result->search_end = NULL; + talloc_set_destructor(result, pdb_search_destructor); + return result; } @@ -1783,8 +1786,7 @@ static bool next_entry_groups(struct pdb_search *s, sid_peek_rid(&map->sid, &rid); - fill_displayentry(s->mem_ctx, rid, 0, map->nt_name, NULL, map->comment, - entry); + fill_displayentry(s, rid, 0, map->nt_name, NULL, map->comment, entry); state->current_group += 1; return True; @@ -1802,7 +1804,7 @@ static bool pdb_search_grouptype(struct pdb_search *search, { struct group_search *state; - state = TALLOC_P(search->mem_ctx, struct group_search); + state = talloc(search, struct group_search); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return False; @@ -1853,7 +1855,7 @@ static struct samr_displayentry *pdb_search_getentry(struct pdb_search *search, break; } - ADD_TO_LARGE_ARRAY(search->mem_ctx, struct samr_displayentry, + ADD_TO_LARGE_ARRAY(search, struct samr_displayentry, entry, &search->cache, &search->num_entries, &search->cache_size); } @@ -1861,52 +1863,54 @@ static struct samr_displayentry *pdb_search_getentry(struct pdb_search *search, return (search->num_entries > idx) ? &search->cache[idx] : NULL; } -struct pdb_search *pdb_search_users(uint32 acct_flags) +struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32 acct_flags) { struct pdb_methods *pdb = pdb_get_methods(); struct pdb_search *result; - result = pdb_search_init(PDB_USER_SEARCH); + result = pdb_search_init(mem_ctx, PDB_USER_SEARCH); if (result == NULL) { return NULL; } if (!pdb->search_users(pdb, result, acct_flags)) { - talloc_destroy(result->mem_ctx); + TALLOC_FREE(result); return NULL; } return result; } -struct pdb_search *pdb_search_groups(void) +struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx) { struct pdb_methods *pdb = pdb_get_methods(); struct pdb_search *result; - result = pdb_search_init(PDB_GROUP_SEARCH); + result = pdb_search_init(mem_ctx, PDB_GROUP_SEARCH); if (result == NULL) { return NULL; } if (!pdb->search_groups(pdb, result)) { - talloc_destroy(result->mem_ctx); + TALLOC_FREE(result); return NULL; } return result; } -struct pdb_search *pdb_search_aliases(const DOM_SID *sid) +struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const DOM_SID *sid) { struct pdb_methods *pdb = pdb_get_methods(); struct pdb_search *result; if (pdb == NULL) return NULL; - result = pdb_search_init(PDB_ALIAS_SEARCH); - if (result == NULL) return NULL; + result = pdb_search_init(mem_ctx, PDB_ALIAS_SEARCH); + if (result == NULL) { + return NULL; + } if (!pdb->search_aliases(pdb, result, sid)) { - talloc_destroy(result->mem_ctx); + TALLOC_FREE(result); return NULL; } return result; @@ -1935,17 +1939,6 @@ uint32 pdb_search_entries(struct pdb_search *search, return search->num_entries - start_idx; } -void pdb_search_destroy(struct pdb_search *search) -{ - if (search == NULL) - return; - - if (!search->search_ended) - search->search_end(search); - - talloc_destroy(search->mem_ctx); -} - /******************************************************************* trustdom methods *******************************************************************/ diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 70a1c62bef..77b19e3de9 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -4349,7 +4349,8 @@ static bool ldapsam_search_next_entry(struct pdb_search *search, !ldapsam_search_nextpage(search)) return False; - result = state->ldap2displayentry(state, search->mem_ctx, state->connection->ldap_struct, + result = state->ldap2displayentry(state, search, + state->connection->ldap_struct, state->current_entry, entry); if (!result) { @@ -4508,7 +4509,7 @@ static bool ldapsam_search_users(struct pdb_methods *methods, (struct ldapsam_privates *)methods->private_data; struct ldap_search_state *state; - state = TALLOC_P(search->mem_ctx, struct ldap_search_state); + state = talloc(search, struct ldap_search_state); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return False; @@ -4525,10 +4526,10 @@ static bool ldapsam_search_users(struct pdb_methods *methods, state->base = lp_ldap_suffix(); state->acct_flags = acct_flags; - state->base = talloc_strdup(search->mem_ctx, state->base); + state->base = talloc_strdup(search, state->base); state->scope = LDAP_SCOPE_SUBTREE; - state->filter = get_ldap_filter(search->mem_ctx, "*"); - state->attrs = talloc_attrs(search->mem_ctx, "uid", "sambaSid", + state->filter = get_ldap_filter(search, "*"); + state->attrs = talloc_attrs(search, "uid", "sambaSid", "displayName", "description", "sambaAcctFlags", NULL); state->attrsonly = 0; @@ -4682,7 +4683,7 @@ static bool ldapsam_search_grouptype(struct pdb_methods *methods, struct ldap_search_state *state; fstring tmp; - state = TALLOC_P(search->mem_ctx, struct ldap_search_state); + state = talloc(search, struct ldap_search_state); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return False; @@ -4690,15 +4691,14 @@ static bool ldapsam_search_grouptype(struct pdb_methods *methods, state->connection = ldap_state->smbldap_state; - state->base = talloc_strdup(search->mem_ctx, lp_ldap_group_suffix()); + state->base = talloc_strdup(search, lp_ldap_group_suffix()); state->connection = ldap_state->smbldap_state; state->scope = LDAP_SCOPE_SUBTREE; - state->filter = talloc_asprintf(search->mem_ctx, - "(&(objectclass=%s)" + state->filter = talloc_asprintf(search, "(&(objectclass=%s)" "(sambaGroupType=%d)(sambaSID=%s*))", LDAP_OBJ_GROUPMAP, type, sid_to_fstring(tmp, sid)); - state->attrs = talloc_attrs(search->mem_ctx, "cn", "sambaSid", + state->attrs = talloc_attrs(search, "cn", "sambaSid", "displayName", "description", "sambaGroupType", NULL); state->attrsonly = 0; diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index b72e0f2cba..d663c7f0b2 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -1566,11 +1566,11 @@ static bool smbpasswd_search_next_entry(struct pdb_search *search, entry->acct_flags = state->entries[state->current].acct_flags; entry->account_name = talloc_strdup( - search->mem_ctx, state->entries[state->current].account_name); + search, state->entries[state->current].account_name); entry->fullname = talloc_strdup( - search->mem_ctx, state->entries[state->current].fullname); + search, state->entries[state->current].fullname); entry->description = talloc_strdup( - search->mem_ctx, state->entries[state->current].description); + search, state->entries[state->current].description); if ((entry->account_name == NULL) || (entry->fullname == NULL) || (entry->description == NULL)) { @@ -1593,8 +1593,7 @@ static bool smbpasswd_search_users(struct pdb_methods *methods, struct smb_passwd *pwd; FILE *fp; - search_state = TALLOC_ZERO_P(search->mem_ctx, - struct smbpasswd_search_state); + search_state = talloc_zero(search, struct smbpasswd_search_state); if (search_state == NULL) { DEBUG(0, ("talloc failed\n")); return false; diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index 143a2e2390..3442561030 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -882,12 +882,9 @@ static bool tdbsam_search_next_entry(struct pdb_search *search, entry->acct_flags = pdb_get_acct_ctrl(user); entry->rid = rid; - entry->account_name = talloc_strdup( - search->mem_ctx, pdb_get_username(user)); - entry->fullname = talloc_strdup( - search->mem_ctx, pdb_get_fullname(user)); - entry->description = talloc_strdup( - search->mem_ctx, pdb_get_acct_desc(user)); + entry->account_name = talloc_strdup(search, pdb_get_username(user)); + entry->fullname = talloc_strdup(search, pdb_get_fullname(user)); + entry->description = talloc_strdup(search, pdb_get_acct_desc(user)); TALLOC_FREE(user); @@ -912,7 +909,7 @@ static bool tdbsam_search_users(struct pdb_methods *methods, return false; } - state = TALLOC_ZERO_P(search->mem_ctx, struct tdbsam_search_state); + state = talloc_zero(search, struct tdbsam_search_state); if (state == NULL) { DEBUG(0, ("talloc failed\n")); return false; diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 5e09787a9c..a83b0c53c6 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -330,6 +330,215 @@ WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, return werror; } +/********************************************************************** + convencience wrapper around rpccli_spoolss_EnumPrintProcessors +**********************************************************************/ + +WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + const char *environment, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PrintProcessorInfo **info) +{ + NTSTATUS status; + WERROR werror; + uint32_t needed; + DATA_BLOB buffer; + + if (offered > 0) { + buffer = data_blob_talloc_zero(mem_ctx, offered); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + } + + status = rpccli_spoolss_EnumPrintProcessors(cli, mem_ctx, + servername, + environment, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + + if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) { + offered = needed; + buffer = data_blob_talloc_zero(mem_ctx, needed); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + + status = rpccli_spoolss_EnumPrintProcessors(cli, mem_ctx, + servername, + environment, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + } + + return werror; +} + +/********************************************************************** + convencience wrapper around rpccli_spoolss_EnumPrintProcDataTypes +**********************************************************************/ + +WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + const char *print_processor_name, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PrintProcDataTypesInfo **info) +{ + NTSTATUS status; + WERROR werror; + uint32_t needed; + DATA_BLOB buffer; + + if (offered > 0) { + buffer = data_blob_talloc_zero(mem_ctx, offered); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + } + + status = rpccli_spoolss_EnumPrintProcDataTypes(cli, mem_ctx, + servername, + print_processor_name, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + + if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) { + offered = needed; + buffer = data_blob_talloc_zero(mem_ctx, needed); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + + status = rpccli_spoolss_EnumPrintProcDataTypes(cli, mem_ctx, + servername, + print_processor_name, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + } + + return werror; +} + +/********************************************************************** + convencience wrapper around rpccli_spoolss_EnumPorts +**********************************************************************/ + +WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PortInfo **info) +{ + NTSTATUS status; + WERROR werror; + uint32_t needed; + DATA_BLOB buffer; + + if (offered > 0) { + buffer = data_blob_talloc_zero(mem_ctx, offered); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + } + + status = rpccli_spoolss_EnumPorts(cli, mem_ctx, + servername, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + + if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) { + offered = needed; + buffer = data_blob_talloc_zero(mem_ctx, needed); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + + status = rpccli_spoolss_EnumPorts(cli, mem_ctx, + servername, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + } + + return werror; +} + +/********************************************************************** + convencience wrapper around rpccli_spoolss_EnumMonitors +**********************************************************************/ + +WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_MonitorInfo **info) +{ + NTSTATUS status; + WERROR werror; + uint32_t needed; + DATA_BLOB buffer; + + if (offered > 0) { + buffer = data_blob_talloc_zero(mem_ctx, offered); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + } + + status = rpccli_spoolss_EnumMonitors(cli, mem_ctx, + servername, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + + if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) { + offered = needed; + buffer = data_blob_talloc_zero(mem_ctx, needed); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + + status = rpccli_spoolss_EnumMonitors(cli, mem_ctx, + servername, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + } + + return werror; +} /********************************************************************* Decode various spoolss rpc's and info levels @@ -465,68 +674,6 @@ static bool decode_printer_info_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer, /********************************************************************** **********************************************************************/ -static bool decode_port_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer, - uint32 returned, PORT_INFO_1 **info) -{ - uint32 i; - PORT_INFO_1 *inf; - - if (returned) { - inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_1, returned); - if (!inf) { - return False; - } - memset(inf, 0, returned*sizeof(PORT_INFO_1)); - } else { - inf = NULL; - } - - prs_set_offset(&buffer->prs, 0); - - for (i=0; i<returned; i++) { - if (!smb_io_port_info_1("", buffer, &(inf[i]), 0)) { - return False; - } - } - - *info=inf; - return True; -} - -/********************************************************************** -**********************************************************************/ - -static bool decode_port_info_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer, - uint32 returned, PORT_INFO_2 **info) -{ - uint32 i; - PORT_INFO_2 *inf; - - if (returned) { - inf=TALLOC_ARRAY(mem_ctx, PORT_INFO_2, returned); - if (!inf) { - return False; - } - memset(inf, 0, returned*sizeof(PORT_INFO_2)); - } else { - inf = NULL; - } - - prs_set_offset(&buffer->prs, 0); - - for (i=0; i<returned; i++) { - if (!smb_io_port_info_2("", buffer, &(inf[i]), 0)) { - return False; - } - } - - *info=inf; - return True; -} - -/********************************************************************** -**********************************************************************/ - static bool decode_printer_driver_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer, uint32 returned, DRIVER_INFO_1 **info) { @@ -753,78 +900,6 @@ WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem /********************************************************************** **********************************************************************/ -WERROR rpccli_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - uint32 level, uint32 *num_ports, PORT_INFO_CTR *ctr) -{ - prs_struct qbuf, rbuf; - SPOOL_Q_ENUMPORTS in; - SPOOL_R_ENUMPORTS out; - RPC_BUFFER buffer; - fstring server; - uint32 offered; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); - strupper_m(server); - - offered = 0; - if (!rpcbuf_init(&buffer, offered, mem_ctx)) - return WERR_NOMEM; - make_spoolss_q_enumports( &in, server, level, &buffer, offered ); - - CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPORTS, - in, out, - qbuf, rbuf, - spoolss_io_q_enumports, - spoolss_io_r_enumports, - WERR_GENERAL_FAILURE ); - - if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { - offered = out.needed; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - if (!rpcbuf_init(&buffer, offered, mem_ctx)) - return WERR_NOMEM; - make_spoolss_q_enumports( &in, server, level, &buffer, offered ); - - CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPORTS, - in, out, - qbuf, rbuf, - spoolss_io_q_enumports, - spoolss_io_r_enumports, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK(out.status) ) - return out.status; - - switch (level) { - case 1: - if (!decode_port_info_1(mem_ctx, out.buffer, out.returned, &ctr->port.info_1)) { - return WERR_GENERAL_FAILURE; - } - break; - case 2: - if (!decode_port_info_2(mem_ctx, out.buffer, out.returned, &ctr->port.info_2)) { - return WERR_GENERAL_FAILURE; - } - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - *num_ports = out.returned; - - return out.status; -} - -/********************************************************************** -**********************************************************************/ - WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 level, const char *env, diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 181ad0e7d2..337121d70d 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -829,52 +829,6 @@ bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 } /******************************************************************* - Parse a PORT_INFO_1 structure. -********************************************************************/ - -bool smb_io_port_info_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - - return True; -} - -/******************************************************************* - Parse a PORT_INFO_2 structure. -********************************************************************/ - -bool smb_io_port_info_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name)) - return False; - if (!smb_io_relstr("description", buffer, depth, &info->description)) - return False; - if (!prs_uint32("port_type", ps, depth, &info->port_type)) - return False; - if (!prs_uint32("reserved", ps, depth, &info->reserved)) - return False; - - return True; -} - -/******************************************************************* Parse a DRIVER_INFO_1 structure. ********************************************************************/ @@ -1136,128 +1090,6 @@ bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, i } /******************************************************************* - Parse a PORT_INFO_1 structure. -********************************************************************/ - -bool smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if(!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - - return True; -} - -/******************************************************************* - Parse a PORT_INFO_2 structure. -********************************************************************/ - -bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if(!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name)) - return False; - if(!smb_io_relstr("description", buffer, depth, &info->description)) - return False; - if(!prs_uint32("port_type", ps, depth, &info->port_type)) - return False; - if(!prs_uint32("reserved", ps, depth, &info->reserved)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool smb_io_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool smb_io_printmonitor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("environment", buffer, depth, &info->environment)) - return False; - if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name)) - return False; - - return True; -} - -/******************************************************************* return the size required by a struct in the stream ********************************************************************/ @@ -1613,61 +1445,6 @@ uint32 spoolss_size_job_info_2(JOB_INFO_2 *info) /******************************************************************* return the size required by a struct in the stream ********************************************************************/ - -uint32 spoolss_size_port_info_1(PORT_INFO_1 *info) -{ - int size=0; - - size+=size_of_relative_string( &info->port_name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_port_info_2(PORT_INFO_2 *info) -{ - int size=0; - - size+=size_of_relative_string( &info->port_name ); - size+=size_of_relative_string( &info->monitor_name ); - size+=size_of_relative_string( &info->description ); - - size+=size_of_uint32( &info->port_type ); - size+=size_of_uint32( &info->reserved ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p) { uint32 size = 0; @@ -1685,32 +1462,6 @@ uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p) } /******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name); - size+=size_of_relative_string( &info->environment); - size+=size_of_relative_string( &info->dll_name); - - return size; -} - -/******************************************************************* * read a structure. * called from spoolss_getprinterdriver2 (srv_spoolss.c) ********************************************************************/ @@ -1808,24 +1559,6 @@ bool make_spoolss_q_enumprinters( } /******************************************************************* - * init a structure. - ********************************************************************/ - -bool make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u, - fstring servername, uint32 level, - RPC_BUFFER *buffer, uint32 offered) -{ - q_u->name_ptr = (servername != NULL) ? 1 : 0; - init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername); - - q_u->level=level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* * read a structure. * called from spoolss_enumprinters (srv_spoolss.c) ********************************************************************/ @@ -2128,68 +1861,6 @@ bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER } /******************************************************************* - Parse a SPOOL_R_ENUMPORTS structure. -********************************************************************/ - -bool spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumports"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->name,True,ps,depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* make a BUFFER5 struct from a uint16* ******************************************************************/ @@ -2216,212 +1887,6 @@ bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 /******************************************************************* ********************************************************************/ -bool spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("", ps, depth, &q_u->environment_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool spoolss_io_q_enumprintprocdatatypes(const char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr)) - return False; - if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!prs_rpcbuffer_p("buffer", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_ENUMPRINTMONITORS structure. -********************************************************************/ - -bool spoolss_io_q_enumprintmonitors(const char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -bool spoolss_io_r_enumprintmonitors(const char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - bool spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth) { prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata"); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a5d059c06a..fb7aca5c0f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1243,7 +1243,8 @@ static void np_write_trigger(struct async_req *req) req->private_data, struct np_write_state); struct tevent_req *subreq; - subreq = writev_send(state, state->ev, state->p->fd, &state->iov, 1); + subreq = writev_send(state, state->ev, NULL, state->p->fd, + &state->iov, 1); if (async_req_nomem(subreq, req)) { return; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0b8cb35a84..1128a856cd 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -319,8 +319,8 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) * enumerate stuff, so just cache 2 entries. */ - static struct disp_info builtin_dispinfo; - static struct disp_info domain_dispinfo; + static struct disp_info *builtin_dispinfo; + static struct disp_info *domain_dispinfo; /* There are two cases to consider here: 1) The SID is a domain SID and we look for an equality match, or @@ -335,18 +335,32 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) /* * Necessary only once, but it does not really hurt. */ - sid_copy(&builtin_dispinfo.sid, &global_sid_Builtin); + if (builtin_dispinfo == NULL) { + builtin_dispinfo = talloc_zero( + talloc_autofree_context(), struct disp_info); + if (builtin_dispinfo == NULL) { + return NULL; + } + } + sid_copy(&builtin_dispinfo->sid, &global_sid_Builtin); - return &builtin_dispinfo; + return builtin_dispinfo; } if (sid_check_is_domain(psid) || sid_check_is_in_our_domain(psid)) { /* * Necessary only once, but it does not really hurt. */ - sid_copy(&domain_dispinfo.sid, get_global_sam_sid()); + if (domain_dispinfo == NULL) { + domain_dispinfo = talloc_zero( + talloc_autofree_context(), struct disp_info); + if (domain_dispinfo == NULL) { + return NULL; + } + } + sid_copy(&domain_dispinfo->sid, get_global_sam_sid()); - return &domain_dispinfo; + return domain_dispinfo; } return NULL; @@ -403,32 +417,11 @@ static void free_samr_cache(DISP_INFO *disp_info) become_root(); - if (disp_info->users) { - DEBUG(10,("free_samr_cache: deleting users cache\n")); - pdb_search_destroy(disp_info->users); - disp_info->users = NULL; - } - if (disp_info->machines) { - DEBUG(10,("free_samr_cache: deleting machines cache\n")); - pdb_search_destroy(disp_info->machines); - disp_info->machines = NULL; - } - if (disp_info->groups) { - DEBUG(10,("free_samr_cache: deleting groups cache\n")); - pdb_search_destroy(disp_info->groups); - disp_info->groups = NULL; - } - if (disp_info->aliases) { - DEBUG(10,("free_samr_cache: deleting aliases cache\n")); - pdb_search_destroy(disp_info->aliases); - disp_info->aliases = NULL; - } - if (disp_info->enum_users) { - DEBUG(10,("free_samr_cache: deleting enum_users cache\n")); - pdb_search_destroy(disp_info->enum_users); - disp_info->enum_users = NULL; - } - disp_info->enum_acb_mask = 0; + TALLOC_FREE(disp_info->users); + TALLOC_FREE(disp_info->machines); + TALLOC_FREE(disp_info->groups); + TALLOC_FREE(disp_info->aliases); + TALLOC_FREE(disp_info->enum_users); unbecome_root(); } @@ -524,7 +517,7 @@ static uint32 count_sam_users(struct disp_info *info, uint32 acct_flags) } if (info->users == NULL) { - info->users = pdb_search_users(acct_flags); + info->users = pdb_search_users(info, acct_flags); if (info->users == NULL) { return 0; } @@ -548,7 +541,7 @@ static uint32 count_sam_groups(struct disp_info *info) } if (info->groups == NULL) { - info->groups = pdb_search_groups(); + info->groups = pdb_search_groups(info); if (info->groups == NULL) { return 0; } @@ -567,7 +560,7 @@ static uint32 count_sam_aliases(struct disp_info *info) struct samr_displayentry *entry; if (info->aliases == NULL) { - info->aliases = pdb_search_aliases(&info->sid); + info->aliases = pdb_search_aliases(info, &info->sid); if (info->aliases == NULL) { return 0; } @@ -1012,12 +1005,12 @@ NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, if ((info->disp_info->enum_users != NULL) && (info->disp_info->enum_acb_mask != r->in.acct_flags)) { - pdb_search_destroy(info->disp_info->enum_users); - info->disp_info->enum_users = NULL; + TALLOC_FREE(info->disp_info->enum_users); } if (info->disp_info->enum_users == NULL) { - info->disp_info->enum_users = pdb_search_users(r->in.acct_flags); + info->disp_info->enum_users = pdb_search_users( + info->disp_info, r->in.acct_flags); info->disp_info->enum_acb_mask = r->in.acct_flags; } @@ -1149,7 +1142,7 @@ NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, become_root(); if (info->disp_info->groups == NULL) { - info->disp_info->groups = pdb_search_groups(); + info->disp_info->groups = pdb_search_groups(info->disp_info); if (info->disp_info->groups == NULL) { unbecome_root(); @@ -1216,7 +1209,8 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, become_root(); if (info->disp_info->aliases == NULL) { - info->disp_info->aliases = pdb_search_aliases(&info->sid); + info->disp_info->aliases = pdb_search_aliases( + info->disp_info, &info->sid); if (info->disp_info->aliases == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -1547,7 +1541,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, case 0x1: case 0x4: if (info->disp_info->users == NULL) { - info->disp_info->users = pdb_search_users(ACB_NORMAL); + info->disp_info->users = pdb_search_users( + info->disp_info, ACB_NORMAL); if (info->disp_info->users == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -1565,8 +1560,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, break; case 0x2: if (info->disp_info->machines == NULL) { - info->disp_info->machines = - pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); + info->disp_info->machines = pdb_search_users( + info->disp_info, ACB_WSTRUST|ACB_SVRTRUST); if (info->disp_info->machines == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -1585,7 +1580,8 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, case 0x3: case 0x5: if (info->disp_info->groups == NULL) { - info->disp_info->groups = pdb_search_groups(); + info->disp_info->groups = pdb_search_groups( + info->disp_info); if (info->disp_info->groups == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -5632,7 +5628,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, switch (r->in.level) { case 1: if (info->disp_info->users == NULL) { - info->disp_info->users = pdb_search_users(ACB_NORMAL); + info->disp_info->users = pdb_search_users( + info->disp_info, ACB_NORMAL); if (info->disp_info->users == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -5651,8 +5648,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, break; case 2: if (info->disp_info->machines == NULL) { - info->disp_info->machines = - pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); + info->disp_info->machines = pdb_search_users( + info->disp_info, ACB_WSTRUST|ACB_SVRTRUST); if (info->disp_info->machines == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; @@ -5671,7 +5668,8 @@ NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, break; case 3: if (info->disp_info->groups == NULL) { - info->disp_info->groups = pdb_search_groups(); + info->disp_info->groups = pdb_search_groups( + info->disp_info); if (info->disp_info->groups == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index d665ebe244..616eb1dbf0 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -439,27 +439,7 @@ static bool api_spoolss_enumforms(pipes_struct *p) static bool api_spoolss_enumports(pipes_struct *p) { - SPOOL_Q_ENUMPORTS q_u; - SPOOL_R_ENUMPORTS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!spoolss_io_q_enumports("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n")); - return False; - } - - r_u.status = _spoolss_enumports(p, &q_u, &r_u); - - if (!spoolss_io_r_enumports("",&r_u,rdata,0)) { - DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); - return False; - } - - return True; + return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPORTS); } /**************************************************************************** @@ -577,27 +557,7 @@ static bool api_spoolss_setform(pipes_struct *p) static bool api_spoolss_enumprintprocessors(pipes_struct *p) { - SPOOL_Q_ENUMPRINTPROCESSORS q_u; - SPOOL_R_ENUMPRINTPROCESSORS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n")); - return False; - } - - r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u); - - if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) { - DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n")); - return False; - } - - return True; + return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCESSORS); } /**************************************************************************** @@ -613,27 +573,7 @@ static bool api_spoolss_addprintprocessor(pipes_struct *p) static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p) { - SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; - SPOOL_R_ENUMPRINTPROCDATATYPES r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n")); - return False; - } - - r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u); - - if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) { - DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n")); - return False; - } - - return True; + return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTPROCDATATYPES); } /**************************************************************************** @@ -641,27 +581,7 @@ static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p) static bool api_spoolss_enumprintmonitors(pipes_struct *p) { - SPOOL_Q_ENUMPRINTMONITORS q_u; - SPOOL_R_ENUMPRINTMONITORS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n")); - return False; - } - - r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u); - - if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) { - DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n")); - return False; - } - - return True; + return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMMONITORS); } /**************************************************************************** diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 77f64ae8ae..0a4f5ae05c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7446,9 +7446,14 @@ WERROR _spoolss_GetForm(pipes_struct *p, /**************************************************************************** ****************************************************************************/ -static void fill_port_1(PORT_INFO_1 *port, const char *name) +static WERROR fill_port_1(TALLOC_CTX *mem_ctx, + struct spoolss_PortInfo1 *r, + const char *name) { - init_unistr(&port->port_name, name); + r->port_name = talloc_strdup(mem_ctx, name); + W_ERROR_HAVE_NO_MEMORY(r->port_name); + + return WERR_OK; } /**************************************************************************** @@ -7456,13 +7461,23 @@ static void fill_port_1(PORT_INFO_1 *port, const char *name) somehow. ****************************************************************************/ -static void fill_port_2(PORT_INFO_2 *port, const char *name) +static WERROR fill_port_2(TALLOC_CTX *mem_ctx, + struct spoolss_PortInfo2 *r, + const char *name) { - init_unistr(&port->port_name, name); - init_unistr(&port->monitor_name, "Local Monitor"); - init_unistr(&port->description, SPL_LOCAL_PORT ); - port->port_type=PORT_TYPE_WRITE; - port->reserved=0x0; + r->port_name = talloc_strdup(mem_ctx, name); + W_ERROR_HAVE_NO_MEMORY(r->port_name); + + r->monitor_name = talloc_strdup(mem_ctx, "Local Monitor"); + W_ERROR_HAVE_NO_MEMORY(r->monitor_name); + + r->description = talloc_strdup(mem_ctx, SPL_LOCAL_PORT); /* FIXME */ + W_ERROR_HAVE_NO_MEMORY(r->description); + + r->port_type = SPOOLSS_PORT_TYPE_WRITE; + r->reserved = 0; + + return WERR_OK; } @@ -7530,9 +7545,13 @@ WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ) enumports level 1. ****************************************************************************/ -static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_1(TALLOC_CTX *mem_ctx, + union spoolss_PortInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PORT_INFO_1 *ports=NULL; + union spoolss_PortInfo *info = NULL; int i=0; WERROR result = WERR_OK; char **qlines = NULL; @@ -7540,31 +7559,31 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need result = enumports_hook(talloc_tos(), &numlines, &qlines ); if (!W_ERROR_IS_OK(result)) { - TALLOC_FREE(qlines); - return result; + goto out; } - if(numlines) { - if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { - DEBUG(10,("Returning WERR_NOMEM [%s]\n", - win_errstr(WERR_NOMEM))); - TALLOC_FREE(qlines); - return WERR_NOMEM; + if (numlines) { + info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines); + if (!info) { + DEBUG(10,("Returning WERR_NOMEM\n")); + result = WERR_NOMEM; + goto out; } for (i=0; i<numlines; i++) { DEBUG(6,("Filling port number [%d] with port [%s]\n", i, qlines[i])); - fill_port_1(&ports[i], qlines[i]); + result = fill_port_1(info, &info[i].info1, qlines[i]); + if (!W_ERROR_IS_OK(result)) { + goto out; + } } } TALLOC_FREE(qlines); - *returned = numlines; - /* check the required size. */ - for (i=0; i<*returned; i++) { + for (i=0; i<numlines; i++) { DEBUGADD(6,("adding port [%d]'s size\n", i)); - *needed += spoolss_size_port_info_1(&ports[i]); + *needed += ndr_size_spoolss_PortInfo1(&info[i].info1, NULL, 0); } if (*needed > offered) { @@ -7572,64 +7591,64 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; - } - - /* fill the buffer with the ports structures */ - for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding port [%d] to buffer\n", i)); - smb_io_port_1("", buffer, &ports[i], 0); - } - out: - SAFE_FREE(ports); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + TALLOC_FREE(qlines); + *count = 0; + *info_p = NULL; + return result; + } - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; + *info_p = info; + *count = numlines; - return result; + return WERR_OK; } /**************************************************************************** enumports level 2. ****************************************************************************/ -static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_2(TALLOC_CTX *mem_ctx, + union spoolss_PortInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PORT_INFO_2 *ports=NULL; + union spoolss_PortInfo *info = NULL; int i=0; WERROR result = WERR_OK; char **qlines = NULL; int numlines = 0; result = enumports_hook(talloc_tos(), &numlines, &qlines ); - if ( !W_ERROR_IS_OK(result)) { - TALLOC_FREE(qlines); - return result; + if (!W_ERROR_IS_OK(result)) { + goto out; } - if(numlines) { - if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { - TALLOC_FREE(qlines); - return WERR_NOMEM; + if (numlines) { + info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines); + if (!info) { + DEBUG(10,("Returning WERR_NOMEM\n")); + result = WERR_NOMEM; + goto out; } for (i=0; i<numlines; i++) { DEBUG(6,("Filling port number [%d] with port [%s]\n", i, qlines[i])); - fill_port_2(&(ports[i]), qlines[i]); + result = fill_port_2(info, &info[i].info2, qlines[i]); + if (!W_ERROR_IS_OK(result)) { + goto out; + } } } - TALLOC_FREE(qlines); - *returned = numlines; - /* check the required size. */ - for (i=0; i<*returned; i++) { + for (i=0; i<numlines; i++) { DEBUGADD(6,("adding port [%d]'s size\n", i)); - *needed += spoolss_size_port_info_2(&ports[i]); + *needed += ndr_size_spoolss_PortInfo2(&info[i].info2, NULL, 0); } if (*needed > offered) { @@ -7637,61 +7656,49 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; - } - - /* fill the buffer with the ports structures */ - for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding port [%d] to buffer\n", i)); - smb_io_port_2("", buffer, &ports[i], 0); - } - out: - SAFE_FREE(ports); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + TALLOC_FREE(qlines); + *count = 0; + *info_p = NULL; + return result; + } - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; + *info_p = info; + *count = numlines; - return result; + return WERR_OK; } -/**************************************************************************** - enumports. -****************************************************************************/ +/**************************************************************** + _spoolss_EnumPorts +****************************************************************/ -WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) +WERROR _spoolss_EnumPorts(pipes_struct *p, + struct spoolss_EnumPorts *r) { - uint32 level = q_u->level; - RPC_BUFFER *buffer = NULL; - uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; - uint32 *returned = &r_u->returned; - /* that's an [in out] buffer */ - if (!q_u->buffer && (offered!=0)) { - return WERR_INVALID_PARAM; - } - - if (offered > MAX_RPC_DATA_SIZE) { + if (!r->in.buffer && (r->in.offered != 0)) { return WERR_INVALID_PARAM; } - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + DEBUG(4,("_spoolss_EnumPorts\n")); - DEBUG(4,("_spoolss_enumports\n")); - - *returned=0; - *needed=0; + *r->out.count = 0; + *r->out.needed = 0; + *r->out.info = NULL; - switch (level) { + switch (r->in.level) { case 1: - return enumports_level_1(buffer, offered, needed, returned); + return enumports_level_1(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); case 2: - return enumports_level_2(buffer, offered, needed, returned); + return enumports_level_2(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); default: return WERR_UNKNOWN_LEVEL; } @@ -8731,69 +8738,75 @@ done: } /**************************************************************************** + fill_print_processor1 +****************************************************************************/ + +static WERROR fill_print_processor1(TALLOC_CTX *mem_ctx, + struct spoolss_PrintProcessorInfo1 *r, + const char *print_processor_name) +{ + r->print_processor_name = talloc_strdup(mem_ctx, print_processor_name); + W_ERROR_HAVE_NO_MEMORY(r->print_processor_name); + + return WERR_OK; +} + +/**************************************************************************** enumprintprocessors level 1. ****************************************************************************/ -static WERROR enumprintprocessors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocessors_level_1(TALLOC_CTX *mem_ctx, + union spoolss_PrintProcessorInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PRINTPROCESSOR_1 *info_1=NULL; - WERROR result = WERR_OK; + union spoolss_PrintProcessorInfo *info; + WERROR result; - if((info_1 = SMB_MALLOC_P(PRINTPROCESSOR_1)) == NULL) - return WERR_NOMEM; + info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcessorInfo, 1); + W_ERROR_HAVE_NO_MEMORY(info); - (*returned) = 0x1; + *count = 1; - init_unistr(&info_1->name, "winprint"); + result = fill_print_processor1(info, &info[0].info1, "winprint"); + if (!W_ERROR_IS_OK(result)) { + goto out; + } - *needed += spoolss_size_printprocessor_info_1(info_1); + *needed += ndr_size_spoolss_PrintProcessorInfo1(&info[0].info1, NULL, 0); if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; + out: + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + *count = 0; + return result; } - smb_io_printprocessor_info_1("", buffer, info_1, 0); + *info_p = info; -out: - SAFE_FREE(info_1); - - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; - - return result; + return WERR_OK; } -/**************************************************************************** -****************************************************************************/ +/**************************************************************** + _spoolss_EnumPrintProcessors +****************************************************************/ -WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) +WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, + struct spoolss_EnumPrintProcessors *r) { - uint32 level = q_u->level; - RPC_BUFFER *buffer = NULL; - uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; - uint32 *returned = &r_u->returned; - /* that's an [in out] buffer */ - if (!q_u->buffer && (offered!=0)) { - return WERR_INVALID_PARAM; - } - - if (offered > MAX_RPC_DATA_SIZE) { + if (!r->in.buffer && (r->in.offered != 0)) { return WERR_INVALID_PARAM; } - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; - - DEBUG(5,("spoolss_enumprintprocessors\n")); + DEBUG(5,("_spoolss_EnumPrintProcessors\n")); /* * Enumerate the print processors ... @@ -8802,213 +8815,261 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS * and I can use my nice printer checker. */ - *returned=0; - *needed=0; + *r->out.count = 0; + *r->out.needed = 0; + *r->out.info = NULL; - switch (level) { + switch (r->in.level) { case 1: - return enumprintprocessors_level_1(buffer, offered, needed, returned); + return enumprintprocessors_level_1(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); default: return WERR_UNKNOWN_LEVEL; } } /**************************************************************************** + fill_printprocdatatype1 +****************************************************************************/ + +static WERROR fill_printprocdatatype1(TALLOC_CTX *mem_ctx, + struct spoolss_PrintProcDataTypesInfo1 *r, + const char *name_array) +{ + r->name_array = talloc_strdup(mem_ctx, name_array); + W_ERROR_HAVE_NO_MEMORY(r->name_array); + + return WERR_OK; +} + +/**************************************************************************** enumprintprocdatatypes level 1. ****************************************************************************/ -static WERROR enumprintprocdatatypes_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocdatatypes_level_1(TALLOC_CTX *mem_ctx, + union spoolss_PrintProcDataTypesInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PRINTPROCDATATYPE_1 *info_1=NULL; - WERROR result = WERR_OK; + WERROR result; + union spoolss_PrintProcDataTypesInfo *info; - if((info_1 = SMB_MALLOC_P(PRINTPROCDATATYPE_1)) == NULL) - return WERR_NOMEM; + info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcDataTypesInfo, 1); + W_ERROR_HAVE_NO_MEMORY(info); - (*returned) = 0x1; + *count = 1; - init_unistr(&info_1->name, "RAW"); + result = fill_printprocdatatype1(info, &info[0].info1, "RAW"); + if (!W_ERROR_IS_OK(result)) { + goto out; + } - *needed += spoolss_size_printprocdatatype_info_1(info_1); + *needed += ndr_size_spoolss_PrintProcDataTypesInfo1(&info[0].info1, NULL, 0); if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; + out: + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + *count = 0; + return result; } - smb_io_printprocdatatype_info_1("", buffer, info_1, 0); + *info_p = info; -out: - SAFE_FREE(info_1); - - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; - - return result; + return WERR_OK; } -/**************************************************************************** -****************************************************************************/ +/**************************************************************** + _spoolss_EnumPrintProcDataTypes +****************************************************************/ -WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) +WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p, + struct spoolss_EnumPrintProcDataTypes *r) { - uint32 level = q_u->level; - RPC_BUFFER *buffer = NULL; - uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; - uint32 *returned = &r_u->returned; - /* that's an [in out] buffer */ - if (!q_u->buffer && (offered!=0)) { - return WERR_INVALID_PARAM; - } - - if (offered > MAX_RPC_DATA_SIZE) { + if (!r->in.buffer && (r->in.offered != 0)) { return WERR_INVALID_PARAM; } - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; - - DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); + DEBUG(5,("_spoolss_EnumPrintProcDataTypes\n")); - *returned=0; - *needed=0; + *r->out.count = 0; + *r->out.needed = 0; + *r->out.info = NULL; - switch (level) { + switch (r->in.level) { case 1: - return enumprintprocdatatypes_level_1(buffer, offered, needed, returned); + return enumprintprocdatatypes_level_1(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); default: return WERR_UNKNOWN_LEVEL; } } /**************************************************************************** + fill_monitor_1 +****************************************************************************/ + +static WERROR fill_monitor_1(TALLOC_CTX *mem_ctx, + struct spoolss_MonitorInfo1 *r, + const char *monitor_name) +{ + r->monitor_name = talloc_strdup(mem_ctx, monitor_name); + W_ERROR_HAVE_NO_MEMORY(r->monitor_name); + + return WERR_OK; +} + +/**************************************************************************** + fill_monitor_2 +****************************************************************************/ + +static WERROR fill_monitor_2(TALLOC_CTX *mem_ctx, + struct spoolss_MonitorInfo2 *r, + const char *monitor_name, + const char *environment, + const char *dll_name) +{ + r->monitor_name = talloc_strdup(mem_ctx, monitor_name); + W_ERROR_HAVE_NO_MEMORY(r->monitor_name); + r->environment = talloc_strdup(mem_ctx, environment); + W_ERROR_HAVE_NO_MEMORY(r->environment); + r->dll_name = talloc_strdup(mem_ctx, dll_name); + W_ERROR_HAVE_NO_MEMORY(r->dll_name); + + return WERR_OK; +} + +/**************************************************************************** enumprintmonitors level 1. ****************************************************************************/ -static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintmonitors_level_1(TALLOC_CTX *mem_ctx, + union spoolss_MonitorInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PRINTMONITOR_1 *info_1; + union spoolss_MonitorInfo *info; WERROR result = WERR_OK; int i; - if((info_1 = SMB_MALLOC_ARRAY(PRINTMONITOR_1, 2)) == NULL) - return WERR_NOMEM; - - *returned = 2; + info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2); + W_ERROR_HAVE_NO_MEMORY(info); - init_unistr(&(info_1[0].name), SPL_LOCAL_PORT ); - init_unistr(&(info_1[1].name), SPL_TCPIP_PORT ); + *count = 2; - for ( i=0; i<*returned; i++ ) { - *needed += spoolss_size_printmonitor_info_1(&info_1[i]); + result = fill_monitor_1(info, &info[0].info1, + SPL_LOCAL_PORT /* FIXME */); + if (!W_ERROR_IS_OK(result)) { + goto out; } - if (*needed > offered) { - result = WERR_INSUFFICIENT_BUFFER; + result = fill_monitor_1(info, &info[1].info1, + SPL_TCPIP_PORT /* FIXME */); + if (!W_ERROR_IS_OK(result)) { goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; + for (i=0; i<*count; i++) { + *needed += ndr_size_spoolss_MonitorInfo1(&info[i].info1, NULL, 0); } - for ( i=0; i<*returned; i++ ) { - smb_io_printmonitor_info_1("", buffer, &info_1[i], 0); + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; } out: - SAFE_FREE(info_1); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + *count = 0; + return result; + } - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; + *info_p = info; - return result; + return WERR_OK; } /**************************************************************************** enumprintmonitors level 2. ****************************************************************************/ -static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintmonitors_level_2(TALLOC_CTX *mem_ctx, + union spoolss_MonitorInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PRINTMONITOR_2 *info_2; + union spoolss_MonitorInfo *info; WERROR result = WERR_OK; int i; - if((info_2 = SMB_MALLOC_ARRAY(PRINTMONITOR_2, 2)) == NULL) - return WERR_NOMEM; - - *returned = 2; - - init_unistr( &(info_2[0].name), SPL_LOCAL_PORT ); - init_unistr( &(info_2[0].environment), "Windows NT X86" ); - init_unistr( &(info_2[0].dll_name), "localmon.dll" ); + info = TALLOC_ARRAY(mem_ctx, union spoolss_MonitorInfo, 2); + W_ERROR_HAVE_NO_MEMORY(info); - init_unistr( &(info_2[1].name), SPL_TCPIP_PORT ); - init_unistr( &(info_2[1].environment), "Windows NT X86" ); - init_unistr( &(info_2[1].dll_name), "tcpmon.dll" ); + *count = 2; - for ( i=0; i<*returned; i++ ) { - *needed += spoolss_size_printmonitor_info_2(&info_2[i]); + result = fill_monitor_2(info, &info[0].info2, + SPL_LOCAL_PORT, /* FIXME */ + "Windows NT X86", /* FIXME */ + "localmon.dll"); + if (!W_ERROR_IS_OK(result)) { + goto out; } - if (*needed > offered) { - result = WERR_INSUFFICIENT_BUFFER; + result = fill_monitor_2(info, &info[1].info2, + SPL_TCPIP_PORT, /* FIXME */ + "Windows NT X86", /* FIXME */ + "tcpmon.dll"); + if (!W_ERROR_IS_OK(result)) { goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; + for (i=0; i<*count; i++) { + *needed += ndr_size_spoolss_MonitorInfo2(&info[i].info2, NULL, 0); } - for ( i=0; i<*returned; i++ ) { - smb_io_printmonitor_info_2("", buffer, &info_2[i], 0); + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; } out: - SAFE_FREE(info_2); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + *count = 0; + return result; + } - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; + *info_p = info; - return result; + return WERR_OK; } -/**************************************************************************** -****************************************************************************/ +/**************************************************************** + _spoolss_EnumMonitors +****************************************************************/ -WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) +WERROR _spoolss_EnumMonitors(pipes_struct *p, + struct spoolss_EnumMonitors *r) { - uint32 level = q_u->level; - RPC_BUFFER *buffer = NULL; - uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; - uint32 *returned = &r_u->returned; - /* that's an [in out] buffer */ - if (!q_u->buffer && (offered!=0)) { - return WERR_INVALID_PARAM; - } - - if (offered > MAX_RPC_DATA_SIZE) { + if (!r->in.buffer && (r->in.offered != 0)) { return WERR_INVALID_PARAM; } - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; - - DEBUG(5,("spoolss_enumprintmonitors\n")); + DEBUG(5,("_spoolss_EnumMonitors\n")); /* * Enumerate the print monitors ... @@ -9017,14 +9078,19 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ * and I can use my nice printer checker. */ - *returned=0; - *needed=0; + *r->out.count = 0; + *r->out.needed = 0; + *r->out.info = NULL; - switch (level) { + switch (r->in.level) { case 1: - return enumprintmonitors_level_1(buffer, offered, needed, returned); + return enumprintmonitors_level_1(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); case 2: - return enumprintmonitors_level_2(buffer, offered, needed, returned); + return enumprintmonitors_level_2(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); default: return WERR_UNKNOWN_LEVEL; } @@ -10219,17 +10285,6 @@ WERROR _spoolss_GetPrinterDriver(pipes_struct *p, } /**************************************************************** - _spoolss_EnumPrintProcessors -****************************************************************/ - -WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, - struct spoolss_EnumPrintProcessors *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** _spoolss_ReadPrinter ****************************************************************/ @@ -10274,28 +10329,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p, } /**************************************************************** - _spoolss_EnumPorts -****************************************************************/ - -WERROR _spoolss_EnumPorts(pipes_struct *p, - struct spoolss_EnumPorts *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** - _spoolss_EnumMonitors -****************************************************************/ - -WERROR _spoolss_EnumMonitors(pipes_struct *p, - struct spoolss_EnumMonitors *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** _spoolss_AddPort ****************************************************************/ @@ -10450,17 +10483,6 @@ WERROR _spoolss_DeletePrintProvidor(pipes_struct *p, } /**************************************************************** - _spoolss_EnumPrintProcDataTypes -****************************************************************/ - -WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p, - struct spoolss_EnumPrintProcDataTypes *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** _spoolss_GetPrinterDriver2 ****************************************************************/ diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index fae5c552c2..6cbdf89583 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -359,55 +359,45 @@ static WERROR cmd_spoolss_enum_printers(struct rpc_pipe_client *cli, /**************************************************************************** ****************************************************************************/ -static void display_port_info_1(PORT_INFO_1 *i1) +static void display_port_info_1(struct spoolss_PortInfo1 *r) { - fstring buffer; - - rpcstr_pull(buffer, i1->port_name.buffer, sizeof(buffer), -1, STR_TERMINATE); - printf("\tPort Name:\t[%s]\n", buffer); + printf("\tPort Name:\t[%s]\n", r->port_name); } /**************************************************************************** ****************************************************************************/ -static void display_port_info_2(PORT_INFO_2 *i2) +static void display_port_info_2(struct spoolss_PortInfo2 *r) { - fstring buffer; - - rpcstr_pull(buffer, i2->port_name.buffer, sizeof(buffer), -1, STR_TERMINATE); - printf("\tPort Name:\t[%s]\n", buffer); - rpcstr_pull(buffer, i2->monitor_name.buffer, sizeof(buffer), -1, STR_TERMINATE); - - printf("\tMonitor Name:\t[%s]\n", buffer); - rpcstr_pull(buffer, i2->description.buffer, sizeof(buffer), -1, STR_TERMINATE); - - printf("\tDescription:\t[%s]\n", buffer); + printf("\tPort Name:\t[%s]\n", r->port_name); + printf("\tMonitor Name:\t[%s]\n", r->monitor_name); + printf("\tDescription:\t[%s]\n", r->description); printf("\tPort Type:\t" ); - if ( i2->port_type ) { + if (r->port_type) { int comma = 0; /* hack */ printf( "[" ); - if ( i2->port_type & PORT_TYPE_READ ) { + if (r->port_type & SPOOLSS_PORT_TYPE_READ) { printf( "Read" ); comma = 1; } - if ( i2->port_type & PORT_TYPE_WRITE ) { + if (r->port_type & SPOOLSS_PORT_TYPE_WRITE) { printf( "%sWrite", comma ? ", " : "" ); comma = 1; } /* These two have slightly different interpretations on 95/98/ME but I'm disregarding that for now */ - if ( i2->port_type & PORT_TYPE_REDIRECTED ) { + if (r->port_type & SPOOLSS_PORT_TYPE_REDIRECTED) { printf( "%sRedirected", comma ? ", " : "" ); comma = 1; } - if ( i2->port_type & PORT_TYPE_NET_ATTACHED ) { + if (r->port_type & SPOOLSS_PORT_TYPE_NET_ATTACHED) { printf( "%sNet-Attached", comma ? ", " : "" ); } printf( "]\n" ); } else { printf( "[Unset]\n" ); } - printf("\tReserved:\t[%d]\n", i2->reserved); + printf("\tReserved:\t[%d]\n", r->reserved); printf("\n"); } @@ -420,8 +410,8 @@ static WERROR cmd_spoolss_enum_ports(struct rpc_pipe_client *cli, { WERROR result; uint32 info_level = 1; - PORT_INFO_CTR ctr; uint32 returned; + union spoolss_PortInfo *info; if (argc > 2) { printf("Usage: %s [level]\n", argv[0]); @@ -433,20 +423,22 @@ static WERROR cmd_spoolss_enum_ports(struct rpc_pipe_client *cli, /* Enumerate ports */ - ZERO_STRUCT(ctr); - - result = rpccli_spoolss_enum_ports(cli, mem_ctx, info_level, &returned, &ctr); - + result = rpccli_spoolss_enumports(cli, mem_ctx, + cli->srv_name_slash, + info_level, + 0, + &returned, + &info); if (W_ERROR_IS_OK(result)) { int i; for (i = 0; i < returned; i++) { switch (info_level) { case 1: - display_port_info_1(&ctr.port.info_1[i]); + display_port_info_1(&info[i].info1); break; case 2: - display_port_info_2(&ctr.port.info_2[i]); + display_port_info_2(&info[i].info2); break; default: printf("unknown info level %d\n", info_level); @@ -3057,6 +3049,176 @@ done: return WERR_OK; } +static void display_proc_info1(struct spoolss_PrintProcessorInfo1 *r) +{ + printf("print_processor_name: %s\n", r->print_processor_name); +} + +static WERROR cmd_spoolss_enum_procs(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR werror; + const char *environment = SPOOLSS_ARCHITECTURE_NT_X86; + uint32_t num_procs, level = 1, i; + union spoolss_PrintProcessorInfo *procs; + + /* Parse the command arguments */ + + if (argc < 1 || argc > 4) { + printf ("Usage: %s [environment] [level]\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + environment = argv[1]; + } + + if (argc == 3) { + level = atoi(argv[2]); + } + + /* Enumerate Print Processors */ + + werror = rpccli_spoolss_enumprintprocessors(cli, mem_ctx, + cli->srv_name_slash, + environment, + level, + 0, + &num_procs, + &procs); + if (!W_ERROR_IS_OK(werror)) + goto done; + + /* Display output */ + + for (i = 0; i < num_procs; i++) { + switch (level) { + case 1: + display_proc_info1(&procs[i].info1); + break; + } + } + + done: + return werror; +} + +static void display_proc_data_types_info1(struct spoolss_PrintProcDataTypesInfo1 *r) +{ + printf("name_array: %s\n", r->name_array); +} + +static WERROR cmd_spoolss_enum_proc_data_types(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR werror; + const char *print_processor_name = "winprint"; + uint32_t num_procs, level = 1, i; + union spoolss_PrintProcDataTypesInfo *procs; + + /* Parse the command arguments */ + + if (argc < 1 || argc > 4) { + printf ("Usage: %s [environment] [level]\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + print_processor_name = argv[1]; + } + + if (argc == 3) { + level = atoi(argv[2]); + } + + /* Enumerate Print Processor Data Types */ + + werror = rpccli_spoolss_enumprintprocessordatatypes(cli, mem_ctx, + cli->srv_name_slash, + print_processor_name, + level, + 0, + &num_procs, + &procs); + if (!W_ERROR_IS_OK(werror)) + goto done; + + /* Display output */ + + for (i = 0; i < num_procs; i++) { + switch (level) { + case 1: + display_proc_data_types_info1(&procs[i].info1); + break; + } + } + + done: + return werror; +} + +static void display_monitor1(const struct spoolss_MonitorInfo1 *r) +{ + printf("monitor_name: %s\n", r->monitor_name); +} + +static void display_monitor2(const struct spoolss_MonitorInfo2 *r) +{ + printf("monitor_name: %s\n", r->monitor_name); + printf("environment: %s\n", r->environment); + printf("dll_name: %s\n", r->dll_name); +} + +static WERROR cmd_spoolss_enum_monitors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR werror; + uint32_t count, level = 1, i; + union spoolss_MonitorInfo *info; + + /* Parse the command arguments */ + + if (argc > 2) { + printf("Usage: %s [level]\n", argv[0]); + return WERR_OK; + } + + if (argc == 2) { + level = atoi(argv[1]); + } + + /* Enumerate Print Monitors */ + + werror = rpccli_spoolss_enummonitors(cli, mem_ctx, + cli->srv_name_slash, + level, + 0, + &count, + &info); + if (!W_ERROR_IS_OK(werror)) { + goto done; + } + + /* Display output */ + + for (i = 0; i < count; i++) { + switch (level) { + case 1: + display_monitor1(&info[i].info1); + break; + case 2: + display_monitor2(&info[i].info2); + break; + } + } + + done: + return werror; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -3092,6 +3254,9 @@ struct cmd_set spoolss_commands[] = { { "setprinterdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinterdata, &syntax_spoolss, NULL, "Set REG_SZ printer data", "" }, { "rffpcnex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_rffpcnex, &syntax_spoolss, NULL, "Rffpcnex test", "" }, { "printercmp", RPC_RTYPE_WERROR, NULL, cmd_spoolss_printercmp, &syntax_spoolss, NULL, "Printer comparison test", "" }, + { "enumprocs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_procs, &syntax_spoolss, NULL, "Enumerate Print Processors", "" }, + { "enumprocdatatypes", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_proc_data_types, &syntax_spoolss, NULL, "Enumerate Print Processor Data Types", "" }, + { "enummonitors", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_monitors, &syntax_spoolss, NULL, "Enumerate Print Monitors", "" }, { NULL } }; diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh index 842277b357..70c6d34c88 100755 --- a/source3/script/tests/test_smbtorture_s3.sh +++ b/source3/script/tests/test_smbtorture_s3.sh @@ -27,7 +27,7 @@ tests="$tests UNLINK BROWSE ATTR TRANS2 TORTURE " tests="$tests OPLOCK1 OPLOCK2 OPLOCK3" tests="$tests DIR DIR1 TCON TCONDEV RW1 RW2 RW3" tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K" -tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE" +tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE CHAIN1" skipped1="RANDOMIPC NEGNOWAIT NBENCH ERRMAPEXTRACT TRANS2SCAN NTTRANSSCAN" skipped2="DENY1 DENY2 OPENATTR CASETABLE EATEST" diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 6b19e098e5..cfa4b430eb 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -347,7 +347,7 @@ static int handle_aio_read_complete(struct aio_extra *aio_ex) /* If errno is ECANCELED then don't return anything to the * client. */ if (errno == ECANCELED) { - srv_cancel_sign_response(aio_ex->req->mid); + srv_cancel_sign_response(aio_ex->req->mid, false); return 0; } @@ -441,7 +441,7 @@ static int handle_aio_write_complete(struct aio_extra *aio_ex) /* If errno is ECANCELED then don't return anything to the * client. */ if (errno == ECANCELED) { - srv_cancel_sign_response(aio_ex->req->mid); + srv_cancel_sign_response(aio_ex->req->mid, false); return 0; } @@ -534,7 +534,7 @@ void smbd_aio_complete_mid(unsigned int mid) if (!aio_ex) { DEBUG(3,("smbd_aio_complete_mid: Can't find record to " "match mid %u.\n", mid)); - srv_cancel_sign_response(mid); + srv_cancel_sign_response(mid, false); return; } @@ -544,7 +544,7 @@ void smbd_aio_complete_mid(unsigned int mid) * ignore. */ DEBUG( 3,( "smbd_aio_complete_mid: file closed whilst " "aio outstanding (mid[%u]).\n", mid)); - srv_cancel_sign_response(mid); + srv_cancel_sign_response(mid, false); return; } diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 86a46505a2..9c7fb1914e 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -1131,7 +1131,7 @@ void reply_ntcancel(struct smb_request *req) START_PROFILE(SMBntcancel); remove_pending_change_notify_requests_by_mid(req->mid); remove_pending_lock_requests_by_mid(req->mid); - srv_cancel_sign_response(req->mid); + srv_cancel_sign_response(req->mid, true); DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", req->mid)); diff --git a/source3/utils/net.c b/source3/utils/net.c index d483198a9e..7823a98219 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -272,7 +272,7 @@ static bool search_maxrid(struct pdb_search *search, const char *type, num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries); for (i=0; i<num_entries; i++) *max_rid = MAX(*max_rid, entries[i].rid); - pdb_search_destroy(search); + TALLOC_FREE(search); return true; } @@ -280,13 +280,14 @@ static uint32 get_maxrid(void) { uint32 max_rid = 0; - if (!search_maxrid(pdb_search_users(0), "users", &max_rid)) + if (!search_maxrid(pdb_search_users(talloc_tos(), 0), "users", &max_rid)) return 0; - if (!search_maxrid(pdb_search_groups(), "groups", &max_rid)) + if (!search_maxrid(pdb_search_groups(talloc_tos()), "groups", &max_rid)) return 0; - if (!search_maxrid(pdb_search_aliases(get_global_sam_sid()), + if (!search_maxrid(pdb_search_aliases(talloc_tos(), + get_global_sam_sid()), "aliases", &max_rid)) return 0; diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index e8ebb60205..eea22c0dc2 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -1269,28 +1269,31 @@ static int net_sam_do_list(struct net_context *c, int argc, const char **argv, } } - pdb_search_destroy(search); + TALLOC_FREE(search); return 0; } static int net_sam_list_users(struct net_context *c, int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, pdb_search_users(ACB_NORMAL), + return net_sam_do_list(c, argc, argv, + pdb_search_users(talloc_tos(), ACB_NORMAL), "users"); } static int net_sam_list_groups(struct net_context *c, int argc, const char **argv) { - return net_sam_do_list(c, argc, argv, pdb_search_groups(), "groups"); + return net_sam_do_list(c, argc, argv, pdb_search_groups(talloc_tos()), + "groups"); } static int net_sam_list_localgroups(struct net_context *c, int argc, const char **argv) { return net_sam_do_list(c, argc, argv, - pdb_search_aliases(get_global_sam_sid()), + pdb_search_aliases(talloc_tos(), + get_global_sam_sid()), "localgroups"); } @@ -1298,7 +1301,8 @@ static int net_sam_list_builtin(struct net_context *c, int argc, const char **argv) { return net_sam_do_list(c, argc, argv, - pdb_search_aliases(&global_sid_Builtin), + pdb_search_aliases(talloc_tos(), + &global_sid_Builtin), "builtin"); } @@ -1306,7 +1310,7 @@ static int net_sam_list_workstations(struct net_context *c, int argc, const char **argv) { return net_sam_do_list(c, argc, argv, - pdb_search_users(ACB_WSTRUST), + pdb_search_users(talloc_tos(), ACB_WSTRUST), "workstations"); } diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 50cbc43d6d..a5bc0c9bd4 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -67,7 +67,7 @@ static int export_database (struct pdb_methods *in, DEBUG(3, ("export_database: username=\"%s\"\n", username ? username : "(NULL)")); - u_search = pdb_search_init(PDB_USER_SEARCH); + u_search = pdb_search_init(talloc_tos(), PDB_USER_SEARCH); if (u_search == NULL) { DEBUG(0, ("pdb_search_init failed\n")); return 1; @@ -75,7 +75,7 @@ static int export_database (struct pdb_methods *in, if (!in->search_users(in, u_search, 0)) { DEBUG(0, ("Could not start searching users\n")); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -116,7 +116,7 @@ static int export_database (struct pdb_methods *in, fprintf(stderr, "export_database: Memory allocation " "failure!\n"); TALLOC_FREE( user ); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -139,7 +139,7 @@ static int export_database (struct pdb_methods *in, TALLOC_FREE( user ); } - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 0; } @@ -352,7 +352,7 @@ static int print_users_list (struct pdb_methods *in, bool verbosity, bool smbpwd struct pdb_search *u_search; struct samr_displayentry userentry; - u_search = pdb_search_init(PDB_USER_SEARCH); + u_search = pdb_search_init(talloc_tos(), PDB_USER_SEARCH); if (u_search == NULL) { DEBUG(0, ("pdb_search_init failed\n")); return 1; @@ -360,7 +360,7 @@ static int print_users_list (struct pdb_methods *in, bool verbosity, bool smbpwd if (!in->search_users(in, u_search, 0)) { DEBUG(0, ("Could not start searching users\n")); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -391,7 +391,7 @@ static int print_users_list (struct pdb_methods *in, bool verbosity, bool smbpwd print_sam_info (sam_pwent, verbosity, smbpwdstyle); TALLOC_FREE(sam_pwent); } - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 0; } @@ -404,7 +404,7 @@ static int fix_users_list (struct pdb_methods *in) struct pdb_search *u_search; struct samr_displayentry userentry; - u_search = pdb_search_init(PDB_USER_SEARCH); + u_search = pdb_search_init(talloc_tos(), PDB_USER_SEARCH); if (u_search == NULL) { DEBUG(0, ("pdb_search_init failed\n")); return 1; @@ -412,7 +412,7 @@ static int fix_users_list (struct pdb_methods *in) if (!in->search_users(in, u_search, 0)) { DEBUG(0, ("Could not start searching users\n")); - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 1; } @@ -444,7 +444,7 @@ static int fix_users_list (struct pdb_methods *in) } TALLOC_FREE(sam_pwent); } - pdb_search_destroy(u_search); + TALLOC_FREE(u_search); return 0; } diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 35768fe7f2..7a53f19ffd 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -821,8 +821,6 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain, } } - cli_setup_signing_state(*cli, Undefined); - result = cli_negprot(*cli); if (!NT_STATUS_IS_OK(result)) { diff --git a/source3/winbindd/winbindd_passdb.c b/source3/winbindd/winbindd_passdb.c index d704ca0fd3..1a358b2b44 100644 --- a/source3/winbindd/winbindd_passdb.c +++ b/source3/winbindd/winbindd_passdb.c @@ -40,9 +40,9 @@ static NTSTATUS enum_groups_internal(struct winbindd_domain *domain, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; if (sidtype == SID_NAME_ALIAS) { - search = pdb_search_aliases(&domain->sid); + search = pdb_search_aliases(talloc_tos(), &domain->sid); } else { - search = pdb_search_groups(); + search = pdb_search_groups(talloc_tos()); } if (search == NULL) goto done; @@ -68,7 +68,7 @@ static NTSTATUS enum_groups_internal(struct winbindd_domain *domain, result = NT_STATUS_OK; done: - pdb_search_destroy(search); + TALLOC_FREE(search); return result; } @@ -456,7 +456,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, uint32 *num_entries, WINBIND_USERINFO **info) { - struct pdb_search *ps = pdb_search_users(ACB_NORMAL); + struct pdb_search *ps = pdb_search_users(talloc_tos(), ACB_NORMAL); struct samr_displayentry *entries = NULL; uint32 i; @@ -473,7 +473,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, *info = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries); if (!(*info)) { - pdb_search_destroy(ps); + TALLOC_FREE(ps); return NT_STATUS_NO_MEMORY; } @@ -498,7 +498,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, DOMAIN_GROUP_RID_USERS); } - pdb_search_destroy(ps); + TALLOC_FREE(ps); return NT_STATUS_OK; } diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index aec7422571..61c8009716 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -1001,7 +1001,7 @@ static WERROR dcesrv_spoolss_DeletePrintProvidor(struct dcesrv_call_state *dce_c static WERROR dcesrv_spoolss_EnumPrintProcDataTypes(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrintProcDataTypes *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + return WERR_OK; } diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 39e6cff274..821db06414 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -291,7 +291,7 @@ if test x"${PIDL_TESTS_SKIP}" = x"yes"; then echo "Skipping pidl tests - PIDL_TESTS_SKIP=yes" elif $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then for f in $samba4srcdir/../pidl/tests/*.pl; do - plantest "pidl.`basename $f .pl`" none $PERL $f "|" $samba4srcdir/../lib/subunit/harness2subunit.pl + plantest "pidl.`basename $f .pl`" none $PERL $f "|" $PERL $samba4srcdir/../lib/subunit/harness2subunit.pl done else echo "Skipping pidl tests - Test::More not installed" diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 64b698a402..ad8158d956 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -568,6 +568,57 @@ static bool test_EnumPrintProcessors(struct torture_context *tctx, return true; } +static bool test_EnumPrintProcDataTypes(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) +{ + NTSTATUS status; + struct spoolss_EnumPrintProcDataTypes r; + uint16_t levels[] = { 1 }; + int i, j; + + for (i=0;i<ARRAY_SIZE(levels);i++) { + int level = levels[i]; + DATA_BLOB blob; + uint32_t needed; + uint32_t count; + union spoolss_PrintProcDataTypesInfo *info; + + r.in.servername = ""; + r.in.print_processor_name = "winprint"; + r.in.level = level; + r.in.buffer = NULL; + r.in.offered = 0; + r.out.needed = &needed; + r.out.count = &count; + r.out.info = &info; + + torture_comment(tctx, "Testing EnumPrintProcDataTypes level %u\n", r.in.level); + + status = dcerpc_spoolss_EnumPrintProcDataTypes(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcDataType failed"); + if (W_ERROR_IS_OK(r.out.result)) { + /* TODO: do some more checks here */ + continue; + } + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "EnumPrintProcDataTypes unexpected return code"); + + blob = data_blob_talloc(ctx, NULL, needed); + data_blob_clear(&blob); + r.in.buffer = &blob; + r.in.offered = needed; + + status = dcerpc_spoolss_EnumPrintProcDataTypes(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcDataTypes failed"); + + torture_assert_werr_ok(tctx, r.out.result, "EnumPrintProcDataTypes failed"); + } + + return true; +} + + static bool test_EnumPrinters(struct torture_context *tctx, struct dcerpc_pipe *p, struct test_spoolss_context *ctx) @@ -1951,6 +2002,7 @@ bool torture_rpc_spoolss(struct torture_context *torture) ret &= test_EnumPrinterDrivers(torture, p, ctx); ret &= test_EnumMonitors(torture, p, ctx); ret &= test_EnumPrintProcessors(torture, p, ctx); + ret &= test_EnumPrintProcDataTypes(torture, p, ctx); ret &= test_EnumPrinters(torture, p, ctx); ret &= test_OpenPrinter_badname(torture, p, "__INVALID_PRINTER__"); ret &= test_OpenPrinter_badname(torture, p, "\\\\__INVALID_HOST__"); |