summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/client/clitar.c16
-rw-r--r--source3/include/passdb.h1
-rw-r--r--source3/include/proto.h101
-rw-r--r--source3/include/rpc_spoolss.h176
-rw-r--r--source3/lib/errmap_unix.c3
-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/locking/locking.c19
-rw-r--r--source3/modules/onefs_open.c113
-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.c480
-rw-r--r--source3/rpc_parse/parse_spoolss.c661
-rw-r--r--source3/rpc_server/srv_pipe.c6
-rw-r--r--source3/rpc_server/srv_samr_nt.c94
-rw-r--r--source3/rpc_server/srv_spoolss.c110
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c726
-rw-r--r--source3/rpcclient/cmd_spoolss.c284
-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/smbd/open.c34
-rw-r--r--source3/utils/net.c9
-rw-r--r--source3/utils/net_rpc_printer.c44
-rw-r--r--source3/utils/net_sam.c16
-rw-r--r--source3/utils/pdbedit.c20
-rw-r--r--source3/winbindd/winbindd.c2
-rw-r--r--source3/winbindd/winbindd_cm.c2
-rw-r--r--source3/winbindd/winbindd_passdb.c12
33 files changed, 1186 insertions, 2009 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 18edf037e2..c9f3e87c4d 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -1513,6 +1513,7 @@ int process_tar(void)
if (strrchr_m(cliplist[i], '\\')) {
char *p;
+ char saved_char;
char *saved_dir = talloc_strdup(ctx,
client_get_cur_dir());
if (!saved_dir) {
@@ -1531,13 +1532,28 @@ int process_tar(void)
if (!tarmac) {
return 1;
}
+ /*
+ * Strip off the last \\xxx
+ * xxx element of tarmac to set
+ * it as current directory.
+ */
p = strrchr_m(tarmac, '\\');
if (!p) {
return 1;
}
+ saved_char = p[1];
p[1] = '\0';
+
client_set_cur_dir(tarmac);
+ /*
+ * Restore the character we
+ * just replaced to
+ * put the pathname
+ * back as it was.
+ */
+ p[1] = saved_char;
+
DEBUG(5, ("process_tar, do_list with tarmac: %s\n", tarmac));
do_list(tarmac,attribute,do_tar, False, True);
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 78110161c5..b6ddacca75 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2430,8 +2430,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);
@@ -3209,7 +3209,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);
@@ -3484,9 +3484,9 @@ bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close,
uint32 dosmode);
-void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok);
-void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, UNIX_USER_TOKEN *tok);
-bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKEN *tok);
+void set_delete_on_close_token(struct share_mode_lock *lck, const UNIX_USER_TOKEN *tok);
+void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, const UNIX_USER_TOKEN *tok);
+bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const UNIX_USER_TOKEN *tok);
bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
bool set_write_time(struct file_id fileid, struct timespec write_time);
int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
@@ -4617,14 +4617,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,
@@ -5474,19 +5474,51 @@ WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
uint32_t level,
uint32_t offered,
union spoolss_JobInfo *info);
+WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t level,
+ 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,
uint32 *num_drivers,
PRINTER_DRIVER_CTR *ctr);
-WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *handle, int level, uint32 *num_forms,
- FORM_1 **forms);
WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, uint32 level, uint32 firstjob,
uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr);
@@ -5806,21 +5838,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_form_1(const char *desc, RPC_BUFFER *buffer, FORM_1 *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,14 +5859,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_form_1(FORM_1 *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(
@@ -5854,9 +5870,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);
@@ -5876,17 +5889,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_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_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,
@@ -5917,9 +5920,6 @@ bool spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u,
bool spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth);
-bool make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
- uint32 level, RPC_BUFFER *buffer,
- uint32 offered);
/* The following definitions come from rpc_server/srv_eventlog_lib.c */
@@ -6122,14 +6122,9 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer);
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 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *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);
@@ -6723,6 +6718,8 @@ void msg_file_was_renamed(struct messaging_context *msg,
struct case_semantics_state;
struct case_semantics_state *set_posix_case_semantics(TALLOC_CTX *mem_ctx,
connection_struct *conn);
+NTSTATUS open_streams_for_delete(connection_struct *conn,
+ const char *fname);
NTSTATUS create_file_default(connection_struct *conn,
struct smb_request *req,
uint16_t root_dir_fid,
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 2b4a036ce8..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
@@ -769,131 +716,8 @@ typedef struct spool_r_enumprinterdrivers
}
SPOOL_R_ENUMPRINTERDRIVERS;
-#define FORM_USER 0
-#define FORM_BUILTIN 1
-#define FORM_PRINTER 2
-
-typedef struct spool_form_1
-{
- uint32 flag;
- UNISTR name;
- uint32 width;
- uint32 length;
- uint32 left;
- uint32 top;
- uint32 right;
- uint32 bottom;
-}
-FORM_1;
-
-typedef struct spool_q_enumforms
-{
- POLICY_HND handle;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
-}
-SPOOL_Q_ENUMFORMS;
-
-typedef struct spool_r_enumforms
-{
- RPC_BUFFER *buffer;
- uint32 needed;
- uint32 numofforms;
- WERROR status;
-}
-SPOOL_R_ENUMFORMS;
-
/********************************************/
-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/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/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/locking/locking.c b/source3/locking/locking.c
index 1737eab1c6..e9a5f757e5 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1295,7 +1295,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close,
(Should this be in locking.c.... ?).
*************************************************************************/
-static UNIX_USER_TOKEN *copy_unix_token(TALLOC_CTX *ctx, UNIX_USER_TOKEN *tok)
+static UNIX_USER_TOKEN *copy_unix_token(TALLOC_CTX *ctx, const UNIX_USER_TOKEN *tok)
{
UNIX_USER_TOKEN *cpy;
@@ -1326,7 +1326,7 @@ static UNIX_USER_TOKEN *copy_unix_token(TALLOC_CTX *ctx, UNIX_USER_TOKEN *tok)
Replace the delete on close token.
****************************************************************************/
-void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok)
+void set_delete_on_close_token(struct share_mode_lock *lck, const UNIX_USER_TOKEN *tok)
{
TALLOC_FREE(lck->delete_token); /* Also deletes groups... */
@@ -1346,7 +1346,7 @@ void set_delete_on_close_token(struct share_mode_lock *lck, UNIX_USER_TOKEN *tok
lck entry. This function is used when the lock is already granted.
****************************************************************************/
-void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, UNIX_USER_TOKEN *tok)
+void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, const UNIX_USER_TOKEN *tok)
{
if (lck->delete_on_close != delete_on_close) {
set_delete_on_close_token(lck, tok);
@@ -1358,8 +1358,9 @@ void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close,
}
}
-bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKEN *tok)
+bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const UNIX_USER_TOKEN *tok)
{
+ UNIX_USER_TOKEN *tok_copy = NULL;
struct share_mode_lock *lck;
DEBUG(10,("set_delete_on_close: %s delete on close flag for "
@@ -1373,6 +1374,16 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close, UNIX_USER_TOKE
return False;
}
+ if (fsp->conn->admin_user) {
+ tok_copy = copy_unix_token(lck, tok);
+ tok_copy->uid = (uid_t)0;
+ if (tok_copy == NULL) {
+ TALLOC_FREE(lck);
+ return false;
+ }
+ tok = tok_copy;
+ }
+
set_delete_on_close_lck(lck, delete_on_close, tok);
if (fsp->is_directory) {
diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c
index d3ba0ac979..c5030f4ab8 100644
--- a/source3/modules/onefs_open.c
+++ b/source3/modules/onefs_open.c
@@ -1649,119 +1649,6 @@ static NTSTATUS onefs_open_directory(connection_struct *conn,
}
/*
- * If a main file is opened for delete, all streams need to be checked for
- * !FILE_SHARE_DELETE. Do this by opening with DELETE_ACCESS.
- * If that works, delete them all by setting the delete on close and close.
- */
-
-static NTSTATUS open_streams_for_delete(connection_struct *conn,
- const char *fname)
-{
- struct stream_struct *stream_info;
- files_struct **streams;
- int i;
- unsigned int num_streams;
- TALLOC_CTX *frame = talloc_stackframe();
- NTSTATUS status;
-
- status = SMB_VFS_STREAMINFO(conn, NULL, fname, talloc_tos(),
- &num_streams, &stream_info);
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)
- || NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
- DEBUG(10, ("no streams around\n"));
- TALLOC_FREE(frame);
- return NT_STATUS_OK;
- }
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10, ("SMB_VFS_STREAMINFO failed: %s\n",
- nt_errstr(status)));
- goto fail;
- }
-
- DEBUG(10, ("open_streams_for_delete found %d streams\n",
- num_streams));
-
- if (num_streams == 0) {
- TALLOC_FREE(frame);
- return NT_STATUS_OK;
- }
-
- streams = TALLOC_ARRAY(talloc_tos(), files_struct *, num_streams);
- if (streams == NULL) {
- DEBUG(0, ("talloc failed\n"));
- status = NT_STATUS_NO_MEMORY;
- goto fail;
- }
-
- /* Open the base file */
-
- for (i=0; i<num_streams; i++) {
- char *streamname;
-
- if (strequal(stream_info[i].name, "::$DATA")) {
- streams[i] = NULL;
- continue;
- }
-
- streamname = talloc_asprintf(talloc_tos(), "%s%s", fname,
- stream_info[i].name);
-
- if (streamname == NULL) {
- DEBUG(0, ("talloc_aprintf failed\n"));
- status = NT_STATUS_NO_MEMORY;
- goto fail;
- }
-
- status = onefs_create_file_unixpath
- (conn, /* conn */
- NULL, /* req */
- streamname, /* fname */
- DELETE_ACCESS, /* access_mask */
- FILE_SHARE_READ | FILE_SHARE_WRITE
- | FILE_SHARE_DELETE, /* share_access */
- FILE_OPEN, /* create_disposition*/
- NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE, /* create_options */
- FILE_ATTRIBUTE_NORMAL, /* file_attributes */
- 0, /* oplock_request */
- 0, /* allocation_size */
- NULL, /* sd */
- NULL, /* ea_list */
- &streams[i], /* result */
- NULL, /* pinfo */
- NULL, /* fsp_data */
- NULL); /* psbuf */
-
- TALLOC_FREE(streamname);
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(10, ("Could not open stream %s: %s\n",
- streamname, nt_errstr(status)));
- break;
- }
- }
-
- /*
- * don't touch the variable "status" beyond this point :-)
- */
-
- for (i -= 1 ; i >= 0; i--) {
- if (streams[i] == NULL) {
- continue;
- }
-
- DEBUG(10, ("Closing stream # %d, %s\n", i,
- streams[i]->fsp_name));
- close_file(NULL, streams[i], NORMAL_CLOSE);
- }
-
- fail:
- TALLOC_FREE(frame);
- return status;
-}
-
-/*
* Wrapper around onefs_open_file_ntcreate and onefs_open_directory.
*/
static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
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 d76d20c962..a83b0c53c6 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -279,6 +279,266 @@ WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
return werror;
}
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumForms
+**********************************************************************/
+
+WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_FormInfo **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_EnumForms(cli, mem_ctx,
+ handle,
+ 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_EnumForms(cli, mem_ctx,
+ handle,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
+ }
+
+ 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
@@ -414,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)
{
@@ -623,34 +821,6 @@ static bool decode_jobs_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
/**********************************************************************
**********************************************************************/
-static bool decode_forms_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 num_forms, FORM_1 **forms)
-{
- int i;
-
- if (num_forms) {
- *forms = TALLOC_ARRAY(mem_ctx, FORM_1, num_forms);
- if (*forms == NULL) {
- return False;
- }
- } else {
- *forms = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i = 0; i < num_forms; i++) {
- if (!smb_io_form_1("", buffer, &((*forms)[i]), 0)) {
- return False;
- }
- }
-
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
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)
@@ -730,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,
@@ -887,64 +985,6 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
/**********************************************************************
**********************************************************************/
-WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *handle, int level, uint32 *num_forms,
- FORM_1 **forms)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ENUMFORMS in;
- SPOOL_R_ENUMFORMS out;
- RPC_BUFFER buffer;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumforms( &in, handle, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMFORMS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumforms,
- spoolss_io_r_enumforms,
- 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_enumforms( &in, handle, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMFORMS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumforms,
- spoolss_io_r_enumforms,
- WERR_GENERAL_FAILURE );
- }
-
- if (!W_ERROR_IS_OK(out.status))
- return out.status;
-
- *num_forms = out.numofforms;
-
- if (!decode_forms_1(mem_ctx, out.buffer, *num_forms, forms)) {
- return WERR_GENERAL_FAILURE;
- }
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, uint32 level, uint32 firstjob,
uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr)
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 78c041f863..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,162 +1090,6 @@ bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, i
}
/*******************************************************************
-********************************************************************/
-
-bool smb_io_form_1(const char *desc, RPC_BUFFER *buffer, FORM_1 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_form_1");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("flag", ps, depth, &info->flag))
- return False;
-
- if (!smb_io_relstr("name", buffer, depth, &info->name))
- return False;
-
- if (!prs_uint32("width", ps, depth, &info->width))
- return False;
- if (!prs_uint32("length", ps, depth, &info->length))
- return False;
- if (!prs_uint32("left", ps, depth, &info->left))
- return False;
- if (!prs_uint32("top", ps, depth, &info->top))
- return False;
- if (!prs_uint32("right", ps, depth, &info->right))
- return False;
- if (!prs_uint32("bottom", ps, depth, &info->bottom))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- 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
********************************************************************/
@@ -1646,81 +1444,6 @@ uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
/*******************************************************************
return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_form_1(FORM_1 *info)
-{
- int size=0;
-
- size+=size_of_uint32( &info->flag );
- size+=size_of_relative_string( &info->name );
- size+=size_of_uint32( &info->width );
- size+=size_of_uint32( &info->length );
- size+=size_of_uint32( &info->left );
- size+=size_of_uint32( &info->top );
- size+=size_of_uint32( &info->right );
- size+=size_of_uint32( &info->bottom );
-
- return size;
-}
-
-/*******************************************************************
-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)
{
@@ -1739,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)
********************************************************************/
@@ -1862,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)
********************************************************************/
@@ -2182,124 +1861,6 @@ bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER
}
/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth)
-{
-
- prs_debug(ps, depth, desc, "spoolss_io_q_enumforms");
- depth++;
-
- if (!prs_align(ps))
- return False;
- if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
- 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_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_enumforms");
- 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("size of buffer needed", ps, depth, &r_u->needed))
- return False;
-
- if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms))
- return False;
-
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- 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*
******************************************************************/
@@ -2326,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");
@@ -3083,19 +2438,3 @@ bool spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX
return False;
return True;
}
-
-/*******************************************************************
- * init a structure.
- ********************************************************************/
-
-bool make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
- uint32 level, RPC_BUFFER *buffer,
- uint32 offered)
-{
- memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
- q_u->level = level;
- q_u->buffer=buffer;
- q_u->offered=offered;
-
- return True;
-}
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index 09b1f66440..f3ee18da5a 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -2113,7 +2113,11 @@ bool api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss
auth_len = p->hdr.auth_len;
- if (auth_len != RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) {
+ if (auth_len < RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN ||
+ auth_len > RPC_HEADER_LEN +
+ RPC_HDR_REQ_LEN +
+ RPC_HDR_AUTH_LEN +
+ auth_len) {
DEBUG(0,("Incorrect auth_len %u.\n", (unsigned int)auth_len ));
return False;
}
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 ee36f04c6d..616eb1dbf0 100644
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -431,27 +431,7 @@ static bool api_spoolss_getform(pipes_struct *p)
static bool api_spoolss_enumforms(pipes_struct *p)
{
- SPOOL_Q_ENUMFORMS q_u;
- SPOOL_R_ENUMFORMS 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_enumforms("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMFORMS);
}
/****************************************************************************
@@ -459,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);
}
/****************************************************************************
@@ -597,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);
}
/****************************************************************************
@@ -633,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);
}
/****************************************************************************
@@ -661,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 814f406e87..0a4f5ae05c 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -7244,21 +7244,6 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS
/****************************************************************************
****************************************************************************/
-static void fill_form_1(FORM_1 *form, nt_forms_struct *list)
-{
- form->flag=list->flag;
- init_unistr(&form->name, list->name);
- form->width=list->width;
- form->length=list->length;
- form->left=list->left;
- form->top=list->top;
- form->right=list->right;
- form->bottom=list->bottom;
-}
-
-/****************************************************************************
-****************************************************************************/
-
static WERROR fill_form_info_1(TALLOC_CTX *mem_ctx,
struct spoolss_FormInfo1 *form,
nt_forms_struct *list)
@@ -7277,73 +7262,65 @@ static WERROR fill_form_info_1(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumForms
+****************************************************************/
-WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u)
+WERROR _spoolss_EnumForms(pipes_struct *p,
+ struct spoolss_EnumForms *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *numofforms = &r_u->numofforms;
- uint32 numbuiltinforms;
-
nt_forms_struct *list=NULL;
nt_forms_struct *builtinlist=NULL;
- FORM_1 *forms_1;
- int buffer_size=0;
+ union spoolss_FormInfo *info;
+ uint32_t count;
+ uint32_t numbuiltinforms;
+ size_t buffer_size = 0;
int i;
- /* that's an [in out] buffer */
+ *r->out.count = 0;
- if (!q_u->buffer && (offered!=0) ) {
- return WERR_INVALID_PARAM;
- }
+ /* that's an [in out] buffer */
- 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_enumforms\n"));
- DEBUGADD(5,("Offered buffer size [%d]\n", offered));
- DEBUGADD(5,("Info level [%d]\n", level));
+ DEBUG(4,("_spoolss_EnumForms\n"));
+ DEBUGADD(5,("Offered buffer size [%d]\n", r->in.offered));
+ DEBUGADD(5,("Info level [%d]\n", r->in.level));
numbuiltinforms = get_builtin_ntforms(&builtinlist);
DEBUGADD(5,("Number of builtin forms [%d]\n", numbuiltinforms));
- *numofforms = get_ntforms(&list);
- DEBUGADD(5,("Number of user forms [%d]\n", *numofforms));
- *numofforms += numbuiltinforms;
+ count = get_ntforms(&list);
+ DEBUGADD(5,("Number of user forms [%d]\n", count));
+ count += numbuiltinforms;
- if (*numofforms == 0) {
+ if (count == 0) {
SAFE_FREE(builtinlist);
SAFE_FREE(list);
return WERR_NO_MORE_ITEMS;
}
- switch (level) {
- case 1:
- if ((forms_1=SMB_MALLOC_ARRAY(FORM_1, *numofforms)) == NULL) {
- SAFE_FREE(builtinlist);
- SAFE_FREE(list);
- *numofforms=0;
- return WERR_NOMEM;
- }
+ info = TALLOC_ARRAY(p->mem_ctx, union spoolss_FormInfo, count);
+ if (!info) {
+ SAFE_FREE(builtinlist);
+ SAFE_FREE(list);
+ return WERR_NOMEM;
+ }
+ switch (r->in.level) {
+ case 1:
/* construct the list of form structures */
for (i=0; i<numbuiltinforms; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &builtinlist[i]);
+ fill_form_info_1(info, &info[i].info1, &builtinlist[i]);
}
SAFE_FREE(builtinlist);
- for (; i<*numofforms; i++) {
+ for (; i<count; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &list[i-numbuiltinforms]);
+ fill_form_info_1(info, &info[i].info1, &list[i-numbuiltinforms]);
}
SAFE_FREE(list);
@@ -7351,38 +7328,22 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF
/* check the required size. */
for (i=0; i<numbuiltinforms; i++) {
DEBUGADD(6,("adding form [%d]'s size\n",i));
- buffer_size += spoolss_size_form_1(&forms_1[i]);
+ buffer_size += ndr_size_spoolss_FormInfo1(&info[i].info1, NULL, 0);
}
- for (; i<*numofforms; i++) {
+ for (; i<count; i++) {
DEBUGADD(6,("adding form [%d]'s size\n",i));
- buffer_size += spoolss_size_form_1(&forms_1[i]);
+ buffer_size += ndr_size_spoolss_FormInfo1(&info[i].info1, NULL, 0);
}
- *needed=buffer_size;
+ *r->out.needed = buffer_size;
- if (*needed > offered) {
- SAFE_FREE(forms_1);
- *numofforms=0;
+ if (*r->out.needed > r->in.offered) {
+ TALLOC_FREE(info);
return WERR_INSUFFICIENT_BUFFER;
}
- if (!rpcbuf_alloc_size(buffer, buffer_size)){
- SAFE_FREE(forms_1);
- *numofforms=0;
- return WERR_NOMEM;
- }
-
- /* fill the buffer with the form structures */
- for (i=0; i<numbuiltinforms; i++) {
- DEBUGADD(6,("adding form [%d] to buffer\n",i));
- smb_io_form_1("", buffer, &forms_1[i], 0);
- }
- for (; i<*numofforms; i++) {
- DEBUGADD(6,("adding form [%d] to buffer\n",i));
- smb_io_form_1("", buffer, &forms_1[i], 0);
- }
-
- SAFE_FREE(forms_1);
+ *r->out.count = count;
+ *r->out.info = info;
return WERR_OK;
@@ -7485,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;
}
/****************************************************************************
@@ -7495,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;
}
@@ -7569,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;
@@ -7579,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) {
@@ -7611,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) {
@@ -7676,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;
}
@@ -8770,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);
-
-out:
- SAFE_FREE(info_1);
-
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
- 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 ...
@@ -8841,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);
-
-out:
- SAFE_FREE(info_1);
-
- if ( !W_ERROR_IS_OK(result) )
- *returned = 0;
+ *info_p = info;
- 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 ...
@@ -9056,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;
}
@@ -10103,7 +10130,7 @@ WERROR _spoolss_XcvData(pipes_struct *p,
struct spoolss_XcvData *r)
{
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
- DATA_BLOB out_data;
+ DATA_BLOB out_data = data_blob_null;
WERROR werror;
if (!Printer) {
@@ -10258,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
****************************************************************/
@@ -10313,39 +10329,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
}
/****************************************************************
- _spoolss_EnumForms
-****************************************************************/
-
-WERROR _spoolss_EnumForms(pipes_struct *p,
- struct spoolss_EnumForms *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
- _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
****************************************************************/
@@ -10500,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 5b55ac3e2a..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);
@@ -1848,7 +1840,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
switch (level) {
case 1:
- info1.flags = FORM_USER;
+ info1.flags = SPOOLSS_FORM_USER;
info1.form_name = argv[2];
info1.size.width = 100;
info1.size.height = 100;
@@ -1861,7 +1853,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
break;
case 2:
- info2.flags = FORM_USER;
+ info2.flags = SPOOLSS_FORM_USER;
info2.form_name = argv[2];
info2.size.width = 100;
info2.size.height = 100;
@@ -1930,7 +1922,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Dummy up some values for the form data */
- info1.flags = FORM_PRINTER;
+ info1.flags = SPOOLSS_FORM_PRINTER;
info1.size.width = 100;
info1.size.height = 100;
info1.area.left = 0;
@@ -1963,11 +1955,11 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
static const char *get_form_flag(int form_flag)
{
switch (form_flag) {
- case FORM_USER:
+ case SPOOLSS_FORM_USER:
return "FORM_USER";
- case FORM_BUILTIN:
+ case SPOOLSS_FORM_BUILTIN:
return "FORM_BUILTIN";
- case FORM_PRINTER:
+ case SPOOLSS_FORM_PRINTER:
return "FORM_PRINTER";
default:
return "unknown";
@@ -1977,27 +1969,6 @@ static const char *get_form_flag(int form_flag)
/****************************************************************************
****************************************************************************/
-static void display_form(FORM_1 *form)
-{
- fstring form_name = "";
-
- if (form->name.buffer)
- rpcstr_pull(form_name, form->name.buffer,
- sizeof(form_name), -1, STR_TERMINATE);
-
- printf("%s\n" \
- "\tflag: %s (%d)\n" \
- "\twidth: %d, length: %d\n" \
- "\tleft: %d, right: %d, top: %d, bottom: %d\n\n",
- form_name, get_form_flag(form->flag), form->flag,
- form->width, form->length,
- form->left, form->right,
- form->top, form->bottom);
-}
-
-/****************************************************************************
-****************************************************************************/
-
static void display_form_info1(struct spoolss_FormInfo1 *r)
{
printf("%s\n" \
@@ -2173,12 +2144,12 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
WERROR werror;
const char *printername;
uint32 num_forms, level = 1, i;
- FORM_1 *forms;
+ union spoolss_FormInfo *forms;
/* Parse the command arguments */
- if (argc != 2) {
- printf ("Usage: %s <printer>\n", argv[0]);
+ if (argc < 2 || argc > 4) {
+ printf ("Usage: %s <printer> [level]\n", argv[0]);
return WERR_OK;
}
@@ -2193,9 +2164,18 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(werror))
goto done;
+ if (argc == 3) {
+ level = atoi(argv[2]);
+ }
+
/* Enumerate forms */
- werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms);
+ werror = rpccli_spoolss_enumforms(cli, mem_ctx,
+ &handle,
+ level,
+ 0,
+ &num_forms,
+ &forms);
if (!W_ERROR_IS_OK(werror))
goto done;
@@ -2203,9 +2183,14 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
/* Display output */
for (i = 0; i < num_forms; i++) {
-
- display_form(&forms[i]);
-
+ switch (level) {
+ case 1:
+ display_form_info1(&forms[i].info1);
+ break;
+ case 2:
+ display_form_info2(&forms[i].info2);
+ break;
+ }
}
done:
@@ -3064,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[] = {
@@ -3099,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/smbd/open.c b/source3/smbd/open.c
index acd347520d..c8cc2e64a3 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2386,6 +2386,14 @@ static NTSTATUS open_directory(connection_struct *conn,
return status;
}
+ /* We need to support SeSecurityPrivilege for this. */
+ if (access_mask & SEC_RIGHT_SYSTEM_SECURITY) {
+ DEBUG(10, ("open_directory: open on %s "
+ "failed - SEC_RIGHT_SYSTEM_SECURITY denied.\n",
+ fname));
+ return NT_STATUS_PRIVILEGE_NOT_HELD;
+ }
+
switch( create_disposition ) {
case FILE_OPEN:
@@ -2719,7 +2727,7 @@ struct case_semantics_state *set_posix_case_semantics(TALLOC_CTX *mem_ctx,
* If that works, delete them all by setting the delete on close and close.
*/
-static NTSTATUS open_streams_for_delete(connection_struct *conn,
+NTSTATUS open_streams_for_delete(connection_struct *conn,
const char *fname)
{
struct stream_struct *stream_info;
@@ -2777,13 +2785,15 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn,
goto fail;
}
- status = create_file_unixpath
- (conn, /* conn */
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
NULL, /* req */
+ 0, /* root_dir_fid */
streamname, /* fname */
+ 0, /* create_file_flags */
DELETE_ACCESS, /* access_mask */
- FILE_SHARE_READ | FILE_SHARE_WRITE
- | FILE_SHARE_DELETE, /* share_access */
+ (FILE_SHARE_READ | /* share_access */
+ FILE_SHARE_WRITE | FILE_SHARE_DELETE),
FILE_OPEN, /* create_disposition*/
NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE, /* create_options */
FILE_ATTRIBUTE_NORMAL, /* file_attributes */
@@ -2929,6 +2939,20 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
status = NT_STATUS_PRIVILEGE_NOT_HELD;
goto fail;
}
+#else
+ /* We need to support SeSecurityPrivilege for this. */
+ if (access_mask & SEC_RIGHT_SYSTEM_SECURITY) {
+ status = NT_STATUS_PRIVILEGE_NOT_HELD;
+ goto fail;
+ }
+ /* Don't allow a SACL set from an NTtrans create until we
+ * support SeSecurityPrivilege. */
+ if (!VALID_STAT(sbuf) &&
+ lp_nt_acl_support(SNUM(conn)) &&
+ sd && (sd->sacl != NULL)) {
+ status = NT_STATUS_PRIVILEGE_NOT_HELD;
+ goto fail;
+ }
#endif
if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
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_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 8116764d9b..950ca72ed8 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -955,14 +955,18 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd,
int level,
- uint32 *num_forms,
- FORM_1 **forms)
+ uint32_t *num_forms,
+ union spoolss_FormInfo **forms)
{
WERROR result;
/* enumforms call */
- result = rpccli_spoolss_enumforms(pipe_hnd, mem_ctx, hnd, level, num_forms, forms);
-
+ result = rpccli_spoolss_enumforms(pipe_hnd, mem_ctx,
+ hnd,
+ level,
+ 0,
+ num_forms,
+ forms);
if (!W_ERROR_IS_OK(result)) {
printf("could not enum forms: %s\n", win_errstr(result));
return false;
@@ -1685,8 +1689,8 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_enum;
union spoolss_PrinterInfo info_dst;
- uint32 num_forms;
- FORM_1 *forms;
+ uint32_t num_forms;
+ union spoolss_FormInfo *forms;
struct cli_state *cli_dst = NULL;
ZERO_STRUCT(ctr_enum);
@@ -1760,34 +1764,19 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
for (f = 0; f < num_forms; f++) {
union spoolss_AddFormInfo info;
- struct spoolss_AddFormInfo1 info1;
- fstring form_name;
NTSTATUS status;
/* only migrate FORM_PRINTER types, according to jerry
FORM_BUILTIN-types are hard-coded in samba */
- if (forms[f].flag != FORM_PRINTER)
+ if (forms[f].info1.flags != SPOOLSS_FORM_PRINTER)
continue;
- if (forms[f].name.buffer)
- rpcstr_pull(form_name, forms[f].name.buffer,
- sizeof(form_name), -1, STR_TERMINATE);
-
if (c->opt_verbose)
d_printf("\tmigrating form # %d [%s] of type [%d]\n",
- f, form_name, forms[f].flag);
-
- /* is there a more elegant way to do that ? */
- info1.flags = FORM_PRINTER;
- info1.size.width = forms[f].width;
- info1.size.height = forms[f].length;
- info1.area.left = forms[f].left;
- info1.area.top = forms[f].top;
- info1.area.right = forms[f].right;
- info1.area.bottom = forms[f].bottom;
- info1.form_name = form_name;
+ f, forms[f].info1.form_name,
+ forms[f].info1.flags);
- info.info1 = &info1;
+ info.info1 = (struct spoolss_AddFormInfo1 *)&forms[f].info1;
/* FIXME: there might be something wrong with samba's
builtin-forms */
@@ -1798,11 +1787,12 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
&result);
if (!W_ERROR_IS_OK(result)) {
d_printf("\tAddForm form %d: [%s] refused.\n",
- f, form_name);
+ f, forms[f].info1.form_name);
continue;
}
- DEBUGADD(1,("\tAddForm of [%s] succeeded\n", form_name));
+ DEBUGADD(1,("\tAddForm of [%s] succeeded\n",
+ forms[f].info1.form_name));
}
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.c b/source3/winbindd/winbindd.c
index dbe83152dd..e455d936e0 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -320,7 +320,7 @@ static bool winbindd_setup_sig_usr2_handler(void)
se = tevent_add_signal(winbind_event_context(),
winbind_event_context(),
- SIGCHLD, 0,
+ SIGUSR2, 0,
winbindd_sig_usr2_handler,
NULL);
if (!se) {
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;
}