From d526d340d8f5d70ea48bcaf535ea57d2c1cd48db Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Wed, 4 Mar 2009 17:26:57 -0800 Subject: Fix careless mistake in winbindd_setup_sig_usr2_handler --- source3/winbindd/winbindd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') 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) { -- cgit From f61f1690548edbd1c6e3badfe8d2e7b50485d03e Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 3 Mar 2009 19:23:33 -0800 Subject: s3: Change open_streams_for_delete to call through the vfs layer This eliminates the last direct caller of create_file_unixpath --- source3/include/proto.h | 2 ++ source3/smbd/open.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 78110161c5..41e3618503 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6723,6 +6723,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/smbd/open.c b/source3/smbd/open.c index acd347520d..ccc6fc77d6 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2719,7 +2719,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 +2777,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 */ -- cgit From 04f5f739056b535c71f0991b388f7f4b14c0b75e Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 3 Mar 2009 19:27:50 -0800 Subject: s3 OneFS: Use the public open_streams_for_delete --- source3/modules/onefs_open.c | 113 ------------------------------------------- 1 file changed, 113 deletions(-) (limited to 'source3') 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 @@ -1648,119 +1648,6 @@ static NTSTATUS onefs_open_directory(connection_struct *conn, return NT_STATUS_OK; } -/* - * 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= 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. */ -- cgit From bb1dab3a97d07dd6778f414ce3bff4f150b60d5d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Mar 2009 09:04:16 -0800 Subject: Fix bug #6160 - Office 2007 fails saving files to a Samba mapped drive. Confirmed by reporters. Jeremy. --- source3/smbd/open.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source3') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ccc6fc77d6..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: @@ -2931,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) -- cgit From 2544ba6a0a1b9c4bacc93262b8e776bf98456252 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 5 Mar 2009 22:20:55 +0100 Subject: Complete the fix for bug 6100 According to [MS-RPCE].pdf, section 2.2.2.11: ---- A client or a server that (during composing of a PDU) has allocated more space for the authentication token than the security provider fills in SHOULD fill in the rest of the allocated space with zero octets. These zero octets are still considered to belong to the authentication token part of the PDU.<36> ---- RPC implementations are allowed to send padding bytes at the end of an auth footer. Windows 7 makes use of this. Thanks to Nick Meier Volker --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 09b1f66440..ac491b9e53 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2113,7 +2113,7 @@ 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) { DEBUG(0,("Incorrect auth_len %u.\n", (unsigned int)auth_len )); return False; } -- cgit From 0d9f4a2886087692642dd3eba68f0b95657232bc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Mar 2009 15:18:18 -0800 Subject: Last part of fix for #6154 - zfs does not honor admin users. Jeremy. --- source3/include/proto.h | 6 +++--- source3/locking/locking.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 41e3618503..0dfa7f0809 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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 *, 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) { -- cgit From 66c0f3690a6c9248adfe5da7c1abd15a8704fd6c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Mar 2009 17:19:18 -0800 Subject: Fix bug #6161 - smbclient corrupts source path in tar mode This was my fault. I broke the smbclient tar argument processing in creating the string for chdir when removing pstrings. Jeremy. --- source3/client/clitar.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source3') 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); -- cgit From 4e74d811aa9f85a4cb7896c0fcc21552d1910cf5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Mar 2009 21:06:48 -0800 Subject: Now we're allowing a lower bound for auth_len, ensure we also check for an upper one (integer wrap). Jeremy. --- source3/rpc_server/srv_pipe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ac491b9e53..6becfa42e8 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; } -- cgit From 67d12e9c6bc9e34ecc335ddfc85fc59ed9167b68 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Mar 2009 22:00:22 -0800 Subject: Get the sense of the integer wrap test the right way around. Sorry. Jeremy. --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 6becfa42e8..f3ee18da5a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2114,7 +2114,7 @@ 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 || - auth_len < RPC_HEADER_LEN + + auth_len > RPC_HEADER_LEN + RPC_HDR_REQ_LEN + RPC_HDR_AUTH_LEN + auth_len) { -- cgit From c14a589a46ab5d9f80533cda01b6624a80611dc9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 10:54:19 +0100 Subject: s3-spoolss: add convencience wrapper around rpccli_spoolss_EnumForms. Guenther --- source3/include/proto.h | 7 ++++++ source3/rpc_client/cli_spoolss.c | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 0dfa7f0809..74240fe97a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5474,6 +5474,13 @@ 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_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, char *name, uint32 flags, uint32 level, uint32 *num_printers, PRINTER_INFO_CTR *ctr); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index d76d20c962..b4828b4d90 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -279,6 +279,57 @@ 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; +} + /********************************************************************* Decode various spoolss rpc's and info levels -- cgit From 6336366abb53436c6800263cc0da26faa13c038c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 10:55:41 +0100 Subject: s3-rpcclient: use new rpccli_spoolss_enumforms wrapper. Guenther --- source3/rpcclient/cmd_spoolss.c | 49 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 5b55ac3e2a..c88cf89367 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1977,27 +1977,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 +2152,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 \n", argv[0]); + if (argc < 2 || argc > 4) { + printf ("Usage: %s [level]\n", argv[0]); return WERR_OK; } @@ -2193,9 +2172,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 +2191,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: -- cgit From 01e4f63c5e75aadf7556b4ad65d061dea9091c20 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 11:02:27 +0100 Subject: s3-net: use new rpccli_spoolss_enumforms wrapper. Guenther --- source3/utils/net_rpc_printer.c | 44 ++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 8116764d9b..108ed50d8a 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 != 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)); } -- cgit From 9bdca59fc5b579c8aafbd6cb7aa1524e1417ca64 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 10:55:09 +0100 Subject: s3-spoolss: remove old rpccli_spoolss_enumforms. Guenther --- source3/include/proto.h | 6 --- source3/rpc_client/cli_spoolss.c | 86 --------------------------------------- source3/rpc_parse/parse_spoolss.c | 16 -------- 3 files changed, 108 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 74240fe97a..4ce5ed695f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5491,9 +5491,6 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli, 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); @@ -5924,9 +5921,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 */ diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index b4828b4d90..5e09787a9c 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -674,34 +674,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) @@ -938,64 +910,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..e3236066a1 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -3083,19 +3083,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; -} -- cgit From f9bf09e255c20672f1565aa9e3c51d1274958dcf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 12:01:14 +0100 Subject: s3-spoolss: use pidl for _spoolss_EnumForms. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_spoolss.c | 22 +------ source3/rpc_server/srv_spoolss_nt.c | 111 ++++++++++++------------------------ 3 files changed, 39 insertions(+), 95 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 4ce5ed695f..8395e2ad4d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6123,7 +6123,6 @@ 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); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index ee36f04c6d..d665ebe244 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); } /**************************************************************************** diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 814f406e87..ec19279e0c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7277,73 +7277,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; iout.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; iout.count = count; + *r->out.info = info; return WERR_OK; @@ -10312,17 +10288,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p, return WERR_NOT_SUPPORTED; } -/**************************************************************** - _spoolss_EnumForms -****************************************************************/ - -WERROR _spoolss_EnumForms(pipes_struct *p, - struct spoolss_EnumForms *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - /**************************************************************** _spoolss_EnumPorts ****************************************************************/ -- cgit From 4541aa5f846bc7b38e2873d65b5b6a5614a037b4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 12:01:54 +0100 Subject: s3-spoolss: use form flags from idl in rpcclient and net. Guenther --- source3/rpcclient/cmd_spoolss.c | 12 ++++++------ source3/utils/net_rpc_printer.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index c88cf89367..fae5c552c2 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1848,7 +1848,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 +1861,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 +1930,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 +1963,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"; diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 108ed50d8a..950ca72ed8 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -1768,7 +1768,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, /* only migrate FORM_PRINTER types, according to jerry FORM_BUILTIN-types are hard-coded in samba */ - if (forms[f].info1.flags != FORM_PRINTER) + if (forms[f].info1.flags != SPOOLSS_FORM_PRINTER) continue; if (c->opt_verbose) -- cgit From 8614ce5ca74e71f931d1fa76d59b7c07271717c4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 12:04:47 +0100 Subject: s3-spoolss: remove old _spoolss_EnumForms. Guenther --- source3/include/proto.h | 4 -- source3/include/rpc_spoolss.h | 35 ------------ source3/rpc_parse/parse_spoolss.c | 110 ------------------------------------ source3/rpc_server/srv_spoolss_nt.c | 15 ----- 4 files changed, 164 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 8395e2ad4d..ffdef43d19 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5818,7 +5818,6 @@ bool smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_I 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); @@ -5840,7 +5839,6 @@ 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); @@ -5880,8 +5878,6 @@ 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); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 2b4a036ce8..e101a27ca8 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -769,41 +769,6 @@ 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 diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index e3236066a1..181ad0e7d2 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -1135,40 +1135,6 @@ bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, i return True; } -/******************************************************************* -********************************************************************/ - -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. ********************************************************************/ @@ -1644,26 +1610,6 @@ uint32 spoolss_size_job_info_2(JOB_INFO_2 *info) return size; } -/******************************************************************* -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 ********************************************************************/ @@ -2181,62 +2127,6 @@ bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER return True; } -/******************************************************************* -********************************************************************/ - -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. ********************************************************************/ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ec19279e0c..0c496b985f 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) -- cgit From 5ce523bbed4196fda6716b71ef6080c3c5522838 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 14:58:49 +0100 Subject: s3-spoolss: Fix Coverity ID #891 (UNINIT). Guenther --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0c496b985f..77f64ae8ae 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -10064,7 +10064,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) { -- cgit From 918e6288fa775893a7e895334e05ce7780f89eaf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 16:18:50 +0100 Subject: s3:libsmb: smb signing works the same for extented and non-extended security This is only cosmetic, but it makes it easier to understand. metze --- source3/libsmb/cliconnect.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index ad11ee0ed4..58e7dd1f8e 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); -- cgit From 4b6cbe80b28b7a99ba8f35190d809f5a439fdd22 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 07:38:41 +0100 Subject: s3:errormap: add ECANCELED, ERRDOS/ERRbadfid, NT_STATUS_CANCELLED mapping If someone knows a better dos error, please tell me... metze --- source3/lib/errmap_unix.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3') 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 } }; -- cgit From 196a5d038886bdea678ac9ae97bdf9dab825e23f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 07:45:06 +0100 Subject: s3:signing: the seqnum should only be decremented by 1 for ntcancel requests [MS-SMB] 3.3.5.1 Receiving Any Message says that the seqnum is incremented by only for ntcancel requests for any other request it's by incremented by 2, even if it doesn't expect a response. metze --- source3/include/proto.h | 2 +- source3/libsmb/smb_signing.c | 6 ++++-- source3/smbd/aio.c | 8 ++++---- source3/smbd/nttrans.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index ffdef43d19..6376d8af8a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/libsmb/smb_signing.c b/source3/libsmb/smb_signing.c index ea1eb05cfb..55b30d476f 100644 --- a/source3/libsmb/smb_signing.c +++ b/source3/libsmb/smb_signing.c @@ -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; + } } /*********************************************************** 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)); -- cgit From 589eb81e3fe5262d544af2c5032c99b5a4d4ba85 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 11:40:21 +0100 Subject: s3:winbindd_cm: remove useless cli_setup_signing_state(*cli, Undefined) call cli_setup_signing_state() with Undefined is a noop. metze --- source3/winbindd/winbindd_cm.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3') 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)) { -- cgit From 6e572d40a913f788f06e4bc7a7047129bc22ad5a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 11:52:15 +0100 Subject: s3:libsmb: remove cli_setup_signing_state() and add struct cli_state *cli_initialise_ex() This prepares the next changes. metze --- source3/include/proto.h | 2 +- source3/libsmb/cliconnect.c | 4 +--- source3/libsmb/clidfs.c | 3 +-- source3/libsmb/clientgen.c | 10 ++++++++-- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 6376d8af8a..c8dff53fdd 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); diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 58e7dd1f8e..e3d1b65be0 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1949,7 +1949,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; } @@ -1997,8 +1997,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..41b1fe8859 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -428,7 +428,7 @@ 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) +static void cli_setup_signing_state(struct cli_state *cli, int signing_state) { if (signing_state == Undefined) return; @@ -449,7 +449,7 @@ void cli_setup_signing_state(struct cli_state *cli, int signing_state) Initialise a client structure. Always returns a malloc'ed struct. ****************************************************************************/ -struct cli_state *cli_initialise(void) +struct cli_state *cli_initialise_ex(int signing_state) { struct cli_state *cli = NULL; @@ -511,6 +511,7 @@ struct cli_state *cli_initialise(void) /* initialise signing */ cli_null_set_signing(cli); + cli_setup_signing_state(cli, signing_state); cli->initialised = 1; @@ -526,6 +527,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. ****************************************************************************/ -- cgit From 3f3e15ab91373597390320269f5cd701d3f07a3b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 12:01:44 +0100 Subject: s3:libsmb: merge cli_setup_signing_state() into cli_initialise_ex() metze --- source3/libsmb/clientgen.c | 52 ++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 41b1fe8859..2983f7771a 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -424,34 +424,16 @@ void cli_init_creds(struct cli_state *cli, const char *username, const char *dom DEBUG(10,("cli_init_creds: user %s domain %s\n", cli->user_name, cli->domain)); } -/**************************************************************************** - Set the signing state (used from the command line). -****************************************************************************/ - -static 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_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_ex(int signing_state) 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,8 +507,9 @@ struct cli_state *cli_initialise_ex(int signing_state) #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_setup_signing_state(cli, signing_state); cli->initialised = 1; -- cgit From bf85a14182f0dfe6d21cda2039c7ccb961419328 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 16:27:10 +0100 Subject: s3:make_test: run CHAIN1 test metze --- source3/script/tests/test_smbtorture_s3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') 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" -- cgit From f48ccec957c1ea943ad88304c40e37e803f6e9fb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 20:22:17 +0100 Subject: s3-spoolss: use pidl for _spoolss_EnumPrintProcessors. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_spoolss.c | 22 +------- source3/rpc_server/srv_spoolss_nt.c | 102 ++++++++++++++++++------------------ 3 files changed, 51 insertions(+), 74 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index c8dff53fdd..ca64463059 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6123,7 +6123,6 @@ 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); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index d665ebe244..9b83377bfe 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -577,27 +577,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); } /**************************************************************************** diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 77f64ae8ae..5ded5aeadc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8730,70 +8730,76 @@ done: return status; } +/**************************************************************************** + fill_print_processor1 +****************************************************************************/ + +static WERROR fill_print_processor1(TALLOC_CTX *mem_ctx, + struct spoolss_PrintProcessorInfo1 *r, + const char *print_processor_name) +{ + r->print_processor_name = talloc_strdup(mem_ctx, print_processor_name); + W_ERROR_HAVE_NO_MEMORY(r->print_processor_name); + + return WERR_OK; +} + /**************************************************************************** enumprintprocessors level 1. ****************************************************************************/ -static WERROR enumprintprocessors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocessors_level_1(TALLOC_CTX *mem_ctx, + union spoolss_PrintProcessorInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PRINTPROCESSOR_1 *info_1=NULL; - WERROR result = WERR_OK; + union spoolss_PrintProcessorInfo *info; + WERROR result; - if((info_1 = SMB_MALLOC_P(PRINTPROCESSOR_1)) == NULL) - return WERR_NOMEM; + info = TALLOC_ARRAY(mem_ctx, union spoolss_PrintProcessorInfo, 1); + W_ERROR_HAVE_NO_MEMORY(info); - (*returned) = 0x1; + *count = 1; - init_unistr(&info_1->name, "winprint"); + result = fill_print_processor1(info, &info[0].info1, "winprint"); + if (!W_ERROR_IS_OK(result)) { + goto out; + } - *needed += spoolss_size_printprocessor_info_1(info_1); + *needed += ndr_size_spoolss_PrintProcessorInfo1(&info[0].info1, NULL, 0); if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; + out: + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + *count = 0; + return result; } - smb_io_printprocessor_info_1("", buffer, info_1, 0); + *info_p = info; -out: - SAFE_FREE(info_1); - - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; - - return result; + return WERR_OK; } -/**************************************************************************** -****************************************************************************/ +/**************************************************************** + _spoolss_EnumPrintProcessors +****************************************************************/ -WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) +WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, + struct spoolss_EnumPrintProcessors *r) { - uint32 level = q_u->level; - RPC_BUFFER *buffer = NULL; - uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; - uint32 *returned = &r_u->returned; - /* that's an [in out] buffer */ - if (!q_u->buffer && (offered!=0)) { - return WERR_INVALID_PARAM; - } - - if (offered > MAX_RPC_DATA_SIZE) { + if (!r->in.buffer && (r->in.offered != 0)) { return WERR_INVALID_PARAM; } - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; - - DEBUG(5,("spoolss_enumprintprocessors\n")); + DEBUG(5,("_spoolss_EnumPrintProcessors\n")); /* * Enumerate the print processors ... @@ -8802,12 +8808,15 @@ 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; } @@ -10218,17 +10227,6 @@ WERROR _spoolss_GetPrinterDriver(pipes_struct *p, return WERR_NOT_SUPPORTED; } -/**************************************************************** - _spoolss_EnumPrintProcessors -****************************************************************/ - -WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, - struct spoolss_EnumPrintProcessors *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - /**************************************************************** _spoolss_ReadPrinter ****************************************************************/ -- cgit From 066a47b9940b9ecc6a5c6d022444a17effac4855 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 20:23:27 +0100 Subject: s3-spoolss: remove old spoolss_EnumPrintProcessors. Guenther --- source3/include/proto.h | 4 -- source3/include/rpc_spoolss.h | 27 ---------- source3/rpc_parse/parse_spoolss.c | 101 -------------------------------------- 3 files changed, 132 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index ca64463059..f7ca81d60d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5820,7 +5820,6 @@ bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, i bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth); bool smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth); bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth); -bool smb_io_printprocessor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth); bool smb_io_printprocdatatype_info_1(const char *desc, RPC_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth); bool smb_io_printmonitor_info_1(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_1 *info, int depth); bool smb_io_printmonitor_info_2(const char *desc, RPC_BUFFER *buffer, PRINTMONITOR_2 *info, int depth); @@ -5841,7 +5840,6 @@ uint32 spoolss_size_job_info_1(JOB_INFO_1 *info); uint32 spoolss_size_job_info_2(JOB_INFO_2 *info); uint32 spoolss_size_port_info_1(PORT_INFO_1 *info); uint32 spoolss_size_port_info_2(PORT_INFO_2 *info); -uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info); uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info); uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p); uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info); @@ -5881,8 +5879,6 @@ bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER 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); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index e101a27ca8..4351090ac4 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -771,33 +771,6 @@ SPOOL_R_ENUMPRINTERDRIVERS; /********************************************/ -typedef struct spool_q_enumprintprocessors -{ - uint32 name_ptr; - UNISTR2 name; - uint32 environment_ptr; - UNISTR2 environment; - uint32 level; - RPC_BUFFER *buffer; - uint32 offered; -} -SPOOL_Q_ENUMPRINTPROCESSORS; - -typedef struct printprocessor_1 -{ - UNISTR name; -} -PRINTPROCESSOR_1; - -typedef struct spool_r_enumprintprocessors -{ - RPC_BUFFER *buffer; - uint32 needed; - uint32 returned; - WERROR status; -} -SPOOL_R_ENUMPRINTPROCESSORS; - typedef struct spool_q_enumprintprocdatatypes { uint32 name_ptr; diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 181ad0e7d2..4d73e4f207 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -1184,24 +1184,6 @@ bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int /******************************************************************* ********************************************************************/ -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; @@ -1645,18 +1627,6 @@ uint32 spoolss_size_port_info_2(PORT_INFO_2 *info) 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; @@ -2216,77 +2186,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"); -- cgit From b73411d650d4d4bed99b75ffb36a1ab0dad9d4a8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 22:09:47 +0100 Subject: s3-spoolss: add rpccli_spoolss_enumprintprocessors convenience wrapper. Guenther --- source3/include/proto.h | 8 ++++++ source3/rpc_client/cli_spoolss.c | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index f7ca81d60d..8cefefaf11 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5481,6 +5481,14 @@ WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, uint32_t offered, uint32_t *count, union spoolss_FormInfo **info); +WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + const char *environment, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PrintProcessorInfo **info); WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, char *name, uint32 flags, uint32 level, uint32 *num_printers, PRINTER_INFO_CTR *ctr); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 5e09787a9c..664220ac19 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -330,6 +330,59 @@ WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, return werror; } +/********************************************************************** + convencience wrapper around rpccli_spoolss_EnumPrintProcessors +**********************************************************************/ + +WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername, + const char *environment, + uint32_t level, + uint32_t offered, + uint32_t *count, + union spoolss_PrintProcessorInfo **info) +{ + NTSTATUS status; + WERROR werror; + uint32_t needed; + DATA_BLOB buffer; + + if (offered > 0) { + buffer = data_blob_talloc_zero(mem_ctx, offered); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + } + + status = rpccli_spoolss_EnumPrintProcessors(cli, mem_ctx, + servername, + environment, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + + if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) { + offered = needed; + buffer = data_blob_talloc_zero(mem_ctx, needed); + W_ERROR_HAVE_NO_MEMORY(buffer.data); + + status = rpccli_spoolss_EnumPrintProcessors(cli, mem_ctx, + servername, + environment, + level, + (offered > 0) ? &buffer : NULL, + offered, + count, + info, + &needed, + &werror); + } + + return werror; +} /********************************************************************* Decode various spoolss rpc's and info levels -- cgit From a58e59fc6ed0ee91c8761cbda62c34e35e6dd153 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 22:11:09 +0100 Subject: s3-rpcclient: add enumprocs command to enumerate print processors. Guenther --- source3/rpcclient/cmd_spoolss.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index fae5c552c2..03d506e083 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3057,6 +3057,61 @@ 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; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -3092,6 +3147,7 @@ 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", "" }, { NULL } }; -- cgit From 3cf22a88562ccbab79c2a4a389fa6559cda71319 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 21:51:12 +0100 Subject: s3-spoolss: use pidl for _spoolss_EnumPrintProcDataTypes. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_spoolss.c | 22 +------- source3/rpc_server/srv_spoolss_nt.c | 102 ++++++++++++++++++------------------ 3 files changed, 51 insertions(+), 74 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 8cefefaf11..6e18126b16 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6127,7 +6127,6 @@ 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_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); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 9b83377bfe..5f6e7d8a2a 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -593,27 +593,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); } /**************************************************************************** diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5ded5aeadc..419e178389 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8822,77 +8822,86 @@ WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, } } +/**************************************************************************** + 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; } @@ -10447,17 +10456,6 @@ WERROR _spoolss_DeletePrintProvidor(pipes_struct *p, return WERR_NOT_SUPPORTED; } -/**************************************************************** - _spoolss_EnumPrintProcDataTypes -****************************************************************/ - -WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p, - struct spoolss_EnumPrintProcDataTypes *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - /**************************************************************** _spoolss_GetPrinterDriver2 ****************************************************************/ -- cgit From f9019c18375d3b63d21aa6ed346620c487d379fb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 21:51:52 +0100 Subject: s3-spoolss: remove old spoolss_EnumPrintProcDataTypes. Guenther --- source3/include/proto.h | 4 -- source3/include/rpc_spoolss.h | 27 ---------- source3/rpc_parse/parse_spoolss.c | 101 -------------------------------------- 3 files changed, 132 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 6e18126b16..4b0d79cc61 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5828,7 +5828,6 @@ bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, i bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth); bool smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth); bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth); -bool smb_io_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); @@ -5848,7 +5847,6 @@ uint32 spoolss_size_job_info_1(JOB_INFO_1 *info); uint32 spoolss_size_job_info_2(JOB_INFO_2 *info); uint32 spoolss_size_port_info_1(PORT_INFO_1 *info); uint32 spoolss_size_port_info_2(PORT_INFO_2 *info); -uint32 spoolss_size_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); @@ -5887,8 +5885,6 @@ bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER 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_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); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 4351090ac4..88e03acc27 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -771,33 +771,6 @@ SPOOL_R_ENUMPRINTERDRIVERS; /********************************************/ -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; diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 4d73e4f207..49be8fa3e1 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -1184,24 +1184,6 @@ bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int /******************************************************************* ********************************************************************/ -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; @@ -1623,18 +1605,6 @@ uint32 spoolss_size_port_info_2(PORT_INFO_2 *info) 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 ********************************************************************/ @@ -2183,77 +2153,6 @@ bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 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. ********************************************************************/ -- cgit From 2d24d3a3800fda96d266aead26286fbb3008339c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 22:22:49 +0100 Subject: s3-spoolss: add rpccli_spoolss_enumprintprocessordatatypes convenience wrapper. Guenther --- source3/include/proto.h | 8 ++++++ source3/rpc_client/cli_spoolss.c | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 4b0d79cc61..b5f310012c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5489,6 +5489,14 @@ WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli, 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_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, char *name, uint32 flags, uint32 level, uint32 *num_printers, PRINTER_INFO_CTR *ctr); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 664220ac19..11537fc689 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -384,6 +384,60 @@ WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli, 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; +} + /********************************************************************* Decode various spoolss rpc's and info levels ********************************************************************/ -- cgit From 62d73b8854b5a0a900c9abb3a60a2b089579886e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:55:15 +0100 Subject: s3-rpcclient: add enumprocdatatypes command to enumerate print processor data types. Guenther --- source3/rpcclient/cmd_spoolss.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 03d506e083..01e61b9a8c 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3112,6 +3112,61 @@ static WERROR cmd_spoolss_enum_procs(struct rpc_pipe_client *cli, 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; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -3148,6 +3203,7 @@ struct cmd_set spoolss_commands[] = { { "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", "" }, { NULL } }; -- cgit From 03f1bec6cea2749bcfb9b77b5eb220cfc17f22d0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 23:38:57 +0100 Subject: s3-spoolss: use pidl for _spoolss_EnumPorts. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_spoolss.c | 22 +--- source3/rpc_server/srv_spoolss_nt.c | 202 ++++++++++++++++++------------------ 3 files changed, 100 insertions(+), 125 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index b5f310012c..74707a7607 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6128,7 +6128,6 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u); WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u); WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ); -WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u); WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u); WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u); WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5f6e7d8a2a..c65b65119e 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -439,27 +439,7 @@ static bool api_spoolss_enumforms(pipes_struct *p) static bool api_spoolss_enumports(pipes_struct *p) { - SPOOL_Q_ENUMPORTS q_u; - SPOOL_R_ENUMPORTS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!spoolss_io_q_enumports("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n")); - return False; - } - - r_u.status = _spoolss_enumports(p, &q_u, &r_u); - - if (!spoolss_io_r_enumports("",&r_u,rdata,0)) { - DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); - return False; - } - - return True; + return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPORTS); } /**************************************************************************** diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 419e178389..8b1e21a518 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7446,9 +7446,14 @@ WERROR _spoolss_GetForm(pipes_struct *p, /**************************************************************************** ****************************************************************************/ -static void fill_port_1(PORT_INFO_1 *port, const char *name) +static WERROR fill_port_1(TALLOC_CTX *mem_ctx, + struct spoolss_PortInfo1 *r, + const char *name) { - init_unistr(&port->port_name, name); + r->port_name = talloc_strdup(mem_ctx, name); + W_ERROR_HAVE_NO_MEMORY(r->port_name); + + return WERR_OK; } /**************************************************************************** @@ -7456,13 +7461,23 @@ static void fill_port_1(PORT_INFO_1 *port, const char *name) somehow. ****************************************************************************/ -static void fill_port_2(PORT_INFO_2 *port, const char *name) +static WERROR fill_port_2(TALLOC_CTX *mem_ctx, + struct spoolss_PortInfo2 *r, + const char *name) { - init_unistr(&port->port_name, name); - init_unistr(&port->monitor_name, "Local Monitor"); - init_unistr(&port->description, SPL_LOCAL_PORT ); - port->port_type=PORT_TYPE_WRITE; - port->reserved=0x0; + r->port_name = talloc_strdup(mem_ctx, name); + W_ERROR_HAVE_NO_MEMORY(r->port_name); + + r->monitor_name = talloc_strdup(mem_ctx, "Local Monitor"); + W_ERROR_HAVE_NO_MEMORY(r->monitor_name); + + r->description = talloc_strdup(mem_ctx, SPL_LOCAL_PORT); /* FIXME */ + W_ERROR_HAVE_NO_MEMORY(r->description); + + r->port_type = SPOOLSS_PORT_TYPE_WRITE; + r->reserved = 0; + + return WERR_OK; } @@ -7530,9 +7545,13 @@ WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ) enumports level 1. ****************************************************************************/ -static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_1(TALLOC_CTX *mem_ctx, + union spoolss_PortInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PORT_INFO_1 *ports=NULL; + union spoolss_PortInfo *info = NULL; int i=0; WERROR result = WERR_OK; char **qlines = NULL; @@ -7540,31 +7559,31 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need result = enumports_hook(talloc_tos(), &numlines, &qlines ); if (!W_ERROR_IS_OK(result)) { - TALLOC_FREE(qlines); - return result; + goto out; } - if(numlines) { - if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { - DEBUG(10,("Returning WERR_NOMEM [%s]\n", - win_errstr(WERR_NOMEM))); - TALLOC_FREE(qlines); - return WERR_NOMEM; + if (numlines) { + info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines); + if (!info) { + DEBUG(10,("Returning WERR_NOMEM\n")); + result = WERR_NOMEM; + goto out; } for (i=0; i offered) { @@ -7572,64 +7591,64 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; - } - - /* fill the buffer with the ports structures */ - for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding port [%d] to buffer\n", i)); - smb_io_port_1("", buffer, &ports[i], 0); - } - out: - SAFE_FREE(ports); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + TALLOC_FREE(qlines); + *count = 0; + *info_p = NULL; + return result; + } - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; + *info_p = info; + *count = numlines; - return result; + return WERR_OK; } /**************************************************************************** enumports level 2. ****************************************************************************/ -static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_2(TALLOC_CTX *mem_ctx, + union spoolss_PortInfo **info_p, + uint32_t offered, + uint32_t *needed, + uint32_t *count) { - PORT_INFO_2 *ports=NULL; + union spoolss_PortInfo *info = NULL; int i=0; WERROR result = WERR_OK; char **qlines = NULL; int numlines = 0; result = enumports_hook(talloc_tos(), &numlines, &qlines ); - if ( !W_ERROR_IS_OK(result)) { - TALLOC_FREE(qlines); - return result; + if (!W_ERROR_IS_OK(result)) { + goto out; } - if(numlines) { - if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { - TALLOC_FREE(qlines); - return WERR_NOMEM; + if (numlines) { + info = TALLOC_ARRAY(mem_ctx, union spoolss_PortInfo, numlines); + if (!info) { + DEBUG(10,("Returning WERR_NOMEM\n")); + result = WERR_NOMEM; + goto out; } for (i=0; i offered) { @@ -7637,61 +7656,49 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need goto out; } - if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; - goto out; - } - - /* fill the buffer with the ports structures */ - for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding port [%d] to buffer\n", i)); - smb_io_port_2("", buffer, &ports[i], 0); - } - out: - SAFE_FREE(ports); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(info); + TALLOC_FREE(qlines); + *count = 0; + *info_p = NULL; + return result; + } - if ( !W_ERROR_IS_OK(result) ) - *returned = 0; + *info_p = info; + *count = numlines; - return result; + return WERR_OK; } -/**************************************************************************** - enumports. -****************************************************************************/ +/**************************************************************** + _spoolss_EnumPorts +****************************************************************/ -WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) +WERROR _spoolss_EnumPorts(pipes_struct *p, + struct spoolss_EnumPorts *r) { - uint32 level = q_u->level; - RPC_BUFFER *buffer = NULL; - uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; - uint32 *returned = &r_u->returned; - /* that's an [in out] buffer */ - if (!q_u->buffer && (offered!=0)) { - return WERR_INVALID_PARAM; - } - - if (offered > MAX_RPC_DATA_SIZE) { + if (!r->in.buffer && (r->in.offered != 0)) { return WERR_INVALID_PARAM; } - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; - - DEBUG(4,("_spoolss_enumports\n")); + DEBUG(4,("_spoolss_EnumPorts\n")); - *returned=0; - *needed=0; + *r->out.count = 0; + *r->out.needed = 0; + *r->out.info = NULL; - switch (level) { + switch (r->in.level) { case 1: - return enumports_level_1(buffer, offered, needed, returned); + return enumports_level_1(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); case 2: - return enumports_level_2(buffer, offered, needed, returned); + return enumports_level_2(p->mem_ctx, r->out.info, + r->in.offered, r->out.needed, + r->out.count); default: return WERR_UNKNOWN_LEVEL; } @@ -10280,17 +10287,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p, 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 ****************************************************************/ -- cgit From 631f277d1cd81de6d796888754b08e2443edad3d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 23:39:23 +0100 Subject: s3-spoolss: remove old spoolss_EnumPorts. Guenther --- source3/include/proto.h | 7 -- source3/include/rpc_spoolss.h | 37 ----------- source3/rpc_client/cli_spoolss.c | 134 -------------------------------------- source3/rpc_parse/parse_spoolss.c | 126 ----------------------------------- 4 files changed, 304 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 74707a7607..5db9b3ff0e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5500,8 +5500,6 @@ WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli, 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, @@ -5868,9 +5866,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); @@ -5890,8 +5885,6 @@ bool make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, uint32 level, RPC_BUFFER *buffer, uint32 offered); bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth); -bool spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth); -bool spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth); bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src); bool spoolss_io_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); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 88e03acc27..6ab74e633d 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -699,43 +699,6 @@ typedef struct s_port_info_2 } 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 diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 11537fc689..f2173faa93 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -572,68 +572,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; iprs, 0); - - for (i=0; idesthost); - strupper_m(server); - - offered = 0; - if (!rpcbuf_init(&buffer, offered, mem_ctx)) - return WERR_NOMEM; - make_spoolss_q_enumports( &in, server, level, &buffer, offered ); - - CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPORTS, - in, out, - qbuf, rbuf, - spoolss_io_q_enumports, - spoolss_io_r_enumports, - WERR_GENERAL_FAILURE ); - - if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) { - offered = out.needed; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - if (!rpcbuf_init(&buffer, offered, mem_ctx)) - return WERR_NOMEM; - make_spoolss_q_enumports( &in, server, level, &buffer, offered ); - - CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPORTS, - in, out, - qbuf, rbuf, - spoolss_io_q_enumports, - spoolss_io_r_enumports, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK(out.status) ) - return out.status; - - switch (level) { - case 1: - if (!decode_port_info_1(mem_ctx, out.buffer, out.returned, &ctr->port.info_1)) { - return WERR_GENERAL_FAILURE; - } - break; - case 2: - if (!decode_port_info_2(mem_ctx, out.buffer, out.returned, &ctr->port.info_2)) { - return WERR_GENERAL_FAILURE; - } - break; - default: - return WERR_UNKNOWN_LEVEL; - } - - *num_ports = out.returned; - - return out.status; -} - -/********************************************************************** -**********************************************************************/ - WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 level, const char *env, diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 49be8fa3e1..3b9262066d 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -828,52 +828,6 @@ bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 return True; } -/******************************************************************* - 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. ********************************************************************/ @@ -1747,24 +1701,6 @@ bool make_spoolss_q_enumprinters( return True; } -/******************************************************************* - * 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) @@ -2067,68 +2003,6 @@ bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVER 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* ******************************************************************/ -- cgit From c7e19c2627e5a336f506ad6e781547288e1b10c5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 23:27:45 +0100 Subject: s3-spoolss: add rpccli_spoolss_enumports convenience wrapper. Guenther --- source3/include/proto.h | 7 ++++++ source3/rpc_client/cli_spoolss.c | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 5db9b3ff0e..f64297c1e0 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5497,6 +5497,13 @@ WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli, 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_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, char *name, uint32 flags, uint32 level, uint32 *num_printers, PRINTER_INFO_CTR *ctr); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index f2173faa93..99ec98da8a 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -438,6 +438,57 @@ WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli, 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; +} + /********************************************************************* Decode various spoolss rpc's and info levels ********************************************************************/ -- cgit From e9179a6850a99d9d6ec25eba86ec02c9c1279850 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 23:36:31 +0100 Subject: s3-rpcclient: use rpccli_spoolss_enumports wrapper. Guenther --- source3/rpcclient/cmd_spoolss.c | 50 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 01e61b9a8c..03d88f743c 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); -- cgit From 2561b2d2e275bf1ca1aa7cab8b3942cff7d8b5f7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:04:05 +0100 Subject: s3-spoolss: use pidl for _spoolss_EnumMonitors. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_spoolss.c | 22 +---- source3/rpc_server/srv_spoolss_nt.c | 192 +++++++++++++++++++++--------------- 3 files changed, 112 insertions(+), 103 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index f64297c1e0..a4e8626d88 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6130,7 +6130,6 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ); 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_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u); WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u); WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u); WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c65b65119e..616eb1dbf0 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -581,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 8b1e21a518..0a4f5ae05c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8914,126 +8914,162 @@ WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p, } } +/**************************************************************************** + 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 ... @@ -9042,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; } @@ -10287,17 +10328,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p, 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 ****************************************************************/ -- cgit From d8a05bd55dd0e1602082376f31a21045a4a7bbee Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:04:48 +0100 Subject: s3-spoolss: remove old spoolss_EnumMonitors. Guenther --- source3/include/proto.h | 6 -- source3/include/rpc_spoolss.h | 34 ---------- source3/rpc_parse/parse_spoolss.c | 130 -------------------------------------- 3 files changed, 170 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index a4e8626d88..a7be0eccd3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5841,8 +5841,6 @@ bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, i bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth); bool smb_io_port_1(const char *desc, RPC_BUFFER *buffer, PORT_INFO_1 *info, int depth); bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int depth); -bool smb_io_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); @@ -5861,8 +5859,6 @@ uint32 spoolss_size_job_info_2(JOB_INFO_2 *info); uint32 spoolss_size_port_info_1(PORT_INFO_1 *info); uint32 spoolss_size_port_info_2(PORT_INFO_2 *info); uint32 spoolss_size_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( @@ -5893,8 +5889,6 @@ bool make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, RPC_BUFFER *buffer, uint32 offered); bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth); bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src); -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, diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 6ab74e633d..57ac7cfdd2 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -734,40 +734,6 @@ SPOOL_R_ENUMPRINTERDRIVERS; /********************************************/ -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/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 3b9262066d..b111fb687a 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -1135,46 +1135,6 @@ bool smb_io_port_2(const char *desc, RPC_BUFFER *buffer, PORT_INFO_2 *info, int 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 ********************************************************************/ @@ -1578,32 +1538,6 @@ uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p) return size; } -/******************************************************************* -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) @@ -2027,70 +1961,6 @@ bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 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; -} - /******************************************************************* ********************************************************************/ -- cgit From 33a441b0c223bc87abdac9dcc8a87dbf13e883f5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:10:15 +0100 Subject: s3-spoolss: add rpccli_spoolss_enummonitors convenience wrapper. Guenther --- source3/include/proto.h | 7 ++++++ source3/rpc_client/cli_spoolss.c | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index a7be0eccd3..df482be156 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5504,6 +5504,13 @@ WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli, 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); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 99ec98da8a..a83b0c53c6 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -489,6 +489,57 @@ WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli, 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 ********************************************************************/ -- cgit From d75d3502875f35cfabb9a41528f43f2fd129527c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:16:10 +0100 Subject: s3-rpcclient: add enummonitors command to enumerate print monitors. Guenther --- source3/rpcclient/cmd_spoolss.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 03d88f743c..6cbdf89583 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3159,6 +3159,66 @@ static WERROR cmd_spoolss_enum_proc_data_types(struct rpc_pipe_client *cli, 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[] = { @@ -3196,6 +3256,7 @@ struct cmd_set spoolss_commands[] = { { "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 } }; -- cgit From c9496ba18a52a4e80fd81c0dfa08129f95edeedb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 01:12:18 +0100 Subject: s3-spoolss: remove more leftovers from old enumports call. Guenther --- source3/include/proto.h | 6 --- source3/include/rpc_spoolss.h | 16 -------- source3/rpc_parse/parse_spoolss.c | 77 --------------------------------------- 3 files changed, 99 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index df482be156..5cd4e459ae 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5838,16 +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_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); 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); @@ -5863,8 +5859,6 @@ uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info); uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info); uint32 spoolss_size_job_info_1(JOB_INFO_1 *info); uint32 spoolss_size_job_info_2(JOB_INFO_2 *info); -uint32 spoolss_size_port_info_1(PORT_INFO_1 *info); -uint32 spoolss_size_port_info_2(PORT_INFO_2 *info); uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p); 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); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 57ac7cfdd2..fdce63aba3 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -683,22 +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; - typedef struct job_info_info { union diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index b111fb687a..337121d70d 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -1089,52 +1089,6 @@ bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, i 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; -} - /******************************************************************* return the size required by a struct in the stream ********************************************************************/ @@ -1488,37 +1442,6 @@ uint32 spoolss_size_job_info_2(JOB_INFO_2 *info) 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 ********************************************************************/ -- cgit From c29826a697f8d92b6b481a694c05b4d8a8e7424d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 3 Mar 2009 14:05:56 +0100 Subject: Fix some nonempty blank lines --- source3/libsmb/smb_signing.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/smb_signing.c b/source3/libsmb/smb_signing.c index 55b30d476f..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 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 . */ @@ -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; @@ -971,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); -- cgit From e58ade4136b40d82c24f3556845e7412a3330992 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 6 Mar 2009 14:24:59 +0100 Subject: Fix a smbclient segfault against security=share servers --- source3/libsmb/cliconnect.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index e3d1b65be0..ec2932488e 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1297,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; } -- cgit From 46bcb10b5abb21758cf234764b64220ede1b7ab5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 12 Feb 2009 17:48:52 +0100 Subject: Shape up pdb_search a bit by making it a talloc ctx with a destructor --- source3/include/passdb.h | 1 - source3/include/proto.h | 10 ++-- source3/passdb/pdb_interface.c | 63 ++++++++++++------------- source3/passdb/pdb_ldap.c | 20 ++++---- source3/passdb/pdb_smbpasswd.c | 9 ++-- source3/passdb/pdb_tdb.c | 11 ++--- source3/rpc_server/srv_samr_nt.c | 94 +++++++++++++++++++------------------- source3/utils/net.c | 9 ++-- source3/utils/net_sam.c | 16 ++++--- source3/utils/pdbedit.c | 20 ++++---- source3/winbindd/winbindd_passdb.c | 12 ++--- 11 files changed, 128 insertions(+), 137 deletions(-) (limited to 'source3') 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 5cd4e459ae..b6ddacca75 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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, 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_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/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; isearch_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_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; } -- cgit