The branch, master has been updated via 5c918d40bdc libsmb: Use tevent_req_received() in cli_qfileinfo_recv() via 0b6debbbb0a pylibsmb: Use async cli_mkdir also for smb2 via 99ced4cc58a libsmb: Remove sync cli_smb2_mkdir() via 93675b4f96e libsmb: Use async cli_smb2_mkdir in async cli_mkdir via 9b598a281b0 libsmb: Add async cli_smb2_mkdir_send()/recv() via e724c51d7f2 pylibsmb: Use async cli_chkpath also for smb2 via 44875bdad71 libsmb: Remove sync cli_smb2_chkpath() via c4bf5b23811 libsmb: Use async cli_smb2_chkpath in async cli_chkpath via fafdb5e38c5 libsmb: Add async cli_smb2_chkpath_send/recv() via 825948c766c pylibsmb: Use async cli_rmdir also for smb2 via 19bb7b00962 libsmb: Remove sync cli_smb2_rmdir() via 81a491dc800 libsmb: Use tevent_req_simple_finish_ntstatus() in cli_rmdir_done() via fe1e4dc9d95 libsmb: Use async cli_smb2_rmdir in async cli_rmdir via ecc25735440 smbcacls: Fix typo "inherated"->"inherited" via d9027c56a57 smbcacls: Align integer types via 358ad2800a8 smbcacls: Remove the CREATE_ACCESS_READ #define via 41ff5579759 smbcacls: Reformat a call to cli_ntcreate() via eec64f24561 libsmb: Remove the CREATE_ACCESS_READ #define via 535731a2911 libsmb: Reformat calls to cli_ntcreate() via e4b7d590608 smbclient: Remove the CREATE_ACCESS_READ #define via c164c036ab8 smbclient: Reformat a call to cli_ntcreate() via 1692b8a6518 pylibsmb: Use async cli_unlink also for smb2 via a92a4324c74 libsmb: Remove sync cli_smb2_unlink() via f8eb7545612 libsmb: Use tevent_req_simple_finish_ntstatus() in cli_unlink_done() via 5c8312f8e87 libsmb: Use async cli_smb2_unlink in async cli_unlink via 2c6138f47d7 libsmb: Remove clistr_pull_talloc() via 3cf84f0e1f9 libsmb: Trim #includes via 652b733337b libsmb: Remove an outdated comment from bae35ebcf34 s3:libsmb: remove finally unused credential flags
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 5c918d40bdc701d2eea384bd2890e7e4c5e490ca Author: Volker Lendecke <v...@samba.org> Date: Wed May 27 19:09:51 2020 +0200 libsmb: Use tevent_req_received() in cli_qfileinfo_recv() That takes care of doing the early talloc_free(state) Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Thu May 28 20:35:41 UTC 2020 on sn-devel-184 commit 0b6debbbb0abf3572db52450937ebd4e493ae758 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 09:01:57 2020 +0200 pylibsmb: Use async cli_mkdir also for smb2 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 99ced4cc58a0aebb52f6b78e99eb4b674ab156f6 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:31:10 2020 +0200 libsmb: Remove sync cli_smb2_mkdir() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 93675b4f96e6cf40a159dde975aa1d288a035706 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:23:31 2020 +0200 libsmb: Use async cli_smb2_mkdir in async cli_mkdir No need to call the sync wrapper in cli_mkdir() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 9b598a281b079ab9ac37f34e9c3cf9f5ede6b3a9 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 22:21:14 2020 +0200 libsmb: Add async cli_smb2_mkdir_send()/recv() Not converting the sync version to use it, it will go away very soon Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit e724c51d7f2753ee26a7f33ef00bae98b0ae8574 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 09:01:57 2020 +0200 pylibsmb: Use async cli_chkpath also for smb2 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 44875bdad715de833e548482b03c8524089e6df2 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:31:10 2020 +0200 libsmb: Remove sync cli_smb2_chkpath() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit c4bf5b23811f9bc14a8b6cabd3bfcb98778d31e0 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:23:31 2020 +0200 libsmb: Use async cli_smb2_chkpath in async cli_chkpath No need to call the sync wrapper in cli_chkpath() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit fafdb5e38c59e25af94afa091bacc717ae9a21af Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 22:21:14 2020 +0200 libsmb: Add async cli_smb2_chkpath_send/recv() Not converting the sync version to use it, it will go away very soon Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 825948c766c4d3b66897b9a8f73754fa430bc96d Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 09:01:57 2020 +0200 pylibsmb: Use async cli_rmdir also for smb2 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 19bb7b0096292a21f2676d238d02cac9b100bc2c Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:31:10 2020 +0200 libsmb: Remove sync cli_smb2_rmdir() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 81a491dc80062dff1767fa5271da365709faba67 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:29:26 2020 +0200 libsmb: Use tevent_req_simple_finish_ntstatus() in cli_rmdir_done() Save a few lines of code Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit fe1e4dc9d956b2b53946855757543eb205fae5c0 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:23:31 2020 +0200 libsmb: Use async cli_smb2_rmdir in async cli_rmdir No need to call the sync wrapper in cli_rmdir() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ecc2573544033a4b0498329d3836405b584161b7 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:17:14 2020 +0200 smbcacls: Fix typo "inherated"->"inherited" Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit d9027c56a5768d49fb372f51b473054b6e16e624 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:16:32 2020 +0200 smbcacls: Align integer types Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 358ad2800a85b130f5fc5a6a57daa6817c6ec001 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:04:52 2020 +0200 smbcacls: Remove the CREATE_ACCESS_READ #define That only confuses things Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 41ff5579759a577c2dfdfed955c970510375b25f Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:07:41 2020 +0200 smbcacls: Reformat a call to cli_ntcreate() The next patch will change one of the arguments Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit eec64f24561673933134f3d37c31011c09820b47 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:04:52 2020 +0200 libsmb: Remove the CREATE_ACCESS_READ #define That only confuses things Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 535731a291170e4706bd2c465f96bcfd3326972f Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:07:41 2020 +0200 libsmb: Reformat calls to cli_ntcreate() The next patch will change one of the arguments Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit e4b7d590608accdf1ade571c7caa14f4d7de5781 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:04:52 2020 +0200 smbclient: Remove the CREATE_ACCESS_READ #define That only confuses things Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit c164c036ab86ffaff8668bf1d19aae545c2685ff Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 08:01:33 2020 +0200 smbclient: Reformat a call to cli_ntcreate() The next patch will change one of the arguments Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 1692b8a65180c3c90d5ae40fc05400228510b3d6 Author: Volker Lendecke <v...@samba.org> Date: Tue May 26 09:01:57 2020 +0200 pylibsmb: Use async cli_unlink also for smb2 Async cli_smb2_unlink was just added Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a92a4324c74c30d2bb20ff1432d0622eaf382a64 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:31:10 2020 +0200 libsmb: Remove sync cli_smb2_unlink() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit f8eb7545612377216e8265c7de6544856797bf7d Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:29:26 2020 +0200 libsmb: Use tevent_req_simple_finish_ntstatus() in cli_unlink_done() Save a few lines of code Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 5c8312f8e8777c4e5d0c3bcddc8ad8f95f8fa60e Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:23:31 2020 +0200 libsmb: Use async cli_smb2_unlink in async cli_unlink No need to call the sync wrapper in cli_unlink() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 2c6138f47d762bbefaccf924bea192c2b91ed073 Author: Volker Lendecke <v...@samba.org> Date: Sun May 17 12:57:32 2020 +0200 libsmb: Remove clistr_pull_talloc() This was just a 1:1 wrapper around pull_string_talloc() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 3cf84f0e1f94bc127090aef4a8704fecd07a3a6a Author: Volker Lendecke <v...@samba.org> Date: Sun May 17 12:06:23 2020 +0200 libsmb: Trim #includes Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 652b733337b76096ffd38917b810931404cc1695 Author: Volker Lendecke <v...@samba.org> Date: Mon May 25 18:21:40 2020 +0200 libsmb: Remove an outdated comment Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/client/client.c | 19 ++- source3/include/libsmb_internal.h | 2 - source3/libsmb/cli_smb2_fnum.c | 289 +++++++++++++++++++------------------- source3/libsmb/cli_smb2_fnum.h | 23 +-- source3/libsmb/cliconnect.c | 28 ++-- source3/libsmb/clidfs.c | 2 +- source3/libsmb/clifile.c | 118 +++++++++++----- source3/libsmb/clifsinfo.c | 2 +- source3/libsmb/clilist.c | 70 ++++----- source3/libsmb/clirap.c | 2 +- source3/libsmb/clistr.c | 19 +-- source3/libsmb/libsmb_xattr.c | 33 ++++- source3/libsmb/proto.h | 7 - source3/libsmb/pylibsmb.c | 71 ++++------ source3/utils/smbcacls.c | 28 ++-- 15 files changed, 373 insertions(+), 340 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/client/client.c b/source3/client/client.c index 87b27062d15..2a95911f54d 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -66,8 +66,6 @@ static int max_protocol = -1; static int process_tok(char *tok); static int cmd_help(void); -#define CREATE_ACCESS_READ READ_CONTROL_ACCESS - /* value for unused fid field in trans2 secondary request */ #define FID_UNUSED (0xFFFF) @@ -606,10 +604,19 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->mode)); d_printf( "SIZE:%.0f\n", (double)finfo->size); d_printf( "MTIME:%s", time_to_asc(t)); - status = cli_ntcreate(cli_state, afname, 0, - CREATE_ACCESS_READ, 0, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, 0x0, 0x0, &fnum, NULL); + status = cli_ntcreate( + cli_state, /* cli */ + afname, /* fname */ + 0, /* CreatFlags */ + READ_CONTROL_ACCESS, /* DesiredAccess */ + 0, /* FileAttributes */ + FILE_SHARE_READ| + FILE_SHARE_WRITE, /* ShareAccess */ + FILE_OPEN, /* CreateDisposition */ + 0x0, /* CreateOptions */ + 0x0, /* SecurityFlags */ + &fnum, /* pfid */ + NULL); /* cr */ if (!NT_STATUS_IS_OK(status)) { DEBUG( 0, ("display_finfo() Failed to open %s: %s\n", afname, nt_errstr(status))); diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 13fd46977a0..ba9936a0eba 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -65,8 +65,6 @@ struct DOS_ATTR_DESC { #define SMBC_XATTR_MODE_CHOWN 5 #define SMBC_XATTR_MODE_CHGRP 6 -#define CREATE_ACCESS_READ READ_CONTROL_ACCESS - /*We should test for this in configure ... */ #ifndef ENOTSUP #define ENOTSUP EOPNOTSUPP diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 7fed546d63f..c1c755a97ea 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -760,46 +760,84 @@ NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool fla return status; } -/*************************************************************** - Small wrapper that allows SMB2 to create a directory - Synchronous only. -***************************************************************/ +struct cli_smb2_mkdir_state { + struct tevent_context *ev; + struct cli_state *cli; +}; + +static void cli_smb2_mkdir_opened(struct tevent_req *subreq); +static void cli_smb2_mkdir_closed(struct tevent_req *subreq); -NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dname) +struct tevent_req *cli_smb2_mkdir_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *dname) { + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_smb2_mkdir_state *state = NULL; + + req = tevent_req_create( + mem_ctx, &state, struct cli_smb2_mkdir_state); + if (req == NULL) { + return NULL; + } + state->ev = ev; + state->cli = cli; + + /* Ensure this is a directory. */ + subreq = cli_smb2_create_fnum_send( + state, /* mem_ctx */ + ev, /* ev */ + cli, /* cli */ + dname, /* fname */ + 0, /* create_flags */ + SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level */ + FILE_READ_ATTRIBUTES, /* desired_access */ + FILE_ATTRIBUTE_DIRECTORY, /* file_attributes */ + FILE_SHARE_READ| + FILE_SHARE_WRITE, /* share_access */ + FILE_CREATE, /* create_disposition */ + FILE_DIRECTORY_FILE, /* create_options */ + NULL); /* in_cblobs */ + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_smb2_mkdir_opened, req); + return req; +} + +static void cli_smb2_mkdir_opened(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct cli_smb2_mkdir_state *state = tevent_req_data( + req, struct cli_smb2_mkdir_state); NTSTATUS status; uint16_t fnum; - if (smbXcli_conn_has_async_calls(cli->conn)) { - /* - * Can't use sync call while an async call is in flight - */ - return NT_STATUS_INVALID_PARAMETER; + status = cli_smb2_create_fnum_recv(subreq, &fnum, NULL, NULL, NULL); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; } - if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) { - return NT_STATUS_INVALID_PARAMETER; + subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum); + if (tevent_req_nomem(subreq, req)) { + return; } + tevent_req_set_callback(subreq, cli_smb2_mkdir_closed, req); +} - status = cli_smb2_create_fnum(cli, - dname, - 0, /* create_flags */ - SMB2_IMPERSONATION_IMPERSONATION, - FILE_READ_ATTRIBUTES, /* desired_access */ - FILE_ATTRIBUTE_DIRECTORY, /* file attributes */ - FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */ - FILE_CREATE, /* create_disposition */ - FILE_DIRECTORY_FILE, /* create_options */ - NULL, - &fnum, - NULL, - NULL, - NULL); +static void cli_smb2_mkdir_closed(struct tevent_req *subreq) +{ + NTSTATUS status = cli_smb2_close_fnum_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); +} - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return cli_smb2_close_fnum(cli, fnum); +NTSTATUS cli_smb2_mkdir_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); } struct cli_smb2_rmdir_state { @@ -976,46 +1014,8 @@ NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req) return state->status; } -NTSTATUS cli_smb2_rmdir( - struct cli_state *cli, - const char *dname, - const struct smb2_create_blobs *in_cblobs) -{ - TALLOC_CTX *frame = talloc_stackframe(); - struct tevent_context *ev; - struct tevent_req *req; - NTSTATUS status = NT_STATUS_NO_MEMORY; - bool ok; - - if (smbXcli_conn_has_async_calls(cli->conn)) { - /* - * Can't use sync call while an async call is in flight - */ - status = NT_STATUS_INVALID_PARAMETER; - goto fail; - } - ev = samba_tevent_context_init(frame); - if (ev == NULL) { - goto fail; - } - req = cli_smb2_rmdir_send(frame, ev, cli, dname, in_cblobs); - if (req == NULL) { - goto fail; - } - ok = tevent_req_poll_ntstatus(req, ev, &status); - if (!ok) { - goto fail; - } - status = cli_smb2_rmdir_recv(req); -fail: - cli->raw_status = status; - TALLOC_FREE(frame); - return status; -} - /*************************************************************** Small wrapper that allows SMB2 to unlink a pathname. - Synchronous only. ***************************************************************/ struct cli_smb2_unlink_state { @@ -1161,43 +1161,6 @@ NTSTATUS cli_smb2_unlink_recv(struct tevent_req *req) return tevent_req_simple_recv_ntstatus(req); } -NTSTATUS cli_smb2_unlink( - struct cli_state *cli, - const char *fname, - const struct smb2_create_blobs *in_cblobs) -{ - TALLOC_CTX *frame = talloc_stackframe(); - struct tevent_context *ev; - struct tevent_req *req; - NTSTATUS status = NT_STATUS_NO_MEMORY; - bool ok; - - if (smbXcli_conn_has_async_calls(cli->conn)) { - /* - * Can't use sync call while an async call is in flight - */ - status = NT_STATUS_INVALID_PARAMETER; - goto fail; - } - ev = samba_tevent_context_init(frame); - if (ev == NULL) { - goto fail; - } - req = cli_smb2_unlink_send(frame, ev, cli, fname, in_cblobs); - if (req == NULL) { - goto fail; - } - ok = tevent_req_poll_ntstatus(req, ev, &status); - if (!ok) { - goto fail; - } - status = cli_smb2_unlink_recv(req); -fail: - cli->raw_status = status; - TALLOC_FREE(frame); - return status; -} - /*************************************************************** Utility function to parse a SMB2_FIND_ID_BOTH_DIRECTORY_INFO reply. ***************************************************************/ @@ -1615,49 +1578,85 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli, return status; } -/*************************************************************** - Wrapper that allows SMB2 to check if a path is a directory. - Synchronous only. -***************************************************************/ +struct cli_smb2_chkpath_state { + struct tevent_context *ev; + struct cli_state *cli; +}; + +static void cli_smb2_chkpath_opened(struct tevent_req *subreq); +static void cli_smb2_chkpath_closed(struct tevent_req *subreq); -NTSTATUS cli_smb2_chkpath(struct cli_state *cli, - const char *name) +struct tevent_req *cli_smb2_chkpath_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *name) { - NTSTATUS status; - uint16_t fnum = 0xffff; + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_smb2_chkpath_state *state = NULL; - if (smbXcli_conn_has_async_calls(cli->conn)) { - /* - * Can't use sync call while an async call is in flight - */ - return NT_STATUS_INVALID_PARAMETER; + req = tevent_req_create( + mem_ctx, &state, struct cli_smb2_chkpath_state); + if (req == NULL) { + return NULL; } + state->ev = ev; + state->cli = cli; - if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) { - return NT_STATUS_INVALID_PARAMETER; + /* Ensure this is a directory. */ + subreq = cli_smb2_create_fnum_send( + state, /* mem_ctx */ + ev, /* ev */ + cli, /* cli */ + name, /* fname */ + 0, /* create_flags */ + SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level */ + FILE_READ_ATTRIBUTES, /* desired_access */ + FILE_ATTRIBUTE_DIRECTORY, /* file_attributes */ + FILE_SHARE_READ| + FILE_SHARE_WRITE| + FILE_SHARE_DELETE, /* share_access */ + FILE_OPEN, /* create_disposition */ + FILE_DIRECTORY_FILE, /* create_options */ + NULL); /* in_cblobs */ + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); } + tevent_req_set_callback(subreq, cli_smb2_chkpath_opened, req); + return req; +} - /* Ensure this is a directory. */ - status = cli_smb2_create_fnum(cli, - name, - 0, /* create_flags */ - SMB2_IMPERSONATION_IMPERSONATION, - FILE_READ_ATTRIBUTES, /* desired_access */ - FILE_ATTRIBUTE_DIRECTORY, /* file attributes */ - FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */ - FILE_OPEN, /* create_disposition */ - FILE_DIRECTORY_FILE, /* create_options */ - NULL, - &fnum, - NULL, - NULL, - NULL); +static void cli_smb2_chkpath_opened(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct cli_smb2_chkpath_state *state = tevent_req_data( + req, struct cli_smb2_chkpath_state); + NTSTATUS status; + uint16_t fnum; - if (!NT_STATUS_IS_OK(status)) { - return status; + status = cli_smb2_create_fnum_recv(subreq, &fnum, NULL, NULL, NULL); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; + } + + subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum); + if (tevent_req_nomem(subreq, req)) { + return; } + tevent_req_set_callback(subreq, cli_smb2_chkpath_closed, req); +} - return cli_smb2_close_fnum(cli, fnum); +static void cli_smb2_chkpath_closed(struct tevent_req *subreq) +{ + NTSTATUS status = cli_smb2_close_fnum_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); +} + +NTSTATUS cli_smb2_chkpath_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); } struct cli_smb2_query_info_fnum_state { @@ -2902,13 +2901,13 @@ NTSTATUS cli_smb2_get_fs_volume_info(struct cli_state *cli, goto fail; } - clistr_pull_talloc(mem_ctx, - (const char *)outbuf.data, - 0, - &volume_name, - outbuf.data + 18, - nlen, - STR_UNICODE); + pull_string_talloc(mem_ctx, + (const char *)outbuf.data, + 0, + &volume_name, + outbuf.data + 18, + nlen, + STR_UNICODE); if (volume_name == NULL) { status = map_nt_error_from_unix(errno); goto fail; diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h index 202cf84bc0e..b921d066ed3 100644 --- a/source3/libsmb/cli_smb2_fnum.h +++ b/source3/libsmb/cli_smb2_fnum.h @@ -73,7 +73,12 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx, bool flag); NTSTATUS cli_smb2_delete_on_close_recv(struct tevent_req *req); NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag); -NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname); +struct tevent_req *cli_smb2_mkdir_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *name); +NTSTATUS cli_smb2_mkdir_recv(struct tevent_req *req); struct tevent_req *cli_smb2_rmdir_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -81,10 +86,6 @@ struct tevent_req *cli_smb2_rmdir_send( const char *dname, const struct smb2_create_blobs *in_cblobs); NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req); -NTSTATUS cli_smb2_rmdir( - struct cli_state *cli, - const char *dname, - const struct smb2_create_blobs *in_cblobs); struct tevent_req *cli_smb2_unlink_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -92,10 +93,6 @@ struct tevent_req *cli_smb2_unlink_send( const char *fname, const struct smb2_create_blobs *in_cblobs); NTSTATUS cli_smb2_unlink_recv(struct tevent_req *req); -NTSTATUS cli_smb2_unlink( - struct cli_state *cli, - const char *fname, - const struct smb2_create_blobs *in_cblobs); NTSTATUS cli_smb2_list(struct cli_state *cli, const char *pathname, uint16_t attribute, @@ -111,8 +108,12 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli, NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli, const char *name, fstring alt_name); -NTSTATUS cli_smb2_chkpath(struct cli_state *cli, - const char *name); +struct tevent_req *cli_smb2_chkpath_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *name); +NTSTATUS cli_smb2_chkpath_recv(struct tevent_req *req); struct tevent_req *cli_smb2_query_info_fnum_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 9d0296873ea..1fb1f0127b9 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -412,13 +412,13 @@ static NTSTATUS smb_bytes_talloc_string(TALLOC_CTX *mem_ctx, size_t srclen, ssize_t *destlen) { - *destlen = clistr_pull_talloc(mem_ctx, - (const char *)hdr, - SVAL(hdr, HDR_FLG2), - dest, - (char *)src, - srclen, - STR_TERMINATE); + *destlen = pull_string_talloc(mem_ctx, + (const char *)hdr, + SVAL(hdr, HDR_FLG2), + dest, + (char *)src, + srclen, + STR_TERMINATE); if (*destlen == -1) { return NT_STATUS_NO_MEMORY; } @@ -2164,13 +2164,13 @@ static void cli_tcon_andx_done(struct tevent_req *subreq) inhdr = in + NBT_HDR_SIZE; if (num_bytes) { - if (clistr_pull_talloc(cli, - (const char *)inhdr, - SVAL(inhdr, HDR_FLG2), - &cli->dev, - bytes, - num_bytes, - STR_TERMINATE|STR_ASCII) == -1) { + if (pull_string_talloc(cli, + (const char *)inhdr, + SVAL(inhdr, HDR_FLG2), + &cli->dev, + bytes, + num_bytes, + STR_TERMINATE|STR_ASCII) == -1) { tevent_req_nterror(req, NT_STATUS_NO_MEMORY); return; -- Samba Shared Repository