summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/client.h2
-rw-r--r--source3/include/passdb.h1
-rw-r--r--source3/include/proto.h75
-rw-r--r--source3/include/rpc_spoolss.h141
-rw-r--r--source3/include/wbc_async.h38
-rw-r--r--source3/lib/errmap_unix.c3
-rw-r--r--source3/lib/interfaces.c74
-rw-r--r--source3/lib/smbconf/testsuite.c2
-rw-r--r--source3/lib/wb_reqtrans.c166
-rw-r--r--source3/lib/wbclient.c290
-rw-r--r--source3/libsmb/cliconnect.c40
-rw-r--r--source3/libsmb/clidfs.c3
-rw-r--r--source3/libsmb/clientgen.c58
-rw-r--r--source3/libsmb/smb_signing.c50
-rw-r--r--source3/passdb/pdb_interface.c63
-rw-r--r--source3/passdb/pdb_ldap.c20
-rw-r--r--source3/passdb/pdb_smbpasswd.c9
-rw-r--r--source3/passdb/pdb_tdb.c11
-rw-r--r--source3/rpc_client/cli_spoolss.c343
-rw-r--r--source3/rpc_parse/parse_spoolss.c535
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c3
-rw-r--r--source3/rpc_server/srv_samr_nt.c94
-rw-r--r--source3/rpc_server/srv_spoolss.c88
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c598
-rw-r--r--source3/rpcclient/cmd_spoolss.c223
-rwxr-xr-xsource3/script/tests/test_smbtorture_s3.sh2
-rw-r--r--source3/smbd/aio.c8
-rw-r--r--source3/smbd/nttrans.c2
-rw-r--r--source3/utils/net.c9
-rw-r--r--source3/utils/net_sam.c16
-rw-r--r--source3/utils/pdbedit.c20
-rw-r--r--source3/winbindd/winbindd_cm.c2
-rw-r--r--source3/winbindd/winbindd_passdb.c12
33 files changed, 1219 insertions, 1782 deletions
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;
}